X-Git-Url: https://git.llucax.com/z.facultad/75.52/treemulator.git/blobdiff_plain/52d9e098f15ad0ca70f11b4549f3d55f55a22a83..2ab8041933e77875de62bc73e76febc528af258e:/src/btree_data.h?ds=inline diff --git a/src/btree_data.h b/src/btree_data.h index 44a3a77..ca2cd4d 100644 --- a/src/btree_data.h +++ b/src/btree_data.h @@ -6,25 +6,32 @@ #include #include "clave.h" #include "clave_fija.h" +#include "clave_variable.h" /** Dato a guardar en los nodos */ class BTreeData { public: - BTreeData () { clave = NULL; } - BTreeData (uchar *node); + BTreeData () {} + BTreeData (uchar *node, int tree_type); + 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; + 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; @@ -34,12 +41,35 @@ class BTreeData { /** Dato a guardar en las hojas */ class BTreeLeafData:public BTreeData { public: - BTreeLeafData (Clave *k):BTreeData () { clave = k; } - BTreeLeafData (uchar *node) { clave = new ClaveFija (node); } + BTreeLeafData (Clave *k) { clave = k; } + BTreeLeafData (uchar *node, int key_type); 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