00001 /******************************************************************************/ 00002 /* */ 00003 /* POLiTe - Persistent Object Library Test */ 00004 /* Ph.D. Thesis by Mgr. Michal Kopecky */ 00005 /* */ 00006 /* Charles University Prague */ 00007 /* */ 00008 /******************************************************************************/ 00009 /* */ 00010 /* File name: ... */ 00011 /* Module: ...... */ 00012 /* */ 00013 /******************************************************************************/ 00014 00015 #ifndef __C_IMMUTABLEOBJECT_H__ 00016 #define __C_IMMUTABLEOBJECT_H__ 00017 00018 // Parent Header(s) 00019 #include <cObject.h> 00020 00021 class DLL_External ImmutableObject : public Object 00022 { 00023 #ifdef POLITE_TEST_FRIEND 00024 friend POLITE_TEST_FRIEND; 00025 #endif // POLITE_TEST_FRIEND 00026 00027 protected: 00028 unsigned int _MemoryLocks; 00029 // Number of memory locks on the object 00030 00031 public: 00032 ImmutableObject() : Object() {}; // constructor 00033 ~ImmutableObject(); // destructor 00034 00035 static const char* RootClassName() {return NULL;}; 00036 static const char* BaseClassName() {return "ImmutableObject";}; 00037 ABSTRACT_CLASS(ImmutableObject); 00038 //static const char* ClassName() {return "ImmutableObject";}; 00039 //static const Object * New() {return NULL;}; 00040 //virtual class ProtoBase *Prototype() const = 0 00041 PARENTS(NULL); 00042 //static const char* ParentClassNames() {return NULL;}; 00043 FROM(""); 00044 //static const char* From() {return "";}; 00045 WHERE(""); 00046 //static const char* Where() {return "";}; 00047 GROUP_BY(""); 00048 //static const char* GroupBy() {return "";}; 00049 HAVING(""); 00050 //static const char* Having() {return "";}; 00051 ORDER_BY(""); 00052 //static const char* OrderBy() {return "";}; 00053 MAPKEY_BEGIN 00054 MAPKEY_END; 00055 MAP_BEGIN 00056 MAP_END; 00057 00058 public: 00059 virtual bool IsTransient() const 00060 //Returns TRUE if an instance of DatabaseObject is transient, 00061 //i.e. if it has no copy in database. This can happen if the 00062 //object was created as transient and was not made persistent 00063 //by calling BePersistent yet. 00064 { return (_Connection == NULL);}; 00065 00066 virtual bool IsPersistent() const 00067 //Returns TRUE if the object is really persistent, otherwise 00068 //it returns False. This function returns the opposite value 00069 //to the method IsTransient. 00070 { return (_Connection != NULL);}; 00071 00072 public: 00073 virtual Object *MemoryLock(); 00074 //Locks a persistent object. Multiple locks 00075 //can be placed on the object. The object can be 00076 //removed from memory only when all the locks are 00077 //released. 00078 00079 virtual bool MemoryUnlock(); 00080 //Unlocks a persistent object in memory. See MemoryLock. 00081 00082 virtual unsigned int MemoryLocked() const; 00083 //Returns the number of memory locks on receiver or zero 00084 //if it is not locked. 00085 00086 virtual bool RemoveAllMemoryLocks(); 00087 //Removes all memory locks existing in the GEN.LIB 00088 00089 00090 }; 00091 //ABSTRACT_CLASS_PROTOTYPE(ImmutableObject); 00092 extern DLL_External Proto<ImmutableObject> ImmutableObject_class; 00093 00094 #endif // __C_IMMUTABLEOBJECT_H__ 00095 00096