00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include <cImmutableObject.h>
00017
00018 PROTOTYPE(ImmutableObject);
00019
00020
00022
00023
00024
00025 ImmutableObject::~ImmutableObject()
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
00040
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
00068
00069
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
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
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