00001 00041 #ifndef _ENTITY_H 00042 #define _ENTITY_H 00043 00044 #include "object.h" 00045 #include <string> 00046 00047 using std::ostream; 00048 using std::string; 00049 00050 namespace container { 00051 00055 class Entity: public Object { 00056 public: 00057 00058 const static Info * const TYPE_INFO; 00059 00060 protected: 00061 00062 const static int COMPARE_KEY_TO_NULL_RVAL; 00063 00064 private: 00065 00066 static int nextDefaultKey; 00067 00068 int defaultKey; 00069 mutable string* keyAsString; 00070 00071 public: 00072 00073 Entity(); 00074 00080 Entity(int key); 00081 00082 Entity(const Entity& pattern); 00083 virtual ~Entity(); 00084 00085 Entity & operator=(const Entity& second); 00086 00087 /********************* Entity Methods (public) *********************/ 00088 00105 virtual int compareKeyTo(const Entity& second) const; 00106 00117 const string& getKeyAsString() const; 00118 00119 protected: 00120 00121 /********************* Entity Methods (protected) *********************/ 00122 00123 int getDefaultKey(); 00124 00125 void invalidateKeyAsString(); 00126 00127 virtual string* generateKeyAsString() const; 00128 00129 public: 00130 00131 /********************* Object Methods (public) *********************/ 00132 00133 virtual ostream& renderState(ostream& os) const; 00134 00135 virtual const Info* typeInfo() const; 00136 00137 virtual Object* clone(bool deepCopy = false) const; 00138 00139 }; 00140 00141 } // namespace container 00142 #endif /* _ENTITY_H */