Changeset 1181
- Timestamp:
- 04/20/08 10:27:32 (3 weeks ago)
- Files:
-
- trunk/Source/System/FieldContainer/Base/OSGFieldContainer.inl (modified) (3 diffs)
- trunk/Source/System/FieldContainer/Base/OSGRefCountPolicies.h (modified) (2 diffs)
- trunk/Source/System/FieldContainer/Base/OSGRefCountPtr.h (modified) (1 diff)
- trunk/Source/System/FieldContainer/Base/OSGRefCountPtr.inl (modified) (3 diffs)
- trunk/Source/System/FieldContainer/Base/OSGTransitPtr.h (modified) (3 diffs)
- trunk/Source/System/FieldContainer/Base/OSGTransitPtr.inl (modified) (1 diff)
- trunk/Source/System/NodeCores/Groups/DynamicStateGenerators/testCubemapGenerator.cpp (modified) (8 diffs)
- trunk/Source/System/NodeCores/Groups/Misc/OSGVisitSubTree.fcd (modified) (1 diff)
- trunk/Source/System/NodeCores/Groups/Misc/OSGVisitSubTreeBase.cpp (modified) (5 diffs)
- trunk/Source/System/NodeCores/Groups/Misc/OSGVisitSubTreeBase.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Source/System/FieldContainer/Base/OSGFieldContainer.inl
r1174 r1181 113 113 void FieldContainer::addReferenceUnrecordedX(void) 114 114 { 115 #ifndef OSG_FIELDCONTAINER_DEBUG_SILENT 116 FINFO(("FieldContainer::addReferenceUnrec [%p] [%d] [%s] START - [%d %d]\n", 117 this, 118 this->getId(), 119 this->getType().getCName(), 120 this->_iRefCount, 121 this->_iWeakRefCount)); 122 #endif 123 115 124 ++_iRefCount; 125 126 #ifndef OSG_FIELDCONTAINER_DEBUG_SILENT 127 FINFO(("FieldContainer::addReferenceUnrec [%p] [%d] [%s] STOP - [%d %d]\n", 128 this, 129 this->getId(), 130 this->getType().getCName(), 131 this->_iRefCount, 132 this->_iWeakRefCount)); 133 #endif 116 134 117 135 // Thread::getCurrentChangeList()->addAddRefd(Inherited::getId()); … … 129 147 #endif 130 148 131 --_iRefCount; 132 133 #ifndef OSG_FIELDCONTAINER_DEBUG_SILENT 134 FINFO(("FieldContainer::subReference [%p] [%d] [%s] STOP - [%d %d]\n", 135 this, 136 this->getId(), 137 this->getType().getCName(), 138 this->_iRefCount, 139 this->_iWeakRefCount)); 140 #endif 141 142 if(_iRefCount <= 0 && _iWeakRefCount <= 0) 149 if(_iRefCount <= 1) 143 150 { 144 151 Thread::getCurrentChangeList()->incSubRefLevel(); … … 150 157 Thread::getCurrentChangeList()->addSubRefd(Inherited::getId()); 151 158 152 #ifdef OSG_MT_CPTR_ASPECT 153 this->onDestroyAspect(Inherited::getId(), Thread::getCurrentAspect()); 154 155 _pAspectStore->removePtrForAspect(Thread::getCurrentAspect()); 156 157 if(_pAspectStore->getRefCount() == 1) 159 if(_iWeakRefCount <= 0) 158 160 { 159 this->deregister(Inherited::getId()); 160 this->onDestroy (Inherited::getId()); 161 #ifdef OSG_MT_CPTR_ASPECT 162 this->onDestroyAspect(Inherited::getId(), 163 Thread::getCurrentAspect()); 164 165 _pAspectStore->removePtrForAspect(Thread::getCurrentAspect()); 166 167 if(_pAspectStore->getRefCount() == 1) 168 { 169 this->deregister(Inherited::getId()); 170 this->onDestroy (Inherited::getId()); 171 } 172 173 OSG::subRef(_pAspectStore); 174 #else 175 this->deregister (Inherited::getId() ); 176 this->onDestroyAspect(Inherited::getId(), 0); 177 this->onDestroy (Inherited::getId() ); 178 #endif 179 180 delete this; 161 181 } 162 163 OSG::subRef(_pAspectStore); 182 else 183 { 184 --_iRefCount; 185 186 #ifndef OSG_FIELDCONTAINER_DEBUG_SILENT 187 FINFO( 188 ("FieldContainer::subReference [%p] [%d] [%s] STOP A [%d %d]\n", 189 this, 190 this->getId(), 191 this->getType().getCName(), 192 this->_iRefCount, 193 this->_iWeakRefCount)); 194 #endif 195 } 196 } 197 else 198 { 199 --_iRefCount; 200 201 #ifndef OSG_FIELDCONTAINER_DEBUG_SILENT 202 FINFO( 203 ("FieldContainer::subReference [%p] [%d] [%s] STOP B [%d %d]\n", 204 this, 205 this->getId(), 206 this->getType().getCName(), 207 this->_iRefCount, 208 this->_iWeakRefCount)); 209 #endif 210 211 Thread::getCurrentChangeList()->addSubRefd(Inherited::getId()); 212 } 213 214 } 215 216 inline 217 void FieldContainer::subReferenceUnrecordedX(void) 218 { 219 #ifndef OSG_FIELDCONTAINER_DEBUG_SILENT 220 FINFO(("FieldContainer::subReferenceUnrec [%p] [%d] [%s] START - [%d %d]\n", 221 this, 222 this->getId(), 223 this->getType().getCName(), 224 this->_iRefCount, 225 this->_iWeakRefCount)); 226 #endif 227 228 if(_iRefCount <= 1) 229 { 230 // Thread::getCurrentChangeList()->incSubRefLevel(); 231 232 this->resolveLinks(); 233 234 // Thread::getCurrentChangeList()->decSubRefLevel(); 235 236 // Thread::getCurrentChangeList()->addSubRefd(Inherited::getId()); 237 238 if(_iWeakRefCount <= 0) 239 { 240 #ifdef OSG_MT_CPTR_ASPECT 241 this->onDestroyAspect(Inherited::getId(), 242 Thread::getCurrentAspect()); 243 244 _pAspectStore->removePtrForAspect(Thread::getCurrentAspect()); 245 246 if(_pAspectStore->getRefCount() == 1) 247 { 248 this->deregister(Inherited::getId()); 249 this->onDestroy (Inherited::getId()); 250 } 251 252 OSG::subRef(_pAspectStore); 164 253 #else 165 this->deregister (Inherited::getId() ); 166 this->onDestroyAspect(Inherited::getId(), 0); 167 this->onDestroy (Inherited::getId() ); 168 #endif 169 170 delete this; 254 this->deregister (Inherited::getId() ); 255 this->onDestroyAspect(Inherited::getId(), 0); 256 this->onDestroy (Inherited::getId() ); 257 #endif 258 259 delete this; 260 } 261 else 262 { 263 --_iRefCount; 264 265 #ifndef OSG_FIELDCONTAINER_DEBUG_SILENT 266 FINFO( 267 ("FieldContainer::subReferenceUnrec [%p] [%d] [%s] " 268 "STOP A [%d %d]\n", 269 this, 270 this->getId(), 271 this->getType().getCName(), 272 this->_iRefCount, 273 this->_iWeakRefCount)); 274 #endif 275 } 171 276 } 172 277 else 173 278 { 174 Thread::getCurrentChangeList()->addSubRefd(Inherited::getId()); 175 } 176 177 } 178 179 inline 180 void FieldContainer::subReferenceUnrecordedX(void) 181 { 182 #ifndef OSG_FIELDCONTAINER_DEBUG_SILENT 183 FINFO(("FieldContainer::subReference [%p] [%d] [%s] START - [%d %d]\n", 184 this, 185 this->getId(), 186 this->getType().getCName(), 187 this->_iRefCount, 188 this->_iWeakRefCount)); 189 #endif 190 191 --_iRefCount; 192 193 #ifndef OSG_FIELDCONTAINER_DEBUG_SILENT 194 FINFO(("FieldContainer::subReference [%p] [%d] [%s] STOP - [%d %d]\n", 195 this, 196 this->getId(), 197 this->getType().getCName(), 198 this->_iRefCount, 199 this->_iWeakRefCount)); 200 #endif 201 202 if(_iRefCount <= 0 && _iWeakRefCount <= 0) 203 { 204 // Thread::getCurrentChangeList()->incSubRefLevel(); 205 206 this->resolveLinks(); 207 208 // Thread::getCurrentChangeList()->decSubRefLevel(); 209 210 // Thread::getCurrentChangeList()->addSubRefd(Inherited::getId()); 211 212 #ifdef OSG_MT_CPTR_ASPECT 213 this->onDestroyAspect(Inherited::getId(), Thread::getCurrentAspect()); 214 215 _pAspectStore->removePtrForAspect(Thread::getCurrentAspect()); 216 217 if(_pAspectStore->getRefCount() == 1) 218 { 219 this->deregister(Inherited::getId()); 220 this->onDestroy (Inherited::getId()); 221 } 222 223 OSG::subRef(_pAspectStore); 224 #else 225 this->deregister (Inherited::getId() ); 226 this->onDestroyAspect(Inherited::getId(), 0); 227 this->onDestroy (Inherited::getId() ); 228 #endif 229 230 delete this; 231 } 232 else 233 { 279 --_iRefCount; 280 281 #ifndef OSG_FIELDCONTAINER_DEBUG_SILENT 282 FINFO(("FieldContainer::subReferenceUnrec [%p] [%d] [%s] " 283 "STOP - [%d %d]\n", 284 this, 285 this->getId(), 286 this->getType().getCName(), 287 this->_iRefCount, 288 this->_iWeakRefCount)); 289 #endif 234 290 // Thread::getCurrentChangeList()->addSubRefd(Inherited::getId()); 235 291 } trunk/Source/System/FieldContainer/Base/OSGRefCountPolicies.h
r1177 r1181 87 87 static void convertTransitPtr(T *&pOut, U *&pIn) 88 88 { 89 RecordedRefCountPolicy::subRef(pOut); 90 89 91 pOut = pIn; 90 92 pIn = NULL; … … 150 152 static void convertTransitPtr(T *&pOut, U *&pIn) 151 153 { 154 UnrecordedRefCountPolicy::subRef(pOut); 155 152 156 pOut = pIn; 153 157 pIn = NULL; trunk/Source/System/FieldContainer/Base/OSGRefCountPtr.h
r1177 r1181 181 181 template <class TargetObjectT, class SourceObjectT, class RP> inline 182 182 RefCountPtr<TargetObjectT, RP> dynamic_pointer_cast( 183 RefCountPtr<SourceObjectT, RP> const &source) 184 { 185 TargetObjectT *pRet = dynamic_cast<TargetObjectT *>(source.get()); 186 187 return RefCountPtr<TargetObjectT, RP>(pRet); 188 } 183 RefCountPtr<SourceObjectT, RP> const &source); 184 185 template <class TargetObjectT, class SourceObjectT, class RP> inline 186 RefCountPtr<TargetObjectT, RP> static_pointer_cast( 187 RefCountPtr<SourceObjectT, RP> const &source); 189 188 190 189 OSG_END_NAMESPACE trunk/Source/System/FieldContainer/Base/OSGRefCountPtr.inl
r1177 r1181 69 69 template <class OtherObjectT > inline 70 70 RefCountPtr<ObjectT, RefCountPolicyT>::RefCountPtr( 71 TransitPtr<OtherObjectT> const &other) 71 TransitPtr<OtherObjectT> const &other) : 72 73 _pObj(NULL) 72 74 { 73 75 RefCountPolicy::convertTransitPtr(_pObj, other._pObj); … … 78 80 class RefCountPolicyT> inline 79 81 RefCountPtr<ObjectT, RefCountPolicyT>::RefCountPtr( 80 ObjectTransitPtr const &other) 82 ObjectTransitPtr const &other) : 83 84 _pObj(NULL) 81 85 { 82 86 RefCountPolicy::convertTransitPtr(_pObj, other._pObj); … … 195 199 } 196 200 201 202 template <class TargetObjectT, class SourceObjectT, class RP> inline 203 RefCountPtr<TargetObjectT, RP> dynamic_pointer_cast( 204 RefCountPtr<SourceObjectT, RP> const &source) 205 { 206 TargetObjectT *pRet = dynamic_cast<TargetObjectT *>(source.get()); 207 208 return RefCountPtr<TargetObjectT, RP>(pRet); 209 } 210 211 template <class TargetObjectT, class SourceObjectT, class RP> inline 212 RefCountPtr<TargetObjectT, RP> static_pointer_cast( 213 RefCountPtr<SourceObjectT, RP> const &source) 214 { 215 TargetObjectT *pRet = static_cast<TargetObjectT *>(source.get()); 216 217 return RefCountPtr<TargetObjectT, RP>(pRet); 218 } 219 197 220 OSG_END_NAMESPACE trunk/Source/System/FieldContainer/Base/OSGTransitPtr.h
r1177 r1181 59 59 class RefCountPolicyT> 60 60 class RefCountPtr; 61 62 template <class TargetObjectT, class SourceObjectT> inline 63 TransitPtr<TargetObjectT> dynamic_pointer_cast( 64 TransitPtr<SourceObjectT> const &source); 65 66 template <class TargetObjectT, class SourceObjectT> inline 67 TransitPtr<TargetObjectT> static_pointer_cast( 68 TransitPtr<SourceObjectT> const &source); 61 69 62 70 template <class ObjectT> … … 144 152 #endif 145 153 154 /*! \} */ 155 /*========================= PROTECTED ===============================*/ 156 157 protected: 158 159 /*========================== PRIVATE ================================*/ 160 161 /*---------------------------------------------------------------------*/ 162 /*! \name Member */ 163 /*! \{ */ 164 165 mutable ObjectPtr _pObj; 166 167 /*! \} */ 168 /*---------------------------------------------------------------------*/ 169 /*! \name Access */ 170 /*! \{ */ 171 146 172 template<class SourceObjectT> 147 void dynamic_cast_set(TransitPtr<SourceObjectT> const &source) 148 { 149 ObjectPtr pObj = dynamic_cast<ObjectPtr>(source._pObj); 150 151 if(pObj != NULL) 152 { 153 _pObj = pObj; 154 155 source._pObj = NULL; 156 } 157 } 158 159 /*! \} */ 160 /*========================= PROTECTED ===============================*/ 161 162 protected: 163 164 /*========================== PRIVATE ================================*/ 165 166 /*---------------------------------------------------------------------*/ 167 /*! \name Member */ 168 /*! \{ */ 169 170 mutable ObjectPtr _pObj; 171 173 void dynamic_cast_set(TransitPtr<SourceObjectT> const &source); 174 175 template<class SourceObjectT> 176 void static_cast_set (TransitPtr<SourceObjectT> const &source); 177 172 178 /*! \} */ 173 179 /*---------------------------------------------------------------------*/ … … 178 184 /*! \name Internal Helpers */ 179 185 /*! \{ */ 186 187 template <class TargetObjectT, class SourceObjectT> 188 friend TransitPtr<TargetObjectT> dynamic_pointer_cast( 189 TransitPtr<SourceObjectT> const &source); 190 191 template <class TargetObjectT, class SourceObjectT> 192 friend TransitPtr<TargetObjectT> static_pointer_cast( 193 TransitPtr<SourceObjectT> const &source); 180 194 181 195 /*! \} */ trunk/Source/System/FieldContainer/Base/OSGTransitPtr.inl
r1177 r1181 159 159 } 160 160 161 template<class ObjectT> 162 template<class SourceObjectT> inline 163 void TransitPtr<ObjectT>::dynamic_cast_set( 164 TransitPtr<SourceObjectT> const &source) 165 { 166 ObjectPtr pObj = dynamic_cast<ObjectPtr>(source._pObj); 167 168 if(pObj != NULL) 169 { 170 _pObj = pObj; 171 172 source._pObj = NULL; 173 } 174 } 175 176 template<class ObjectT> 177 template<class SourceObjectT> inline 178 void TransitPtr<ObjectT>::static_cast_set( 179 TransitPtr<SourceObjectT> const &source) 180 { 181 ObjectPtr pObj = static_cast<ObjectPtr>(source._pObj); 182 183 if(pObj != NULL) 184 { 185 _pObj = pObj; 186 187 source._pObj = NULL; 188 } 189 } 190 191 161 192 OSG_END_NAMESPACE 162 193 trunk/Source/System/NodeCores/Groups/DynamicStateGenerators/testCubemapGenerator.cpp
r1176 r1181 218 218 { 219 219 case 27: 220 221 fprintf(stderr, "Start Destruction\n\n"); 222 220 223 delete rentravact; 221 224 … … 386 389 GroupUnrecPtr b1 = Group::create(); 387 390 391 fprintf(stderr, "Create b1n %p %d %d \n", 392 b1n.get(), 393 b1n->getRefCount(), 394 b1n->getWeakRefCount()); 395 388 396 b1n->setCore( b1 ); 389 397 … … 394 402 t1n->setCore (t1 ); 395 403 t1n->addChild(b1n); 404 405 fprintf(stderr, "Create t1n %p %d %d \n", 406 t1n.get(), 407 t1n->getRefCount(), 408 t1n->getWeakRefCount()); 396 409 397 410 cam_trans = t1; … … 411 424 } 412 425 426 fprintf(stderr, "Create dlight %p %d %d \n", 427 dlight.get(), 428 dlight->getRefCount(), 429 dlight->getWeakRefCount()); 413 430 414 431 hdrroot = Node::create(); … … 424 441 hdrroot->setCore (pHDR ); 425 442 443 fprintf(stderr, "Create hdrroot %p %d %d \n", 444 hdrroot.get(), 445 hdrroot->getRefCount(), 446 hdrroot->getWeakRefCount()); 447 426 448 // root 427 449 root = Node:: create(); … … 436 458 root->addChild(t1n ); 437 459 root->addChild(dlight); 460 461 fprintf(stderr, "Create root %p %d %d \n", 462 root.get(), 463 root->getRefCount(), 464 root->getWeakRefCount()); 438 465 439 466 // Load the file … … 581 608 tball.setRotationCenter (tCenter ); 582 609 583 610 fprintf(stderr, "Create b1n %p %d %d \n", 611 b1n.get(), 612 b1n->getRefCount(), 613 b1n->getWeakRefCount()); 614 615 fprintf(stderr, "Create t1n %p %d %d \n", 616 t1n.get(), 617 t1n->getRefCount(), 618 t1n->getWeakRefCount()); 619 620 fprintf(stderr, "Create dlight %p %d %d \n", 621 dlight.get(), 622 dlight->getRefCount(), 623 dlight->getWeakRefCount()); 624 625 fprintf(stderr, "Create hdrroot %p %d %d \n", 626 hdrroot.get(), 627 hdrroot->getRefCount(), 628 hdrroot->getWeakRefCount()); 629 630 fprintf(stderr, "Create root %p %d %d \n", 631 root.get(), 632 root->getRefCount(), 633 root->getWeakRefCount()); 634 584 635 return 0; 585 636 } … … 588 639 { 589 640 doMain(argc, argv); 641 642 fprintf(stderr, "Create hdrroot %p %d %d \n", 643 hdrroot.get(), 644 hdrroot->getRefCount(), 645 hdrroot->getWeakRefCount()); 646 647 fprintf(stderr, "Create root %p %d %d \n", 648 root.get(), 649 root->getRefCount(), 650 root->getWeakRefCount()); 590 651 591 652 // run... trunk/Source/System/NodeCores/Groups/Misc/OSGVisitSubTree.fcd
r435 r1181 19 19 <Field 20 20 name="subTreeRoot" 21 type="NodePtr" 21 type="Node" 22 category="weakpointer" 22 23 cardinality="single" 23 24 visibility="external" trunk/Source/System/NodeCores/Groups/Misc/OSGVisitSubTreeBase.cpp
r1101 r1181 98 98 99 99 100 pDesc = new SF UnrecNodePtr::Description(101 SF UnrecNodePtr::getClassType(),100 pDesc = new SFWeakNodePtr::Description( 101 SFWeakNodePtr::getClassType(), 102 102 "subTreeRoot", 103 103 "Reference to the sub-graph to draw in place of this node.\n" … … 145 145 " <Field\n" 146 146 " name=\"subTreeRoot\"\n" 147 " type=\"NodePtr\"\n" 147 " type=\"Node\"\n" 148 " category=\"weakpointer\"\n" 148 149 " cardinality=\"single\"\n" 149 150 " visibility=\"external\"\n" … … 183 184 184 185 //! Get the VisitSubTree::_sfSubTreeRoot field. 185 const SF UnrecNodePtr *VisitSubTreeBase::getSFSubTreeRoot(void) const186 const SFWeakNodePtr *VisitSubTreeBase::getSFSubTreeRoot(void) const 186 187 { 187 188 return &_sfSubTreeRoot; … … 349 350 GetFieldHandlePtr VisitSubTreeBase::getHandleSubTreeRoot (void) const 350 351 { 351 SF UnrecNodePtr::GetHandlePtr returnValue(352 new SF UnrecNodePtr::GetHandle(352 SFWeakNodePtr::GetHandlePtr returnValue( 353 new SFWeakNodePtr::GetHandle( 353 354 &_sfSubTreeRoot, 354 355 this->getType().getFieldDesc(SubTreeRootFieldId))); … … 359 360 EditFieldHandlePtr VisitSubTreeBase::editHandleSubTreeRoot (void) 360 361 { 361 SF UnrecNodePtr::EditHandlePtr returnValue(362 new SF UnrecNodePtr::EditHandle(362 SFWeakNodePtr::EditHandlePtr returnValue( 363 new SFWeakNodePtr::EditHandle( 363 364 &_sfSubTreeRoot, 364 365 this->getType().getFieldDesc(SubTreeRootFieldId))); trunk/Source/System/NodeCores/Groups/Misc/OSGVisitSubTreeBase.h
r1178 r1181 126 126 /*! \{ */ 127 127 128 const SF UnrecNodePtr*getSFSubTreeRoot (void) const;128 const SFWeakNodePtr *getSFSubTreeRoot (void) const; 129 129 130 130 … … 196 196 /*! \{ */ 197 197 198 SF UnrecNodePtr_sfSubTreeRoot;198 SFWeakNodePtr _sfSubTreeRoot; 199 199 200 200 /*! \} */
