| 41 | | /*! \var Int32 AspectStore::_refCount |
|---|
| 42 | | * \brief reference count |
|---|
| 43 | | */ |
|---|
| 44 | | |
|---|
| 45 | | /*-------------------------------------------------------------------------*/ |
|---|
| 46 | | /* Destructor */ |
|---|
| 47 | | |
|---|
| 48 | | inline |
|---|
| 49 | | AspectStore::~AspectStore(void) |
|---|
| 50 | | { |
|---|
| 51 | | } |
|---|
| | 41 | /*-------------------------------------------------------------------------*/ |
|---|
| | 42 | /* Constructors */ |
|---|
| | 43 | |
|---|
| | 44 | inline |
|---|
| | 45 | AspectStore::AspectStore(void) : |
|---|
| | 46 | _vAspects ( ), |
|---|
| | 47 | _refCount (0), |
|---|
| | 48 | _externalRefCount(0) |
|---|
| | 49 | { |
|---|
| | 50 | if(_externalRefCountLock == NULL) |
|---|
| | 51 | { |
|---|
| | 52 | _externalRefCountLock = |
|---|
| | 53 | ThreadManager::the()->getLockPool( |
|---|
| | 54 | "AspectStore::_externalRefCountLock"); |
|---|
| | 55 | |
|---|
| | 56 | if(_externalRefCountLock != NULL) |
|---|
| | 57 | { |
|---|
| | 58 | FINFO(("AspectStore::AspectStore: " |
|---|
| | 59 | "Got AspectStore::_externalRefCountLock\n")); |
|---|
| | 60 | } |
|---|
| | 61 | else |
|---|
| | 62 | { |
|---|
| | 63 | FFATAL(("AspectStore::AspectStore: " |
|---|
| | 64 | "Failed to get AspectStore::_externalRefCountLock\n")); |
|---|
| | 65 | } |
|---|
| | 66 | } |
|---|
| | 67 | |
|---|
| | 68 | OSG::addRef(_externalRefCountLock); |
|---|
| | 69 | } |
|---|
| | 70 | |
|---|
| | 71 | inline |
|---|
| | 72 | AspectStore::AspectStore(const AspectStore &) : |
|---|
| | 73 | _vAspects ( ), |
|---|
| | 74 | _refCount (0), |
|---|
| | 75 | _externalRefCount(0) |
|---|
| | 76 | { |
|---|
| | 77 | FWARNING(("AspectStore::AspectStore(AspectStore const &) called.\n")); |
|---|
| | 78 | } |
|---|
| | 79 | |
|---|
| | 80 | /*-------------------------------------------------------------------------*/ |
|---|
| | 81 | /* Access */ |
|---|
| 99 | | /*-------------------------------------------------------------------------*/ |
|---|
| 100 | | /* Reference Counting */ |
|---|
| 101 | | |
|---|
| 102 | | inline |
|---|
| 103 | | void AspectStore::addRef(void) |
|---|
| 104 | | { |
|---|
| 105 | | _refCount++; |
|---|
| 106 | | } |
|---|
| 107 | | |
|---|
| 108 | | inline |
|---|
| 109 | | void AspectStore::subRef(void) |
|---|
| 110 | | { |
|---|
| 111 | | _refCount--; |
|---|
| 112 | | |
|---|
| 113 | | if(_refCount <= 0) |
|---|
| 114 | | delete this; |
|---|
| 115 | | } |
|---|
| 116 | | |
|---|
| 117 | | inline |
|---|
| 118 | | Int32 AspectStore::getRefCount(void) |
|---|
| 119 | | { |
|---|
| 120 | | return _refCount; |
|---|
| 121 | | } |
|---|
| 122 | | |
|---|
| 123 | | /*-------------------------------------------------------------------------*/ |
|---|
| 124 | | /* Constructors */ |
|---|
| 125 | | |
|---|
| 126 | | inline |
|---|
| 127 | | AspectStore::AspectStore(void) : |
|---|
| 128 | | _refCount(0) |
|---|
| 129 | | { |
|---|
| 130 | | } |
|---|
| 131 | | |
|---|
| 132 | | inline |
|---|
| 133 | | AspectStore::AspectStore(const AspectStore &) : |
|---|
| 134 | | _refCount(0) |
|---|
| 135 | | { |
|---|
| 136 | | } |
|---|
| 137 | | |
|---|
| 138 | | inline |
|---|
| 139 | | void AspectStore::fillOffsetArray(AspectOffsetStore &oStore, |
|---|
| 140 | | FieldContainerPtr pRef ) |
|---|
| | 128 | inline |
|---|
| | 129 | void AspectStore::fillOffsetArray(AspectOffsetStore & oStore, |
|---|
| | 130 | FieldContainer * const pRef ) |
|---|
| 170 | | inline |
|---|
| 171 | | void addRef(const AspectStoreP pObject) |
|---|
| 172 | | { |
|---|
| 173 | | if(pObject != NULL) |
|---|
| 174 | | pObject->addRef(); |
|---|
| 175 | | } |
|---|
| 176 | | |
|---|
| 177 | | inline |
|---|
| 178 | | void subRef(const AspectStoreP pObject) |
|---|
| 179 | | { |
|---|
| 180 | | if(pObject != NULL) |
|---|
| 181 | | pObject->subRef(); |
|---|
| 182 | | } |
|---|
| 183 | | |
|---|
| | 176 | /*-------------------------------------------------------------------------*/ |
|---|
| | 177 | /* Destructor */ |
|---|
| | 178 | |
|---|
| | 179 | inline |
|---|
| | 180 | AspectStore::~AspectStore(void) |
|---|
| | 181 | { |
|---|
| | 182 | OSG::subRef(_externalRefCountLock); |
|---|
| | 183 | } |
|---|
| | 184 | |
|---|
| | 185 | /*-------------------------------------------------------------------------*/ |
|---|
| | 186 | /* Reference Counting */ |
|---|
| | 187 | |
|---|
| | 188 | inline void |
|---|
| | 189 | AspectStore::addReference(void) |
|---|
| | 190 | { |
|---|
| | 191 | ++_refCount; |
|---|
| | 192 | } |
|---|
| | 193 | |
|---|
| | 194 | inline void |
|---|
| | 195 | AspectStore::subReference(void) |
|---|
| | 196 | { |
|---|
| | 197 | --_refCount; |
|---|
| | 198 | |
|---|
| | 199 | if(_refCount <= 0) |
|---|
| | 200 | { |
|---|
| | 201 | delete this; |
|---|
| | 202 | } |
|---|
| | 203 | } |
|---|
| | 204 | |
|---|
| | 205 | inline void |
|---|
| | 206 | AspectStore::acquireExternalReferenceCountLock(void) |
|---|
| | 207 | { |
|---|
| | 208 | _externalRefCountLock->acquire(this); |
|---|
| | 209 | } |
|---|
| | 210 | |
|---|
| | 211 | inline void |
|---|
| | 212 | AspectStore::releaseExternalReferenceCountLock(void) |
|---|
| | 213 | { |
|---|
| | 214 | _externalRefCountLock->release(this); |
|---|
| | 215 | } |
|---|
| | 216 | |
|---|
| | 217 | inline void |
|---|
| | 218 | AspectStore::addExternalReference(void) |
|---|
| | 219 | { |
|---|
| | 220 | ++_externalRefCount; |
|---|
| | 221 | } |
|---|
| | 222 | |
|---|
| | 223 | inline void |
|---|
| | 224 | AspectStore::subExternalReference(void) |
|---|
| | 225 | { |
|---|
| | 226 | --_externalRefCount; |
|---|
| | 227 | } |
|---|
| | 228 | |
|---|
| | 229 | /*-------------------------------------------------------------------------*/ |
|---|
| | 230 | /* Reference Counting Free Functions */ |
|---|
| | 231 | |
|---|
| | 232 | inline void |
|---|
| | 233 | addRef(AspectStore * const objectP) |
|---|
| | 234 | { |
|---|
| | 235 | if(objectP != NULL) |
|---|
| | 236 | objectP->addReference(); |
|---|
| | 237 | } |
|---|
| | 238 | |
|---|
| | 239 | inline void |
|---|
| | 240 | subRef(AspectStore * const objectP) |
|---|
| | 241 | { |
|---|
| | 242 | if(objectP != NULL) |
|---|
| | 243 | objectP->subReference(); |
|---|
| | 244 | } |
|---|
| | 245 | |
|---|
| | 246 | inline Int32 |
|---|
| | 247 | getRefCount(AspectStore * const objectP) |
|---|
| | 248 | { |
|---|
| | 249 | return objectP->getRefCount(); |
|---|
| | 250 | } |
|---|