| 104 | | FieldContainer::subReference(void) |
|---|
| 105 | | { |
|---|
| 106 | | FINFO(("FieldContainer::subReference [%d] [%p] START - [%d %d %d] [%s]\n", |
|---|
| 107 | | this->getId(), this, |
|---|
| 108 | | _pAspectStore->getExternalRefCount(), this->_internalRefCount, this->_weakRefCount, |
|---|
| 109 | | this->getType().getCName())); |
|---|
| 110 | | |
|---|
| 111 | | --_internalRefCount; |
|---|
| 112 | | |
|---|
| 113 | | if((this ->_resolveInProgress == false) && |
|---|
| 114 | | (this ->_internalRefCount <= 0 ) && |
|---|
| 115 | | (_pAspectStore->getExternalRefCount() <= 0 ) ) |
|---|
| 116 | | { |
|---|
| 117 | | FINFO(("FieldContainer::subReference [%d] [%p] E, I - RESOLVE\n", this->getId(), this)); |
|---|
| 118 | | |
|---|
| 119 | | this->_resolveInProgress = true; |
|---|
| | 118 | FieldContainer::subReference(void) |
|---|
| | 119 | { |
|---|
| | 120 | #ifndef OSG_FIELDCONTAINER_DEBUG_SILENT |
|---|
| | 121 | FINFO(("FieldContainer::subReference [%p] [%d] [%s] START - [%d %d]\n", |
|---|
| | 122 | this, this->getId(), this->getType().getCName(), |
|---|
| | 123 | this->_refCount, this->_weakRefCount)); |
|---|
| | 124 | #endif |
|---|
| | 125 | |
|---|
| | 126 | --_refCount; |
|---|
| | 127 | |
|---|
| | 128 | if(_refCount <= 0) |
|---|
| | 129 | { |
|---|
| | 130 | this->registerResolveContainer(); |
|---|
| | 131 | } |
|---|
| | 132 | |
|---|
| | 133 | #ifndef OSG_FIELDCONTAINER_DEBUG_SILENT |
|---|
| | 134 | FINFO(("FieldContainer::subReference [%p] [%d] [%s] STOP - [%d %d]\n", |
|---|
| | 135 | this, this->getId(), this->getType().getCName(), |
|---|
| | 136 | this->_refCount, this->_weakRefCount)); |
|---|
| | 137 | #endif |
|---|
| | 138 | } |
|---|
| | 139 | |
|---|
| | 140 | inline |
|---|
| | 141 | Int32 FieldContainer::getRefCount(void) const |
|---|
| | 142 | { |
|---|
| | 143 | return _refCount; |
|---|
| | 144 | } |
|---|
| | 145 | |
|---|
| | 146 | /*! Increments the \em weak reference count of the container. |
|---|
| | 147 | |
|---|
| | 148 | \warning This function should never be called explicitly by user or library |
|---|
| | 149 | code, all reference count handling should be handled automatically. |
|---|
| | 150 | */ |
|---|
| | 151 | inline void |
|---|
| | 152 | FieldContainer::addWeakReference(void) |
|---|
| | 153 | { |
|---|
| | 154 | #ifndef OSG_FIELDCONTAINER_DEBUG_SILENT |
|---|
| | 155 | FINFO(("FieldContainer::addWeakReference [%p] [%d] [%s] START - [%d %d]\n", |
|---|
| | 156 | this, this->getId(), this->getType().getCName(), |
|---|
| | 157 | this->_refCount, this->_weakRefCount)); |
|---|
| | 158 | #endif |
|---|
| | 159 | |
|---|
| | 160 | ++_weakRefCount; |
|---|
| | 161 | |
|---|
| | 162 | #ifndef OSG_FIELDCONTAINER_DEBUG_SILENT |
|---|
| | 163 | FINFO(("FieldContainer::addWeakReference [%p] [%d] [%s] STOP - [%d %d]\n", |
|---|
| | 164 | this, this->getId(), this->getType().getCName(), |
|---|
| | 165 | this->_refCount, this->_weakRefCount)); |
|---|
| | 166 | #endif |
|---|
| | 167 | } |
|---|
| | 168 | |
|---|
| | 169 | /*! Decrements the \em weak reference count of the container. |
|---|
| | 170 | |
|---|
| | 171 | \warning This function should never be called explicitly by user or library |
|---|
| | 172 | code, all reference count handling should be handled automatically. |
|---|
| | 173 | */ |
|---|
| | 174 | inline void |
|---|
| | 175 | FieldContainer::subWeakReference(void) |
|---|
| | 176 | { |
|---|
| | 177 | #ifndef OSG_FIELDCONTAINER_DEBUG_SILENT |
|---|
| | 178 | FINFO(("FieldContainer::subWeakReference [%p] [%d] [%s] START - [%d %d]\n", |
|---|
| | 179 | this, this->getId(), this->getType().getCName(), |
|---|
| | 180 | this->_refCount, this->_weakRefCount)); |
|---|
| | 181 | #endif |
|---|
| | 182 | |
|---|
| | 183 | --_weakRefCount; |
|---|
| | 184 | |
|---|
| | 185 | if((_refCount <= 0) && (_weakRefCount <= 0)) |
|---|
| | 186 | { |
|---|
| | 187 | this->registerDestroyContainer(); |
|---|
| | 188 | } |
|---|
| | 189 | |
|---|
| | 190 | #ifndef OSG_FIELDCONTAINER_DEBUG_SILENT |
|---|
| | 191 | FINFO(("FieldContainer::subWeakReference [%p] [%d] [%s] STOP - [%d %d]\n", |
|---|
| | 192 | this, this->getId(), this->getType().getCName(), |
|---|
| | 193 | this->_refCount, this->_weakRefCount)); |
|---|
| | 194 | #endif |
|---|
| | 195 | } |
|---|
| | 196 | |
|---|
| | 197 | inline Int32 |
|---|
| | 198 | FieldContainer::getWeakRefCount(void) const |
|---|
| | 199 | { |
|---|
| | 200 | return _weakRefCount; |
|---|
| | 201 | } |
|---|
| | 202 | |
|---|
| | 203 | /*-------------------------------------------------------------------------*/ |
|---|
| | 204 | /* Constructors */ |
|---|
| | 205 | |
|---|
| | 206 | inline |
|---|
| | 207 | FieldContainer::FieldContainer(void) : |
|---|
| | 208 | Inherited ( ), |
|---|
| | 209 | #ifdef OSG_MT_CPTR_ASPECT |
|---|
| | 210 | _pAspectStore (NULL ), |
|---|
| | 211 | #endif |
|---|
| | 212 | _pFieldFlags (NULL ), |
|---|
| | 213 | _mfChangedFunctors( ), |
|---|
| | 214 | _refCount ( 0), |
|---|
| | 215 | _weakRefCount ( 0) |
|---|
| | 216 | { |
|---|
| | 217 | _pFieldFlags = new FieldFlags; |
|---|
| | 218 | } |
|---|
| | 219 | |
|---|
| | 220 | inline |
|---|
| | 221 | FieldContainer::FieldContainer(const FieldContainer &source) : |
|---|
| | 222 | Inherited (source ), |
|---|
| | 223 | #ifdef OSG_MT_CPTR_ASPECT |
|---|
| | 224 | _pAspectStore (NULL ), |
|---|
| | 225 | #endif |
|---|
| | 226 | _pFieldFlags (NULL ), |
|---|
| | 227 | _mfChangedFunctors(source._mfChangedFunctors), |
|---|
| | 228 | _refCount ( 0), |
|---|
| | 229 | _weakRefCount ( 0) |
|---|
| | 230 | { |
|---|
| | 231 | _pFieldFlags = new FieldFlags(*(source._pFieldFlags)); |
|---|
| | 232 | } |
|---|
| | 233 | |
|---|
| | 234 | /*-------------------------------------------------------------------------*/ |
|---|
| | 235 | /* Destructor */ |
|---|
| | 236 | |
|---|
| | 237 | inline |
|---|
| | 238 | FieldContainer::~FieldContainer(void) |
|---|
| | 239 | { |
|---|
| | 240 | if (NULL != _pFieldFlags) |
|---|
| | 241 | { |
|---|
| | 242 | delete _pFieldFlags; |
|---|
| | 243 | _pFieldFlags = NULL; |
|---|
| | 244 | } |
|---|
| | 245 | } |
|---|
| | 246 | |
|---|
| | 247 | inline |
|---|
| | 248 | UInt32 FieldContainer::addChangedFunctor(ChangedFunctor func, |
|---|
| | 249 | std::string createSymbol) |
|---|
| | 250 | { |
|---|
| | 251 | ChangedFunctorCallback oTmp; |
|---|
| | 252 | |
|---|
| | 253 | oTmp._func = func; |
|---|
| | 254 | oTmp._uiId = _mfChangedFunctors.size(); |
|---|
| | 255 | oTmp._createSymbol = createSymbol; |
|---|
| | 256 | |
|---|
| | 257 | _mfChangedFunctors.push_back(oTmp); |
|---|
| | 258 | |
|---|
| | 259 | return oTmp._uiId; |
|---|
| | 260 | } |
|---|
| | 261 | |
|---|
| | 262 | template<class FunctorT> inline |
|---|
| | 263 | void FieldContainer::subChangedFunctor(FunctorT func) |
|---|
| | 264 | { |
|---|
| | 265 | MFChangedFunctorCallback::iterator cfIt = _mfChangedFunctors.begin(); |
|---|
| | 266 | MFChangedFunctorCallback::const_iterator cfEnd= _mfChangedFunctors.end(); |
|---|
| | 267 | |
|---|
| | 268 | while(cfIt != cfEnd) |
|---|
| | 269 | { |
|---|
| | 270 | if(cfIt->_func == func) |
|---|
| | 271 | break; |
|---|
| | 272 | |
|---|
| | 273 | ++cfIt; |
|---|
| | 274 | } |
|---|
| | 275 | |
|---|
| | 276 | if(cfIt != cfEnd) |
|---|
| | 277 | _mfChangedFunctors.erase(cfIt); |
|---|
| | 278 | } |
|---|
| | 279 | |
|---|
| | 280 | inline |
|---|
| | 281 | void FieldContainer::subChangedFunctor(UInt32 uiId) |
|---|
| | 282 | { |
|---|
| | 283 | MFChangedFunctorCallback::iterator cfIt = _mfChangedFunctors.begin(); |
|---|
| | 284 | MFChangedFunctorCallback::const_iterator cfEnd= _mfChangedFunctors.end(); |
|---|
| | 285 | |
|---|
| | 286 | while(cfIt != cfEnd) |
|---|
| | 287 | { |
|---|
| | 288 | if(cfIt->_uiId == uiId) |
|---|
| | 289 | break; |
|---|
| | 290 | |
|---|
| | 291 | ++cfIt; |
|---|
| | 292 | } |
|---|
| | 293 | |
|---|
| | 294 | if(cfIt != cfEnd) |
|---|
| | 295 | _mfChangedFunctors.erase(cfIt); |
|---|
| | 296 | } |
|---|
| | 297 | |
|---|
| | 298 | inline |
|---|
| | 299 | void FieldContainer::clearChangedFunctors(void) |
|---|
| | 300 | { |
|---|
| | 301 | _mfChangedFunctors.clear(); |
|---|
| | 302 | } |
|---|
| | 303 | |
|---|
| | 304 | inline |
|---|
| | 305 | const FieldFlags *FieldContainer::getFieldFlags(void) |
|---|
| | 306 | { |
|---|
| | 307 | return _pFieldFlags; |
|---|
| | 308 | } |
|---|
| | 309 | |
|---|
| | 310 | #ifdef OSG_MT_CPTR_ASPECT |
|---|
| | 311 | inline |
|---|
| | 312 | FieldContainerPtr FieldContainer::getAspectPtr(UInt32 uiAspect) const |
|---|
| | 313 | { |
|---|
| | 314 | if(_pAspectStore == NULL) |
|---|
| | 315 | return NullFC; |
|---|
| | 316 | |
|---|
| | 317 | return _pAspectStore->getPtr(uiAspect); |
|---|
| | 318 | } |
|---|
| | 319 | |
|---|
| | 320 | inline |
|---|
| | 321 | void FieldContainer::setupAspectStore(void) |
|---|
| | 322 | { |
|---|
| | 323 | _pAspectStore = new AspectStore; |
|---|
| | 324 | |
|---|
| | 325 | OSG::addRef(_pAspectStore); |
|---|
| | 326 | |
|---|
| | 327 | _pAspectStore->setAspectPtr(this, Thread::getCurrentAspect()); |
|---|
| | 328 | } |
|---|
| | 329 | |
|---|
| | 330 | inline |
|---|
| | 331 | void FieldContainer::setupAspectStore(AspectStore *pStore) |
|---|
| | 332 | { |
|---|
| | 333 | _pAspectStore = pStore; |
|---|
| | 334 | |
|---|
| | 335 | OSG::addRef(_pAspectStore); |
|---|
| | 336 | |
|---|
| | 337 | _pAspectStore->setAspectPtr(this, Thread::getCurrentAspect()); |
|---|
| | 338 | } |
|---|
| | 339 | |
|---|
| | 340 | inline |
|---|
| | 341 | AspectStoreP FieldContainer::getAspectStore(void) const |
|---|
| | 342 | { |
|---|
| | 343 | return _pAspectStore; |
|---|
| | 344 | } |
|---|
| | 345 | |
|---|
| | 346 | #endif |
|---|
| | 347 | |
|---|
| | 348 | inline void |
|---|
| | 349 | FieldContainer::handleResolve(void) |
|---|
| | 350 | { |
|---|
| | 351 | #ifndef OSG_FIELDCONTAINER_DEBUG_SILENT |
|---|
| | 352 | FINFO(("FieldContainer::handleResolve [%p] [%d] [%s] - [%d %d]\n", |
|---|
| | 353 | this, this->getId(), this->getType().getCName(), |
|---|
| | 354 | this->_refCount, this->_weakRefCount)); |
|---|
| | 355 | #endif |
|---|
| | 356 | |
|---|
| | 357 | if(this->_refCount <= 0) |
|---|
| | 358 | { |
|---|
| 139 | | FieldContainer::subReferenceLocalVar(void) |
|---|
| 140 | | { |
|---|
| 141 | | FWARNING(("FieldContainer::subReferneceLocalVar: NI.\n")); |
|---|
| 142 | | } |
|---|
| 143 | | |
|---|
| 144 | | inline void |
|---|
| 145 | | FieldContainer::subReferenceUnresolved(void) |
|---|
| 146 | | { |
|---|
| 147 | | FWARNING(("FieldContainer::subReferenceUnresolved: NI.\n")); |
|---|
| 148 | | } |
|---|
| 149 | | |
|---|
| 150 | | inline |
|---|
| 151 | | Int32 FieldContainer::getRefCount(void) const |
|---|
| 152 | | { |
|---|
| 153 | | return _internalRefCount; |
|---|
| 154 | | } |
|---|
| 155 | | |
|---|
| 156 | | /*! Increments the \em external reference count of the container. |
|---|
| 157 | | |
|---|
| 158 | | \warning This function should never be called by library code and by user |
|---|
| 159 | | code only if you know what you are doing. |
|---|
| 160 | | */ |
|---|
| 161 | | inline void |
|---|
| 162 | | FieldContainer::addExternalReference(void) |
|---|
| 163 | | { |
|---|
| 164 | | _pAspectStore->acquireExternalReferenceCountLock(); |
|---|
| 165 | | |
|---|
| 166 | | _pAspectStore->addExternalReference(); |
|---|
| 167 | | |
|---|
| 168 | | Thread::getCurrentChangeList()->addAddExternalRef(Inherited::getId()); |
|---|
| 169 | | |
|---|
| 170 | | _pAspectStore->releaseExternalReferenceCountLock(); |
|---|
| 171 | | } |
|---|
| 172 | | |
|---|
| 173 | | /*! Decrements the \em external reference count of the container. |
|---|
| 174 | | |
|---|
| 175 | | \warning This function should never be called by library code and by user |
|---|
| 176 | | code only if you know what you are doing. |
|---|
| 177 | | */ |
|---|
| 178 | | inline void |
|---|
| 179 | | FieldContainer::subExternalReference(void) |
|---|
| 180 | | { |
|---|
| 181 | | FINFO(("FieldContainer::subExternalReference [%d] [%p] START - [%d %d %d] [%s]\n", |
|---|
| 182 | | this->getId(), this, |
|---|
| 183 | | _pAspectStore->getExternalRefCount(), this->_internalRefCount, this->_weakRefCount, |
|---|
| 184 | | this->getType().getCName())); |
|---|
| 185 | | |
|---|
| 186 | | _pAspectStore->acquireExternalReferenceCountLock(); |
|---|
| 187 | | |
|---|
| 188 | | _pAspectStore->subExternalReference(); |
|---|
| 189 | | |
|---|
| 190 | | Thread::getCurrentChangeList()->addSubExternalRef(Inherited::getId()); |
|---|
| 191 | | |
|---|
| 192 | | if(_pAspectStore->getExternalRefCount() <= 0) |
|---|
| 193 | | { |
|---|
| 194 | | FINFO(("FieldContainer::subExternalReference [%d] [%p] E\n", this->getId(), this)); |
|---|
| 195 | | |
|---|
| 196 | | _pAspectStore->releaseExternalReferenceCountLock(); |
|---|
| | 369 | FieldContainer::handleDestroyAspect(void) |
|---|
| | 370 | { |
|---|
| | 371 | #ifndef OSG_FIELDCONTAINER_DEBUG_SILENT |
|---|
| | 372 | FINFO(("FieldContainer::handleDestroyAspect [%p] [%d] [%s] - [%d %d]\n", |
|---|
| | 373 | this, this->getId(), this->getType().getCName(), |
|---|
| | 374 | this->_refCount, this->_weakRefCount)); |
|---|
| | 375 | #endif |
|---|
| 198 | | bool lastAspect = false; |
|---|
| 199 | | |
|---|
| 200 | | for(UInt32 i = 0; i < _pAspectStore->getNumAspects(); ++i) |
|---|
| 201 | | { |
|---|
| 202 | | FieldContainerPtr pAspect = _pAspectStore->getPtr(i); |
|---|
| 203 | | |
|---|
| 204 | | if((pAspect != NullFC) && |
|---|
| 205 | | (pAspect->_resolveInProgress == false ) && |
|---|
| 206 | | (pAspect->_internalRefCount <= 0 ) ) |
|---|
| 207 | | { |
|---|
| 208 | | FINFO(("FieldContainer::subExternalReference [%p] E, I - RESOLVE\n", pAspect)); |
|---|
| 209 | | |
|---|
| 210 | | pAspect->_resolveInProgress = true; |
|---|
| 211 | | pAspect->resolveLinks(); |
|---|
| 212 | | |
|---|
| 213 | | if(pAspect->_weakRefCount <= 0) |
|---|
| 214 | | { |
|---|
| 215 | | FINFO(("FieldContainer::subExternalReference [%p] E, I, W - RESOLVE, DESTROY\n", pAspect)); |
|---|
| 216 | | |
|---|
| 217 | | lastAspect = pAspect->destroyAspect(pAspect->getId(), i); |
|---|
| 218 | | } |
|---|
| 219 | | else |
|---|
| 220 | | { |
|---|
| 221 | | pAspect->_resolveInProgress = false; |
|---|
| 222 | | } |
|---|
| 223 | | } |
|---|
| 224 | | |
|---|
| 225 | | if(lastAspect == true) |
|---|
| 226 | | break; |
|---|
| 227 | | } |
|---|
| 228 | | } |
|---|
| 229 | | else |
|---|
| 230 | | { |
|---|
| 231 | | _pAspectStore->releaseExternalReferenceCountLock(); |
|---|
| 232 | | } |
|---|
| 233 | | |
|---|
| 234 | | FINFO(("FieldContainer::subExternalReference [%d] [%p] STOP\n", this->getId(), this)); |
|---|
| 235 | | } |
|---|
| 236 | | |
|---|
| 237 | | inline Int32 |
|---|
| 238 | | FieldContainer::getExternalRefCount(void) const |
|---|
| 239 | | { |
|---|
| 240 | | return _pAspectStore->getExternalRefCount(); |
|---|
| 241 | | } |
|---|
| 242 | | |
|---|
| 243 | | |
|---|
| 244 | | /*! Increments the \em weak reference count of the container. |
|---|
| 245 | | |
|---|
| 246 | | \warning This function should never be called by user or library code |
|---|
| 247 | | explicitly, all reference count handling should be handled automatically. |
|---|
| 248 | | */ |
|---|
| 249 | | inline void |
|---|
| 250 | | FieldContainer::addWeakReference(void) |
|---|
| 251 | | { |
|---|
| 252 | | ++_weakRefCount; |
|---|
| 253 | | } |
|---|
| 254 | | |
|---|
| 255 | | /*! Decrements the \em weak reference count of the container. |
|---|
| 256 | | |
|---|
| 257 | | \warning This function should never be called by user or library code |
|---|
| 258 | | explicitly, all reference count handling should be handled automatically. |
|---|
| 259 | | */ |
|---|
| 260 | | inline void |
|---|
| 261 | | FieldContainer::subWeakReference(void) |
|---|
| 262 | | { |
|---|
| 263 | | FINFO(("FieldContainer::subWeakReference [%d] [%p] START - [%d %d %d] [%s]\n", |
|---|
| 264 | | this->getId(), this, |
|---|
| 265 | | _pAspectStore->getExternalRefCount(), this->_internalRefCount, this->_weakRefCount, |
|---|
| 266 | | this->getType().getCName())); |
|---|
| 267 | | |
|---|
| 268 | | --_weakRefCount; |
|---|
| 269 | | |
|---|
| 270 | | if((this ->_resolveInProgress == false) && |
|---|
| 271 | | (this ->_internalRefCount <= 0 ) && |
|---|
| 272 | | (this ->_weakRefCount <= 0 ) && |
|---|
| 273 | | (_pAspectStore->getExternalRefCount() <= 0 ) ) |
|---|
| 274 | | { |
|---|
| 275 | | FINFO(("FieldContainer::subWeakReference [%d] [%p] E, I, W - DESTROY\n", this->getId(), this)); |
|---|
| 276 | | |
|---|
| | 377 | if((this->_refCount <= 0) && (this->_weakRefCount <= 0)) |
|---|
| | 378 | { |
|---|
| 279 | | |
|---|
| 280 | | FINFO(("FieldContainer::subWeakReference [%d] [%p] STOP\n", this->getId(), this)); |
|---|
| 281 | | } |
|---|
| 282 | | |
|---|
| 283 | | inline Int32 |
|---|
| 284 | | FieldContainer::getWeakRefCount(void) const |
|---|
| 285 | | { |
|---|
| 286 | | return _weakRefCount; |
|---|
| 287 | | } |
|---|
| 288 | | |
|---|
| 289 | | /*-------------------------------------------------------------------------*/ |
|---|
| 290 | | /* Constructors */ |
|---|
| 291 | | |
|---|
| 292 | | inline |
|---|
| 293 | | FieldContainer::FieldContainer(void) : |
|---|
| 294 | | Inherited ( ), |
|---|
| 295 | | #ifdef OSG_MT_CPTR_ASPECT |
|---|
| 296 | | _pAspectStore (NULL ), |
|---|
| 297 | | #endif |
|---|
| 298 | | _pFieldFlags (NULL ), |
|---|
| 299 | | _mfChangedFunctors( ), |
|---|
| 300 | | _internalRefCount ( 0), |
|---|
| 301 | | _weakRefCount ( 0), |
|---|
| 302 | | _resolveInProgress(false) |
|---|
| 303 | | { |
|---|
| 304 | | _pFieldFlags = new FieldFlags; |
|---|
| 305 | | } |
|---|
| 306 | | |
|---|
| 307 | | inline |
|---|
| 308 | | FieldContainer::FieldContainer(const FieldContainer &source) : |
|---|
| 309 | | Inherited (source ), |
|---|
| 310 | | #ifdef OSG_MT_CPTR_ASPECT |
|---|
| 311 | | _pAspectStore (NULL ), |
|---|
| 312 | | #endif |
|---|
| 313 | | _pFieldFlags (NULL ), |
|---|
| 314 | | _mfChangedFunctors(source._mfChangedFunctors), |
|---|
| 315 | | _internalRefCount ( 0), |
|---|
| 316 | | _weakRefCount ( 0), |
|---|
| 317 | | _resolveInProgress(false ) |
|---|
| 318 | | { |
|---|
| 319 | | _pFieldFlags = new FieldFlags(*(source._pFieldFlags)); |
|---|
| 320 | | } |
|---|
| 321 | | |
|---|
| 322 | | /*-------------------------------------------------------------------------*/ |
|---|
| 323 | | /* Destructor */ |
|---|
| 324 | | |
|---|
| 325 | | inline |
|---|
| 326 | | FieldContainer::~FieldContainer(void) |
|---|
| 327 | | { |
|---|
| 328 | | if (NULL != _pFieldFlags) |
|---|
| 329 | | { |
|---|
| 330 | | delete _pFieldFlags; |
|---|
| 331 | | _pFieldFlags = NULL; |
|---|
| 332 | | } |
|---|
| 333 | | } |
|---|
| 334 | | |
|---|
| 335 | | inline |
|---|
| 336 | | UInt32 FieldContainer::addChangedFunctor(ChangedFunctor func, |
|---|
| 337 | | std::string createSymbol) |
|---|
| 338 | | { |
|---|
| 339 | | ChangedFunctorCallback oTmp; |
|---|
| 340 | | |
|---|
| 341 | | oTmp._func = func; |
|---|
| 342 | | oTmp._uiId = _mfChangedFunctors.size(); |
|---|
| 343 | | oTmp._createSymbol = createSymbol; |
|---|
| 344 | | |
|---|
| 345 | | _mfChangedFunctors.push_back(oTmp); |
|---|
| 346 | | |
|---|
| 347 | | return oTmp._uiId; |
|---|
| 348 | | } |
|---|
| 349 | | |
|---|
| 350 | | template<class FunctorT> inline |
|---|
| 351 | | void FieldContainer::subChangedFunctor(FunctorT func) |
|---|
| 352 | | { |
|---|
| 353 | | MFChangedFunctorCallback::iterator cfIt = _mfChangedFunctors.begin(); |
|---|
| 354 | | MFChangedFunctorCallback::const_iterator cfEnd= _mfChangedFunctors.end(); |
|---|
| 355 | | |
|---|
| 356 | | while(cfIt != cfEnd) |
|---|
| 357 | | { |
|---|
| 358 | | if(cfIt->_func == func) |
|---|
| 359 | | break; |
|---|
| 360 | | |
|---|
| 361 | | ++cfIt; |
|---|
| 362 | | } |
|---|
| 363 | | |
|---|
| 364 | | if(cfIt != cfEnd) |
|---|
| 365 | | _mfChangedFunctors.erase(cfIt); |
|---|
| 366 | | } |
|---|
| 367 | | |
|---|
| 368 | | inline |
|---|
| 369 | | void FieldContainer::subChangedFunctor(UInt32 uiId) |
|---|
| 370 | | { |
|---|
| 371 | | MFChangedFunctorCallback::iterator cfIt = _mfChangedFunctors.begin(); |
|---|
| 372 | | MFChangedFunctorCallback::const_iterator cfEnd= _mfChangedFunctors.end(); |
|---|
| 373 | | |
|---|
| 374 | | while(cfIt != cfEnd) |
|---|
| 375 | | { |
|---|
| 376 | | if(cfIt->_uiId == uiId) |
|---|
| 377 | | break; |
|---|
| 378 | | |
|---|
| 379 | | ++cfIt; |
|---|
| 380 | | } |
|---|
| 381 | | |
|---|
| 382 | | if(cfIt != cfEnd) |
|---|
| 383 | | _mfChangedFunctors.erase(cfIt); |
|---|
| 384 | | } |
|---|
| 385 | | |
|---|
| 386 | | inline |
|---|
| 387 | | void FieldContainer::clearChangedFunctors(void) |
|---|
| 388 | | { |
|---|
| 389 | | _mfChangedFunctors.clear(); |
|---|
| 390 | | } |
|---|
| 391 | | |
|---|
| 392 | | inline |
|---|
| 393 | | const FieldFlags *FieldContainer::getFieldFlags(void) |
|---|
| 394 | | { |
|---|
| 395 | | return _pFieldFlags; |
|---|
| 396 | | } |
|---|
| 397 | | |
|---|
| 398 | | #ifdef OSG_MT_CPTR_ASPECT |
|---|
| 399 | | inline |
|---|
| 400 | | FieldContainerPtr FieldContainer::getAspectPtr(UInt32 uiAspect) const |
|---|
| 401 | | { |
|---|
| 402 | | if(_pAspectStore == NULL) |
|---|
| 403 | | return NullFC; |
|---|
| 404 | | |
|---|
| 405 | | return _pAspectStore->getPtr(uiAspect); |
|---|
| 406 | | } |
|---|
| 407 | | |
|---|
| 408 | | inline |
|---|
| 409 | | void FieldContainer::setupAspectStore(void) |
|---|
| 410 | | { |
|---|
| 411 | | _pAspectStore = new AspectStore; |
|---|
| 412 | | |
|---|
| 413 | | OSG::addRef(_pAspectStore); |
|---|
| 414 | | |
|---|
| 415 | | _pAspectStore->setAspectPtr(this, Thread::getCurrentAspect()); |
|---|
| 416 | | } |
|---|
| 417 | | |
|---|
| 418 | | inline |
|---|
| 419 | | void FieldContainer::setupAspectStore(AspectStore *pStore) |
|---|
| 420 | | { |
|---|
| 421 | | _pAspectStore = pStore; |
|---|
| 422 | | |
|---|
| 423 | | OSG::addRef(_pAspectStore); |
|---|
| 424 | | |
|---|
| 425 | | _pAspectStore->setAspectPtr(this, Thread::getCurrentAspect()); |
|---|
| 426 | | } |
|---|
| 427 | | |
|---|
| 428 | | inline |
|---|
| 429 | | AspectStoreP FieldContainer::getAspectStore(void) const |
|---|
| 430 | | { |
|---|
| 431 | | return _pAspectStore; |
|---|
| 432 | | } |
|---|
| 433 | | |
|---|
| 434 | | #endif |
|---|
| | 381 | } |
|---|