Show
Ignore:
Timestamp:
12/03/07 15:48:13 (1 year ago)
Author:
cneumann
Message:

fixed: compile errors

reference counting


It compiles on linux (when disabling the VRML Loader) and the first
ref counting tests seem to work.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/Carsten_PtrWork2/Source/System/FieldContainer/Base/OSGChangeList.cpp

    r1014 r1030  
    6464 
    6565#if 1 
    66 void ChangeList::addAddRefd(const UInt32 uiContainerId) 
     66void 
     67ChangeList::addAddExternalRef(UInt32 const uiContainerId) 
    6768{ 
    6869#ifdef OSG_ENABLE_VALGRIND_CHECKS 
     
    7172 
    7273#ifndef SILENT 
    73     fprintf(stderr, "Add AddRef %u\n", 
    74             uiContainerId); 
    75 #endif 
    76  
    77     ContainerChangeEntry *pEntry = getNewEntry(); 
    78  
    79     pEntry->uiEntryDesc   = ContainerChangeEntry::AddReference; 
    80     pEntry->uiContainerId = uiContainerId; 
    81 
    82  
    83 void ChangeList::addSubRefd(const UInt32 uiContainerId, 
    84                                   bool   ignoreLevel  ) 
    85 
    86 #ifdef OSG_ENABLE_VALGRIND_CHECKS 
    87     VALGRIND_CHECK_VALUE_IS_DEFINED(uiContainerId); 
    88 #endif 
    89  
    90 #ifndef SILENT 
    91     fprintf(stderr, "Add SubRef %u\n", uiContainerId); 
    92 #endif 
    93  
    94     ContainerChangeEntry *pEntry = getNewEntry(); 
    95  
    96     if(_iSubRefLevel == 0 || ignoreLevel == true) 
    97     { 
    98         pEntry->uiEntryDesc   = ContainerChangeEntry::SubReference; 
    99     } 
    100     else 
    101     { 
    102         pEntry->uiEntryDesc   = ContainerChangeEntry::DepSubReference; 
    103     } 
    104  
    105     pEntry->uiContainerId = uiContainerId; 
    106 
    107  
    108 void 
    109 ChangeList::addAddExternalRefd(UInt32 const uiContainerId) 
    110 
    111 #ifndef SILENT 
    112     FDEBUG(("ChangeList::addAddExternalRefd [%u]\n", uiContainerId)); 
     74    fprintf(stderr, "ChangeList::addAddExternalRef [%u]\n", uiContainerId); 
    11375#endif 
    11476 
     
    12082 
    12183void 
    122 ChangeList::addSubExternalRefd(UInt32 const uiContainerId) 
    123 
     84ChangeList::addSubExternalRef(UInt32 const uiContainerId) 
     85
     86#ifdef OSG_ENABLE_VALGRIND_CHECKS 
     87    VALGRIND_CHECK_VALUE_IS_DEFINED(uiContainerId); 
     88#endif 
     89 
    12490#ifndef SILENT 
    125     FDEBUG(("ChangeList::addSubExternalRefd [%u]\n", uiContainerId)); 
     91    fprintf(stderr, "ChangeList::addSubExternalRef [%u]\n", uiContainerId); 
    12692#endif 
    12793 
     
    223189 
    224190    returnValue->_uiAspect  = Thread::getCurrentAspect(); 
    225  
    226191    returnValue->_bExternal = true; 
    227192 
     
    242207    _workStore         (                   ), 
    243208    _uiAspect          (                  0), 
    244     _iSubRefLevel      (                  0), 
    245209    _bExternal         (false              ) 
    246210{ 
     
    290254} 
    291255 
    292  
    293  
    294  
    295256ContainerChangeEntry *ChangeList::getNewEntry(void) 
    296257{ 
     
    319280    if(_workStore.empty() == false) 
    320281    { 
    321         fprintf(stderr, "warning non empty workstore found\n"); 
    322     } 
    323  
     282        FWARNING(("ChangeList::doCommitChanges<>: Non-empty workstore found\n")); 
     283    } 
    324284 
    325285    const unsigned loop_detection_limit(15); 
     
    405365        { 
    406366#ifndef SILENT_CPTR 
    407             fprintf(stderr, "Strange handler nil %d %p\n",  
    408                     (*ccIt)->uiContainerId,  
    409                     pHandler); 
    410  
     367            fprintf(stderr, "ChangeList::doApply: Handler is NULL %d %p\n", 
     368                    (*ccIt)->uiContainerId, pHandler); 
    411369#endif 
    412370            ++ccIt; 
     
    420378        { 
    421379#ifndef SILENT_CPTR 
    422             fprintf(stderr, "Strange src nil %d %p\n",  
    423                     (*ccIt)->uiContainerId,  
    424                     pSrc); 
    425              
     380            fprintf(stderr, "ChangeList::doApply: Source is NULL %d %p\n", 
     381                    (*ccIt)->uiContainerId, pSrc); 
    426382#endif 
    427383            ++ccIt; 
     
    434390 
    435391#ifndef SILENT_CPTR 
    436             fprintf(stderr, "Setup store for %d %p \n", 
    437                     (*ccIt)->uiContainerId, 
    438                    pDst); 
     392            fprintf(stderr, "ChangeList::doApply: Setup store for %d %p\n", 
     393                    (*ccIt)->uiContainerId, pDst); 
    439394#endif 
    440395 
     
    544499            } 
    545500        } 
    546         else if((*cIt)->uiEntryDesc == ContainerChangeEntry::AddReference) 
    547         { 
    548 #ifndef SILENT_CPTR 
    549             fprintf(stderr, "Execute add Ref for %d %s\n", 
    550                     (*cIt)->uiContainerId, pDst->getType().getCName()); 
    551 #endif 
    552  
    553             if(pDst != NULL) 
    554                 pDst->addReference(); 
    555         } 
    556         else if((*cIt)->uiEntryDesc == ContainerChangeEntry::SubReference)// || 
    557 //            (*cIt)->uiEntryDesc == ContainerChangeEntry::DepSubReference) 
    558         { 
    559 #ifndef SILENT_CPTR 
    560             fprintf(stderr, "Execute sub Ref for %d %s\n", 
    561                     (*cIt)->uiContainerId, pDst->getType().getCName()); 
    562 #endif 
    563              
    564             if(pDst != NULL) 
    565                 pDst->subReference(); 
    566         } 
     501//         else if((*cIt)->uiEntryDesc == ContainerChangeEntry::AddExternalReference) 
     502//         { 
     503// #ifndef SILENT_CPTR 
     504//             fprintf(stderr, "Execute add Ref for %d %s\n", 
     505//                     (*cIt)->uiContainerId, pDst->getType().getCName()); 
     506// #endif 
     507//  
     508//             if(pDst != NULL) 
     509//                 pDst->addExternalReference(); 
     510//         } 
     511//         else if((*cIt)->uiEntryDesc == ContainerChangeEntry::SubExternalReference) 
     512//         { 
     513// #ifndef SILENT_CPTR 
     514//             fprintf(stderr, "Execute sub Ref for %d %s\n", 
     515//                     (*cIt)->uiContainerId, pDst->getType().getCName()); 
     516// #endif 
     517//              
     518//             if(pDst != NULL) 
     519//                 pDst->subExternalReference(); 
     520//         } 
    567521 
    568522        ++cIt; 
     
    576530    if(_uiAspect != Thread::getCurrentAspect()) 
    577531    { 
    578         fprintf(stderr, "ChangeList::doClear aspects don't match %d %d\n", 
    579                 _uiAspect, Thread::getCurrentAspect())
     532        FWARNING(("ChangeList::doClear: Aspects don't match %d %d\n", 
     533                _uiAspect, Thread::getCurrentAspect()))
    580534         
    581535        return; 
     
    632586    while(cIt != cEnd) 
    633587    { 
    634         if((*cIt)->uiEntryDesc == ContainerChangeEntry::AddReference   || 
    635            (*cIt)->uiEntryDesc == ContainerChangeEntry::SubReference   || 
    636            (*cIt)->uiEntryDesc == ContainerChangeEntry::DepSubReference ) 
     588        if((*cIt)->uiEntryDesc == ContainerChangeEntry::AddExternalReference || 
     589           (*cIt)->uiEntryDesc == ContainerChangeEntry::SubExternalReference   ) 
    637590        { 
    638591            ContainerChangeEntry *pEntry = getNewEntry(); 
     
    676629            this->addCreated(i); 
    677630 
    678             for(UInt32 j = 0; j < pContainer->getRefCount(); ++j) 
    679                 this->addAddRefd(i); 
    680  
     631            for(UInt32 j = 0; j < pContainer->getExternalRefCount(); ++j) 
     632                this->addAddExternalRef(i); 
     633             
    681634            ContainerChangeEntry *pEntry = this->getNewEntry(); 
    682635