00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 #ifndef ELEMENT_H
00025 #define ELEMENT_H
00026 
00027 #include "FileIO.h"
00028 
00048 template <typename T>
00049 class CompareElements {
00050  public:
00051 
00053   bool operator() (const T *x, const T *y) {
00054     
00055     return(*x < *y);
00056   }
00057 };
00058 
00078 class Element {
00079  public:
00080 
00082   Element(char *name, int number, FILE_POS_TYPE filePosition = 0);
00083   ~Element(void);
00084 
00086   void assignPosition(FILE_POS_TYPE position);
00087 
00089   FILE_POS_TYPE filePosition(void);
00090 
00092   char *name(void);
00093 
00095   int number(void);
00096 
00098   bool operator< (const Element &word) const;
00099 
00101   bool operator== (const Element &word) const;
00102 
00104   void operator= (const Element &word);
00105 
00107   void purge(FileIO *file);
00108 
00110   void salvage(FileIO *file);
00111 
00112   void hashNumber(int number);
00113   int hashNumber(void);
00114 
00115   friend class OrderElements;
00116 
00117  protected:
00118   Element(void);
00119   int _number;
00120 
00121  private:
00122   char *_name;
00123   int _nameLength;
00124   FILE_POS_TYPE _filePosition;
00125 
00126   
00127   int _hashNumber;
00128 };
00129 
00130 
00149 class OrderElements {
00150  public:
00151 
00153   bool operator() (const Element *x, const Element *y) {
00154     return (x->_number < y->_number);
00155   }
00156 };
00157 
00158 
00159 #endif