Show
Ignore:
Timestamp:
12/12/07 18:00:42 (9 months ago)
Author:
cneumann
Message:

added: generic interface
changed: factory functions return RefPtr?

The unittests don't pass right now, because of the change
to the factory functions, which leads to containers
being immediately destroyed as they are not assigned to
a RefPtr?.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/Carsten_PtrWork2/Source/System/Cluster/Window/SortLast/OSGSortLastWindowBase.cpp

    r1020 r1032  
    9595*/ 
    9696 
    97  
     97     
    9898void SortLastWindowBase::classDescInserter(TypeObject &oType) 
    9999{ 
    100100    FieldDescriptionBase *pDesc = NULL; 
    101  
    102101 
    103102    pDesc = new MFNodeInternalPtr::Description( 
     
    105104        "groupNodes", 
    106105        "", 
    107         GroupNodesFieldId, GroupNodesFieldMask, 
     106        GroupNodesFieldId, 
     107        GroupNodesFieldMask, 
    108108        false, 
    109109        Field::MFDefaultFlags, 
    110110        static_cast<FieldEditMethodSig>(&SortLastWindowBase::editHandleGroupNodes), 
    111         static_cast<FieldGetMethodSig >(&SortLastWindowBase::getHandleGroupNodes)); 
    112  
    113     oType.addInitialDesc(pDesc); 
    114  
     111        static_cast<FieldGetMethodSig >(&SortLastWindowBase::getHandleGroupNodes ) ); 
     112         
     113        oType.addInitialDesc(pDesc); 
     114         
     115         
    115116    pDesc = new MFUInt32::Description( 
    116117        MFUInt32::getClassType(), 
    117118        "groupLengths", 
    118119        "", 
    119         GroupLengthsFieldId, GroupLengthsFieldMask, 
     120        GroupLengthsFieldId, 
     121        GroupLengthsFieldMask, 
    120122        false, 
    121123        Field::MFDefaultFlags, 
    122124        static_cast<FieldEditMethodSig>(&SortLastWindowBase::editHandleGroupLengths), 
    123         static_cast<FieldGetMethodSig >(&SortLastWindowBase::getHandleGroupLengths)); 
    124  
    125     oType.addInitialDesc(pDesc); 
    126  
     125        static_cast<FieldGetMethodSig >(&SortLastWindowBase::getHandleGroupLengths ) ); 
     126         
     127        oType.addInitialDesc(pDesc); 
     128         
     129         
    127130    pDesc = new SFBool::Description( 
    128131        SFBool::getClassType(), 
    129132        "groupsChanged", 
    130133        "", 
    131         GroupsChangedFieldId, GroupsChangedFieldMask, 
     134        GroupsChangedFieldId, 
     135        GroupsChangedFieldMask, 
    132136        true, 
    133137        Field::SFDefaultFlags, 
    134138        static_cast<FieldEditMethodSig>(&SortLastWindowBase::editHandleGroupsChanged), 
    135         static_cast<FieldGetMethodSig >(&SortLastWindowBase::getHandleGroupsChanged)); 
    136  
    137     oType.addInitialDesc(pDesc); 
    138 
    139  
     139        static_cast<FieldGetMethodSig >(&SortLastWindowBase::getHandleGroupsChanged ) ); 
     140         
     141        oType.addInitialDesc(pDesc); 
     142         
     143         
     144
    140145 
    141146SortLastWindowBase::TypeObject SortLastWindowBase::_type( 
     
    191196    "Cluster rendering configuration for sort first image composition\n" 
    192197    ); 
    193  
     198     
    194199/*------------------------------ get -----------------------------------*/ 
    195200 
     
    266271} 
    267272 
    268 void 
     273bool 
    269274SortLastWindowBase::replaceGroupNodes( 
    270275    MFNodeInternalPtr::ArgumentType pOldElem, 
    271276    MFNodeInternalPtr::ArgumentType pNewElem ) 
    272277{ 
    273     if(pNewElem == NullFC) 
    274         return; 
     278    bool retVal = false; 
     279 
     280    if(pNewElem != NullFC) 
     281        return retVal; 
    275282 
    276283    GroupNodesFieldType::iterator fieldIt = 
     
    279286    if(fieldIt != _mfGroupNodes.end()) 
    280287    { 
     288        retVal = true; 
     289     
    281290        editMField(GroupNodesFieldMask, _mfGroupNodes); 
    282291         
    283292        (*fieldIt) = NodePtr(pNewElem); 
    284293    } 
     294     
     295    return retVal; 
    285296} 
    286297 
     
    300311} 
    301312 
    302 void 
     313bool 
    303314SortLastWindowBase::subGroupNodes( 
    304315    MFNodeInternalPtr::ArgumentType value) 
    305316{ 
     317    bool retVal = false; 
    306318    GroupNodesFieldType::iterator fieldIt = 
    307319        _mfGroupNodes.find(value); 
     
    309321    if(fieldIt != _mfGroupNodes.end()) 
    310322    { 
     323        retVal = true; 
     324     
    311325        editMField(GroupNodesFieldMask, _mfGroupNodes); 
    312326         
    313327        _mfGroupNodes.erase(fieldIt); 
    314328    } 
     329     
     330    return retVal; 
    315331} 
    316332 
     
    389405 
    390406//! create a new instance of the class 
    391 SortLastWindowPtr SortLastWindowBase::create(void) 
    392 
    393     SortLastWindowPtr fc; 
     407SortLastWindowBase::ObjRefPtr 
     408SortLastWindowBase::create(void) 
     409
     410    ObjRefPtr pFC; 
    394411 
    395412    if(getClassType().getPrototype() != NullFC) 
    396413    { 
    397         fc = dynamic_cast<SortLastWindow::ObjPtr>( 
    398             getClassType().getPrototype()-> shallowCopy()); 
    399     } 
    400  
    401     return fc
     414        pFC = boost::dynamic_pointer_cast<SortLastWindow>( 
     415            getClassType().getPrototype()->shallowCopy()); 
     416    } 
     417 
     418    return pFC
    402419} 
    403420 
     
    412429} 
    413430 
    414 FieldContainerPtr SortLastWindowBase::shallowCopy(void) const 
    415 
    416     SortLastWindowPtr returnValue; 
     431FieldContainerRefPtr 
     432SortLastWindowBase::shallowCopy(void) const 
     433
     434    ObjPtr returnValue; 
    417435 
    418436    newPtr(returnValue, dynamic_cast<const SortLastWindow *>(this)); 
    419437 
    420     return returnValue
     438    return FieldContainerRefPtr(returnValue)
    421439} 
    422440 
     
    465483            ++GroupNodesIt; 
    466484        } 
     485         
    467486    } 
    468487} 
     
    484503             &_mfGroupNodes,  
    485504             this->getType().getFieldDesc(GroupNodesFieldId))); 
    486  
    487 //    returnValue->setAddMethod(boost::bind(&SortLastWindow::addGroupNodes,  
    488 //                              static_cast<SortLastWindow *>(this), _1)); 
     505    returnValue->setAddFunc( 
     506        boost::bind( 
     507            &SortLastWindow::addGroupNodes, 
     508            static_cast<SortLastWindow *>(this), _1)); 
     509    returnValue->setInsertFunc( 
     510        boost::bind( 
     511            &SortLastWindow::insertGroupNodes, 
     512            static_cast<SortLastWindow *>(this), _1, _2)); 
     513             
     514    void (SortLastWindow::*replaceGroupNodesIndexFunc)( 
     515        UInt32 const, 
     516        MFNodeInternalPtr::ArgumentType) = 
     517            &SortLastWindow::replaceGroupNodes; 
     518    returnValue->setReplaceIndexFunc( 
     519        boost::bind( 
     520            replaceGroupNodesIndexFunc, 
     521            static_cast<SortLastWindow *>(this), _1, _2)); 
     522             
     523    bool (SortLastWindow::*replaceGroupNodesObjectFunc)( 
     524        MFNodeInternalPtr::ArgumentType, 
     525        MFNodeInternalPtr::ArgumentType ) = 
     526            &SortLastWindow::replaceGroupNodes; 
     527    returnValue->setReplaceObjectFunc( 
     528        boost::bind( 
     529            replaceGroupNodesObjectFunc, 
     530            static_cast<SortLastWindow *>(this), _1, _2)); 
     531             
     532    void (SortLastWindow::*subGroupNodesIndexFunc)(UInt32 const) = 
     533        &SortLastWindow::subGroupNodes; 
     534    returnValue->setSubIndexFunc( 
     535        boost::bind( 
     536            subGroupNodesIndexFunc, 
     537            static_cast<SortLastWindow *>(this), _1)); 
     538             
     539    bool (SortLastWindow::*subGroupNodesObjectFunc)( 
     540        MFNodeInternalPtr::ArgumentType) = 
     541            &SortLastWindow::subGroupNodes; 
     542    returnValue->setSubObjectFunc( 
     543        boost::bind( 
     544            subGroupNodesObjectFunc, 
     545            static_cast<SortLastWindow *>(this), _1)); 
     546    returnValue->setClearFunc( 
     547        boost::bind( 
     548            &SortLastWindow::clearGroupNodes, 
     549            static_cast<SortLastWindow *>(this))); 
    489550 
    490551    editMField(GroupNodesFieldMask, _mfGroupNodes);