From: Ricardo Markiewicz Date: Mon, 12 Sep 2005 05:08:45 +0000 (+0000) Subject: Agrego estructura basica para manejo de claves X-Git-Tag: 1_0-pre1~157 X-Git-Url: https://git.llucax.com/z.facultad/75.52/treemulator.git/commitdiff_plain/1b6152a8b901df0e8b57c35b9846a6e609b8b7df?ds=inline;hp=b0999d0c64b37aee18260b6ba0f2dda47a974c6a Agrego estructura basica para manejo de claves La idea es que el manejo sea transparente a travez del tipo "Clave" y toda la magia la haga los objetitos. --- diff --git a/src/Makefile b/src/Makefile index 5440d99..cd9cbe7 100644 --- a/src/Makefile +++ b/src/Makefile @@ -3,5 +3,6 @@ CXXFLAGS=-Wall -g all: $(TARGET) -$(TARGET): main.o btree.o - g++ -o $(TARGET) main.o btree.o +$(TARGET): main.o btree.o clave_fija.o + g++ -o $(TARGET) main.o btree.o clave_fija.o + diff --git a/src/btree.h b/src/btree.h index 0ed4fbd..744079b 100644 --- a/src/btree.h +++ b/src/btree.h @@ -45,9 +45,9 @@ */ #include +#include "common.h" /* alias para codear menos :) */ -typedef unsigned char uchar; /** Encabezado del archivo BTree */ typedef struct _btree_file_ { diff --git a/src/clave.h b/src/clave.h new file mode 100644 index 0000000..7cf3ceb --- /dev/null +++ b/src/clave.h @@ -0,0 +1,17 @@ + +#ifndef _CLAVE_H_ +#define _CLAVE_H_ + +/* Clave para agregar a un arbol B */ +#include "common.h" + +class Clave { + public: + virtual ~Clave () {} + + virtual uint Size () = 0; + virtual uchar *ToArray () = 0; +}; + +#endif + diff --git a/src/clave_fija.cpp b/src/clave_fija.cpp new file mode 100644 index 0000000..05c9814 --- /dev/null +++ b/src/clave_fija.cpp @@ -0,0 +1,17 @@ + +#include +#include "clave_fija.h" + +uint ClaveFija::Size () +{ + return sizeof (int); +} + +uchar *ClaveFija::ToArray () +{ + uchar *out; + out = new uchar[sizeof(int)]; + memcpy (out, &data, sizeof(int)); + return out; +} + diff --git a/src/clave_fija.h b/src/clave_fija.h new file mode 100644 index 0000000..b11fe22 --- /dev/null +++ b/src/clave_fija.h @@ -0,0 +1,19 @@ + +#ifndef _CLAVE_FIJA_H_ +#define _CLAVE_FIJA_H_ + +#include "clave.h" + +class ClaveFija : Clave { + public : + virtual ~ClaveFija () {} + + virtual uint Size (); + virtual uchar *ToArray (); + + private: + int data; +}; + +#endif + diff --git a/src/common.h b/src/common.h new file mode 100644 index 0000000..6e7079f --- /dev/null +++ b/src/common.h @@ -0,0 +1,9 @@ + +#ifndef _COMMON_H_ +#define _COMMON_H_ + +typedef unsigned char uchar; +typedef unsigned int uint; + +#endif +