Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

cImmutableObject.cpp

Go to the documentation of this file.
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 // Own Header
00016 #include <cImmutableObject.h>
00017 
00018 PROTOTYPE(ImmutableObject);
00019 //Proto<ImmutableObject> ImmutableObject_class;
00020 
00022 // Object destructor:
00023 // Delete the Object object with the appropriate de-initialization.
00024 
00025 ImmutableObject::~ImmutableObject()     // destructor
00026 {
00027         #ifdef C_IMMUTABLEOBJECT_TRACE
00028         logmsg("ImmutableObject::~ImmutableObject() invoked");
00029         #endif
00030 
00031         _Free();
00032 
00033         #ifdef C_IMMUTABLEOBJECT_TRACE
00034         logmsg("ImmutableObject::~ImmutableObject() finished");
00035         #endif
00036 }
00037 
00039 //Locks a persistent object. Multiple locks can be placed on the object. The object
00040 //can be removed from memory only when all the locks are released..
00041 
00042 Object  *ImmutableObject::MemoryLock()
00043 {
00044         Object  *retval;
00045 
00046         #ifdef C_IMMUTABLEOBJECT_TRACE
00047         logmsg("DatabaseObject *ImmutableObject::MemoryLock() invoked");
00048         #endif
00049 
00050         if (IsTransient())
00051                 retval = this;
00052         else if (_MemoryLocks < ~(unsigned int)0) {
00053                 _MemoryLocks++;
00054                 retval = this;
00055                 }
00056         else
00057                 retval = NULL;
00058 
00059         #ifdef C_IMMUTABLEOBJECT_TRACE
00060         logmsg("DatabaseObject *ImmutableObject::MemoryLock() finished");
00061         #endif
00062 
00063         return retval;
00064 }
00065 
00067 //Unlocks a persistent object in memory. See MemoryLock.
00068 //covered external events:
00069 //· Unlock object in memory
00070 
00071 bool ImmutableObject::MemoryUnlock()
00072 {
00073         #ifdef C_IMMUTABLEOBJECT_TRACE
00074         logmsg("bool ImmutableObject::MemoryUnlock() invoked");
00075         #endif
00076 
00077         if (IsTransient())
00078                 return true;
00079         else if (_MemoryLocks > 0) {
00080                 _MemoryLocks--;
00081 
00082                 #ifdef C_IMMUTABLEOBJECT_TRACE
00083                 logmsg("bool ImmutableObject::MemoryUnlock() finished, returned true");
00084                 #endif
00085 
00086                 return true;
00087                 }
00088         else {
00089 
00090                 #ifdef C_IMMUTABLEOBJECT_TRACE
00091                 logmsg("bool ImmutableObject::MemoryUnlock() finished, returned false");
00092                 #endif
00093 
00094                 return false;
00095                 };
00096 }
00097 
00099 //Returns the number of memory locks on receiver or zero if it is not locked.
00100 
00101 unsigned int ImmutableObject::MemoryLocked() const
00102 {
00103         #ifdef C_IMMUTABLEOBJECT_TRACE
00104         logmsg("int ImmutableObject::MemoryLocked() invoked and finished");
00105         #endif
00106 
00107         return _MemoryLocks;
00108 }
00109 
00110 bool ImmutableObject::RemoveAllMemoryLocks()
00111 //Removes all memory locks existing in the GEN.LIB
00112 {
00113         #ifdef C_IMMUTABLEOBJECT_TRACE
00114         logmsg("int ImmutableObject::RemoveAllMemoryLocks() invoked and finished");
00115         #endif
00116 
00117         _MemoryLocks = 0;
00118         return true;
00119 }
00120 

Generated on Sun Jul 14 20:51:14 2002 for POLiTe by doxygen1.2.16