X-Git-Url: https://git.llucax.com/z.facultad/75.52/treemulator.git/blobdiff_plain/a86378ad0949572fd260f105f3e02f2c3e1370a0..a164e095defb0f86d8dcde22c6054b5e2bc7da7b:/src/btree_data.h?ds=inline diff --git a/src/btree_data.h b/src/btree_data.h index c1d4261..f7106df 100644 --- a/src/btree_data.h +++ b/src/btree_data.h @@ -10,20 +10,26 @@ /** Dato a guardar en los nodos */ class BTreeData { public: - BTreeData () { clave = NULL; } + BTreeData () {} BTreeData (uchar *node); + BTreeData (Clave *k, uint child); virtual ~BTreeData (); - virtual uint Size (); - virtual uchar *ToArray (); + virtual uint Size () const; + virtual uchar *ToArray () const; + Clave* getClave () { return clave; } + uint getChild () { return hijo; } + void setChild (uint c) { hijo = c; } bool operator < (const BTreeData &data) const; virtual operator std::string () const { - if (clave) { - return (*clave); - } - return "NoKey"; + std::string out = (*clave); + std::stringstream ss; + ss << "(" << out ; + ss << ")" << "[" << hijo << "]"; + ss >> out; + return out; } protected: Clave *clave; @@ -33,12 +39,35 @@ class BTreeData { /** Dato a guardar en las hojas */ class BTreeLeafData:public BTreeData { public: - BTreeLeafData (Clave *k):BTreeData () { clave = k; } + BTreeLeafData (Clave *k) { clave = k; } BTreeLeafData (uchar *node) { clave = new ClaveFija (node); } virtual ~BTreeLeafData (); - virtual uint Size (); - virtual uchar *ToArray (); + virtual uint Size () const; + virtual uchar *ToArray () const; + virtual operator std::string () const { + if (clave) { + return (*clave); + } + return "NoKey"; + } +}; + +class BTreeChildData:public BTreeData { + public: + BTreeChildData (uint child):BTreeData () { hijo = child; clave = NULL; } + BTreeChildData (uchar *node); + virtual ~BTreeChildData (); + + virtual uint Size () const; + virtual uchar *ToArray () const; + virtual operator std::string () const { + std::string out; + std::stringstream ss; + ss << "|" << hijo << "|"; + ss >> out; + return out; + } }; #endif