Ticket #84: cloneTree_01.diff

File cloneTree_01.diff, 124.6 kB (added by cneumann, 2 years ago)

final (?) version of the patch.

  • Source/System/FieldContainer/Base/OSGFieldContainer.cpp

    old new  
    194194    callChangedFunctors(0); 
    195195} 
    196196 
     197/*-------------------------------------------------------------------------*/ 
     198/*                              Cloning                                    */ 
    197199 
    198 void OSG::splitShareString(const std::string               &shareString, 
    199                                  std::vector<std::string> &shareList  ) 
     200/*! Fills \a types with the type objects corresponding to the types named in 
     201    \a typeNames. This is a helper function for deepClone. 
     202    The elements of \a typeNames must be names of FieldContainer types, if a 
     203    type name is not found there is no type object inserted into \a types, i.e. 
     204    \a types may be shorter than \a typeNames. 
     205 
     206    \param[in] typeNames FieldContainer type names. 
     207    \param[out] types Type objects corresponding to \a typeNames. 
     208 */ 
     209void 
     210OSG::appendTypesVector(const std::vector<std::string>                &typeNames, 
     211                             std::vector<const FieldContainerType *> &types     ) 
    200212{ 
    201     shareList.clear()
     213    const FieldContainerType *pType
    202214 
    203     // parse comma separated names. 
    204     std::string::const_iterator nextComma; 
    205     std::string::const_iterator curPos = shareString.begin(); 
     215    std::vector<std::string>::const_iterator namesIt  = typeNames.begin(); 
     216    std::vector<std::string>::const_iterator namesEnd = typeNames.end(); 
    206217 
    207     while(curPos < shareString.end()
     218    for(; namesIt != namesEnd; ++namesIt
    208219    { 
    209         nextComma = std::find(curPos, shareString.end(), ','); 
     220        pType = FieldContainerFactory::the()->findType(namesIt->c_str()); 
    210221 
    211         // strip leading spaces 
    212         curPos = std::find_if(curPos, 
    213                               nextComma, 
    214                               std::not1(std::ptr_fun(isspace))); 
     222        if(pType) 
     223            types.push_back(pType); 
     224    } 
     225
    215226 
    216         shareList.push_back(std::string(curPos, nextComma)); 
     227/*! Fills \a groupIds with the group ids of the groups in \a groupNames. 
     228    This is a helper function for deepClone. 
     229    The elements of \a groupNames must be names of groups, if a group name is 
     230    not found there is no group id inserted into \a groupIds, i.e. 
     231    \a groupIds may be shorter than \a groupNames. 
    217232 
    218         curPos = ++nextComma; 
     233    \param[in] groupNames Names of groups. 
     234    \param[out] groupIds Ids of the groups in \a groupNames. 
     235 */ 
     236void 
     237OSG::appendGroupsVector(const std::vector<std::string> &groupNames, 
     238                              std::vector<UInt16>      &groupIds   ) 
     239
     240    UInt16 groupId; 
     241 
     242    std::vector<std::string>::const_iterator namesIt  = groupNames.begin(); 
     243    std::vector<std::string>::const_iterator namesEnd = groupNames.end(); 
     244 
     245    for(; namesIt != namesEnd; ++namesIt) 
     246    { 
     247        groupId = FieldContainerFactory::the()->findGroupId(namesIt->c_str()); 
     248 
     249        if(groupId != 0) 
     250            groupIds.push_back(groupId); 
    219251    } 
    220252} 
    221253 
    222 void OSG::fillGroupShareList(const std::vector<UInt16     > &shareGroupIds, 
    223                                    std::vector<std::string> &shareList    ) 
     254/*! Fills \a types with the type objects corresponding to the types named in 
     255    \a typesString. This is a helper function for deepClone. 
     256    \a typesString is a comma separated string of FieldContainer type names. 
     257 
     258    \param[in] typesString String of comma separated FieldContainer type names. 
     259    \param[out] types Type objects corresponding to elements of \a typesString. 
     260 */ 
     261void 
     262OSG::appendTypesString(const std::string                             &typesString, 
     263                             std::vector<const FieldContainerType *> &types       ) 
    224264{ 
    225     shareList.clear  (); 
    226     shareList.reserve(shareGroupIds.size()); 
     265    const FieldContainerType *pType; 
     266    string_token_iterator     tokenIt(typesString, ", "); 
     267    string_token_iterator     tokenEnd; 
    227268 
    228     for(UInt32 i = 0; i < shareGroupIds.size(); ++i
     269    for(; tokenIt != tokenEnd; ++tokenIt
    229270    { 
    230         const Char8 *name = 
    231             FieldContainerFactory::the()->findGroupName(shareGroupIds[i]); 
     271        pType = FieldContainerFactory::the()->findType((*tokenIt).c_str()); 
    232272 
    233         if(name != NULL
    234             shareList.push_back(name); 
     273        if(pType
     274            types.push_back(pType); 
    235275    } 
    236276} 
    237277 
    238 // deep clone of a fieldcontainer. 
    239 FieldContainerPtr OSG::deepClone(      FieldContainerPtrConstArg  src, 
    240                                  const std::vector<std::string>  &share) 
     278/*! Creates a deep copy of \a src, i.e. all fields of \a src are copied, if 
     279    they contain pointers to other FieldContainers these are cloned as well. 
     280    The remaining parameters allow the selection of certain types that are 
     281    either not cloned at all or are shared between \a src and the copy. 
     282 
     283    \param[in] src FieldContainer to clone. 
     284    \param[in] shareTypeNames Names of types that should be shared 
     285        instead of cloned. 
     286    \param[in] ignoreTypeNames Names of types that should be ignored. 
     287    \param[in] shareGroupNames Names of type groups that should be shared 
     288        instead of cloned. 
     289    \param[in] ignoreGroupNames Names of type groups that should be ignored. 
     290    \return deep copy of \a src. 
     291 */ 
     292OSG_SYSTEM_DLLMAPPING 
     293FieldContainerPtr 
     294OSG::deepClone(      FieldContainerPtrConstArg  src, 
     295               const std::vector<std::string>  &shareTypeNames, 
     296               const std::vector<std::string>  &ignoreTypeNames, 
     297               const std::vector<std::string>  &shareGroupNames, 
     298               const std::vector<std::string>  &ignoreGroupNames) 
    241299{ 
     300    std::vector<const FieldContainerType *> shareTypes; 
     301    std::vector<const FieldContainerType *> ignoreTypes; 
     302    std::vector<UInt16>                     shareGroupIds; 
     303    std::vector<UInt16>                     ignoreGroupIds; 
     304 
     305    appendTypesVector (shareTypeNames,   shareTypes    ); 
     306    appendTypesVector (ignoreTypeNames,  ignoreTypes   ); 
     307    appendGroupsVector(shareGroupNames,  shareGroupIds ); 
     308    appendGroupsVector(ignoreGroupNames, ignoreGroupIds); 
     309 
     310    return OSG::deepClone(src, shareTypes,    ignoreTypes, 
     311                               shareGroupIds, ignoreGroupIds); 
     312} 
     313 
     314/*! Creates a deep copy of \a src, i.e. all fields of \a src are copied, if 
     315    they contain pointers to other FieldContainers these are cloned as well. 
     316    The remaining parameters allow the selection of certain types that are 
     317    either not cloned at all or are shared between \a src and the copy. 
     318 
     319    \param[in] src FieldContainer to clone. 
     320    \param[in] shareGroupIds Type groups that should be shared instead 
     321        of cloned. 
     322    \param[in] ignoreGroupIds Type groups that should be ignored. 
     323    \return deep copy of \a src. 
     324 */ 
     325FieldContainerPtr 
     326OSG::deepClone(      FieldContainerPtrConstArg  src, 
     327               const std::vector<UInt16>       &shareGroupIds, 
     328               const std::vector<UInt16>       &ignoreGroupIds) 
     329{ 
     330    std::vector<const FieldContainerType *> shareTypes; 
     331    std::vector<const FieldContainerType *> ignoreTypes; 
     332 
     333    return OSG::deepClone(src, shareTypes,    ignoreTypes, 
     334                               shareGroupIds, ignoreGroupIds); 
     335} 
     336 
     337/*! Creates a deep copy of \a src, i.e. all fields of \a src are copied, if 
     338    they contain pointers to other FieldContainers these are cloned as well. 
     339    The remaining parameters allow the selection of certain types that are 
     340    either not cloned at all or are shared between \a src and the copy. 
     341 
     342    \param[in] src FieldContainer to clone. 
     343    \param[in] shareTypesString Comma separated string of type names that 
     344        should be shared instead of cloned. 
     345    \param[in] ignoreTypesString Comma separated string of type names that 
     346        should be ignored. 
     347    \return deep copy of \a src. 
     348 */ 
     349FieldContainerPtr 
     350OSG::deepClone(      FieldContainerPtrConstArg  src, 
     351               const std::string               &shareTypesString, 
     352               const std::string               &ignoreTypesString) 
     353{ 
     354    std::vector<const FieldContainerType *> shareTypes; 
     355    std::vector<const FieldContainerType *> ignoreTypes; 
     356    std::vector<UInt16>                     shareGroupIds; 
     357    std::vector<UInt16>                     ignoreGroupIds; 
     358 
     359    appendTypesString(shareTypesString,  shareTypes); 
     360    appendTypesString(ignoreTypesString, ignoreTypes); 
     361 
     362    return OSG::deepClone(src, shareTypes,    ignoreTypes, 
     363                               shareGroupIds, ignoreGroupIds); 
     364} 
     365 
     366/*! Creates a deep copy of \a src, i.e. all fields of \a src are copied, if 
     367    they contain pointers to other FieldContainers these are cloned as well. 
     368    The remaining parameters allow the selection of certain types that are 
     369    either not cloned at all or are shared between \a src and the copy. 
     370 
     371    \param[in] src FieldContainer to clone. 
     372    \param[in] shareTypes Types that should be shared instead of cloned. 
     373    \param[in] ignoreTypes Types that should be ignored. 
     374    \param[in] shareGroupIds Type groups that should be shared instead 
     375        of cloned. 
     376    \param[in] ignoreGroupIds Type groups that should be ignored. 
     377    \return deep copy of \a src. 
     378 */ 
     379FieldContainerPtr 
     380OSG::deepClone( 
     381               FieldContainerPtrConstArg                src, 
     382         const std::vector<const FieldContainerType *> &shareTypes, 
     383         const std::vector<const FieldContainerType *> &ignoreTypes, 
     384         const std::vector<UInt16>                     &shareGroupIds, 
     385         const std::vector<UInt16>                     &ignoreGroupIds) 
     386{ 
    242387    if(src == NullFC) 
    243388        return NullFC; 
    244389 
    245     const FieldContainerType &type   = src->getType(); 
     390    const FieldContainerType &fcType  = src->getType(); 
     391    FieldContainerPtr         fcClone = fcType.createContainer(); 
    246392 
    247     //FDEBUG(("deepClone: fieldcontainertype = %s\n", type.getCName())); 
     393    UInt32 fCount = osgMin(fcType            .getNumFieldDescs(), 
     394                           fcClone->getType().getNumFieldDescs() ); 
    248395 
    249     FieldContainerPtr dst = 
    250         FieldContainerFactory::the()->createContainer( 
    251             type.getName().str()); 
    252  
    253 //          UInt32              fcount = type.getNumFieldDescs(); 
    254     UInt32 fcount = osgMin(     type     .getNumFieldDescs(), 
    255                            dst->getType().getNumFieldDescs()); 
    256  
    257     for(UInt32 i = 1;i <= fcount;++i) 
     396    for(UInt32 i = 1; i <= fCount; ++i) 
    258397    { 
    259         const FieldDescriptionBase *fdesc = type.getFieldDesc(i); 
     398        const FieldDescriptionBase *fDesc = fcType.getFieldDesc(i); 
    260399 
    261         if(fdesc->isInternal()) 
     400        if(fDesc->isInternal()) 
    262401            continue; 
    263402 
    264         BitVector mask = fdesc->getFieldMask(); 
     403        const UInt32  fieldId  = fDesc  ->getFieldId(); 
     404        const Field  *srcField = src    ->getField (i); 
     405              Field  *dstField = fcClone->editField(i); 
    265406 
    266         const Field * srcField = src->getField (i); 
    267  
    268               Field * dstField = dst->editField(i); 
    269         const Field *cdstField = dst->getField (i); 
    270  
    271407        if(dstField != NULL) 
    272408        { 
    273             fdesc->copyValues (srcField, dstField); 
     409            fDesc->copyValues(srcField, dstField); 
    274410        } 
    275411        else 
    276412        { 
    277             fdesc->cloneValuesV(srcField, mask, share, dst); 
     413            fDesc->cloneValuesV(srcField, fieldId, fcClone, 
     414                                shareTypes,    ignoreTypes, 
     415                                shareGroupIds, ignoreGroupIds); 
    278416        } 
    279417    } 
    280418 
    281     return dst
     419    return fcClone
    282420} 
    283421 
    284 FieldContainerPtr OSG::deepClone( 
    285            FieldContainerPtrConstArg  src, 
    286      const std::vector<UInt16>       &shareGroupIds) 
    287 { 
    288     std::vector<std::string> share; 
    289  
    290     fillGroupShareList(shareGroupIds, share); 
    291  
    292     return OSG::deepClone(src, share); 
    293 } 
    294  
    295 // shareString is a comma separated FieldContainer type list 
    296 // e.g. "Material, Geometry" 
    297 FieldContainerPtr OSG::deepClone(      FieldContainerPtrConstArg  src, 
    298                                  const std::string               &shareString) 
    299 { 
    300     std::vector<std::string> share; 
    301  
    302     splitShareString(shareString, share); 
    303  
    304     return OSG::deepClone(src, share); 
    305 } 
    306  
    307422/*-------------------------------------------------------------------------*/ 
    308423/*                              cvs id's                                   */ 
    309424 
  • Source/System/FieldContainer/Base/OSGAttachmentContainer.h

    old new  
    206206typedef RefPtr<AttachmentContainerPtr>      AttachmentContainerRefPtr; 
    207207 
    208208OSG_SYSTEM_DLLMAPPING 
    209 void deepCloneAttachments(      AttachmentContainerPtrConstArg src, 
    210                                 AttachmentContainerPtrArg      dst, 
    211                           const std::vector<std::string>      &share         ); 
     209void 
     210cloneAttachments( 
     211          AttachmentContainerPtrConstArg           src, 
     212          AttachmentContainerPtrArg                dst, 
     213    const std::vector<std::string>                &cloneTypeNames, 
     214    const std::vector<std::string>                &ignoreTypeNames   = 
     215        std::vector<std::string>(), 
     216    const std::vector<std::string>                &cloneGroupNames   = 
     217        std::vector<std::string>(), 
     218    const std::vector<std::string>                &ignoreGroupNames  = 
     219        std::vector<std::string>()                                    ); 
    212220 
    213221OSG_SYSTEM_DLLMAPPING 
    214 void deepCloneAttachments(      AttachmentContainerPtrConstArg src, 
    215                                 AttachmentContainerPtrArg      dst, 
    216                           const std::vector<UInt16>           &shareGroupIds ); 
     222void 
     223cloneAttachments( 
     224          AttachmentContainerPtrConstArg           src, 
     225          AttachmentContainerPtrArg                dst, 
     226    const std::vector<UInt16>                     &cloneGroupIds, 
     227    const std::vector<UInt16>                     &ignoreGroupIds    = 
     228        std::vector<UInt16>()                                         ); 
    217229 
    218230OSG_SYSTEM_DLLMAPPING 
    219 void deepCloneAttachments(      AttachmentContainerPtrConstArg src, 
    220                                 AttachmentContainerPtrArg      dst, 
    221                           const std::string                   &shareString=""); 
     231void 
     232cloneAttachments( 
     233          AttachmentContainerPtrConstArg           src, 
     234          AttachmentContainerPtrArg                dst, 
     235    const std::string                             &cloneTypesString, 
     236    const std::string                             &ignoreTypesString = 
     237        std::string()                                                 ); 
    222238 
     239OSG_SYSTEM_DLLMAPPING 
     240void 
     241cloneAttachments( 
     242          AttachmentContainerPtrConstArg           src, 
     243          AttachmentContainerPtrArg                dst, 
     244    const std::vector<const FieldContainerType *> &cloneTypes        = 
     245        std::vector<const FieldContainerType *>(), 
     246    const std::vector<const FieldContainerType *> &ignoreTypes       = 
     247        std::vector<const FieldContainerType *>(), 
     248    const std::vector<UInt16>                     &cloneGroupIds     = 
     249        std::vector<UInt16>(), 
     250    const std::vector<UInt16>                     &ignoreGroupIds    = 
     251        std::vector<UInt16>()                                         ); 
    223252 
     253OSG_SYSTEM_DLLMAPPING 
     254void 
     255deepCloneAttachments( 
     256          AttachmentContainerPtrConstArg           src, 
     257          AttachmentContainerPtrArg                dst, 
     258    const std::vector<std::string>                &cloneTypeNames, 
     259    const std::vector<std::string>                &ignoreTypeNames   = 
     260        std::vector<std::string>(), 
     261    const std::vector<std::string>                &cloneGroupNames   = 
     262        std::vector<std::string>(), 
     263    const std::vector<std::string>                &ignoreGroupNames  = 
     264        std::vector<std::string>()                                    ); 
    224265 
     266OSG_SYSTEM_DLLMAPPING 
     267void 
     268deepCloneAttachments( 
     269          AttachmentContainerPtrConstArg           src, 
     270          AttachmentContainerPtrArg                dst, 
     271    const std::vector<UInt16>                     &cloneGroupIds, 
     272    const std::vector<UInt16>                     &ignoreGroupIds    = 
     273        std::vector<UInt16>()                                         ); 
     274 
     275OSG_SYSTEM_DLLMAPPING 
     276void 
     277deepCloneAttachments( 
     278          AttachmentContainerPtrConstArg           src, 
     279          AttachmentContainerPtrArg                dst, 
     280    const std::string                             &cloneTypesString, 
     281    const std::string                             &ignoreTypesString = 
     282        std::string()                                                 ); 
     283 
     284OSG_SYSTEM_DLLMAPPING 
     285void 
     286deepCloneAttachments( 
     287          AttachmentContainerPtrConstArg           src, 
     288          AttachmentContainerPtrArg                dst, 
     289    const std::vector<const FieldContainerType *> &shareTypes        = 
     290        std::vector<const FieldContainerType *>(), 
     291    const std::vector<const FieldContainerType *> &ignoreTypes       = 
     292        std::vector<const FieldContainerType *>(), 
     293    const std::vector<UInt16>                     &shareGroupIds     = 
     294        std::vector<UInt16>(), 
     295    const std::vector<UInt16>                     &ignoreGroupIds    = 
     296        std::vector<UInt16>()                                         ); 
     297 
    225298OSG_END_NAMESPACE 
    226299 
    227300#define OSGATTACHMENTCONTAINER_HEADER_CVSID "@(#)$Id$" 
  • Source/System/FieldContainer/Base/OSGFieldDescriptionBase.h

    old new  
    223223    virtual void pushSizeToStream    (const Field        *pField, 
    224224                                            OutStream    &str   ) const = 0; 
    225225 
    226  
    227  
    228  
    229226    /*! \}                                                                 */ 
    230227    /*---------------------------------------------------------------------*/ 
    231228    /*! \name                     Set from Field                           */ 
     
    234231    virtual void copyValues  (const Field *pSrc, 
    235232                                    Field *pDst  ) const = 0; 
    236233 
     234    virtual void cloneValuesV( 
     235        const Field                                  *pSrc, 
     236        const UInt32                                  fieldId, 
     237              FieldContainerPtrConstArg               pDst, 
     238        const std::vector<const FieldContainerType*> &shareTypes, 
     239        const std::vector<const FieldContainerType*> &ignoreTypes, 
     240        const std::vector<UInt16>                    &shareGroupIds, 
     241        const std::vector<UInt16>                    &ignoreGroupIds) const = 0; 
    237242 
    238     virtual void cloneValuesV(const Field                     *pSrc, 
    239                                     ConstFieldMaskArg          whichField, 
    240                               const StringVector              &share, 
    241                                     FieldContainerPtrConstArg  pDst) const = 0; 
     243    virtual void shareValuesV( 
     244        const Field                                  *pSrc, 
     245        const UInt32                                  fieldId, 
     246              FieldContainerPtrConstArg               pDst, 
     247        const std::vector<const FieldContainerType*> &cloneTypes, 
     248        const std::vector<const FieldContainerType*> &ignoreTypes, 
     249        const std::vector<UInt16>                    &cloneGroupIds, 
     250        const std::vector<UInt16>                    &ignoreGroupIds) const = 0; 
    242251 
    243     virtual void shareValuesV(const Field                     *pSrc, 
    244                                     ConstFieldMaskArg          whichField, 
    245                                     FieldContainerPtrConstArg  pDst) const = 0; 
    246  
    247252    /*! \}                                                                 */ 
    248253    /*---------------------------------------------------------------------*/ 
    249254    /*! \name                   your_category                              */ 
  • Source/System/FieldContainer/Base/OSGFieldContainer.h

    old new  
    7171    /*! \{                                                                 */ 
    7272 
    7373    typedef FieldContainerParent                             Inherited; 
    74      
     74 
    7575    typedef FieldContainerType                               TypeObject; 
    7676 
    7777    typedef PointerBuilder<FieldContainer>::ObjPtr           ObjPtr; 
     
    9797    /*! \name             Get Class Type Information                       */ 
    9898    /*! \{                                                                 */ 
    9999 
    100     static OSG_SYSTEM_DLLMAPPING TypeObject &getClassType   (void);  
     100    static OSG_SYSTEM_DLLMAPPING TypeObject &getClassType   (void); 
    101101    static OSG_SYSTEM_DLLMAPPING UInt32      getClassTypeId (void); 
    102102    static OSG_SYSTEM_DLLMAPPING UInt16      getClassGroupId(void); 
    103103 
     
    106106    /*! \name        General Fieldcontainer Declaration                    */ 
    107107    /*! \{                                                                 */ 
    108108 
    109     OSG_SYSTEM_DLLMAPPING  
     109    OSG_SYSTEM_DLLMAPPING 
    110110    virtual       TypeObject &getType(void); 
    111      
     111 
    112112    OSG_SYSTEM_DLLMAPPING 
    113113    virtual const TypeObject &getType(void) const; 
    114114 
     
    117117    /*! \name                      Get                                     */ 
    118118    /*! \{                                                                 */ 
    119119 
    120     OSG_SYSTEM_DLLMAPPING  
    121     virtual void    copyFromBin(BinaryDataHandler  &pMem,  
     120    OSG_SYSTEM_DLLMAPPING 
     121    virtual void    copyFromBin(BinaryDataHandler  &pMem, 
    122122                                ConstFieldMaskArg   whichField); 
    123123 
    124124    /*---------------------------------------------------------------------*/ 
     
    137137    /*! \name                      Set                                     */ 
    138138    /*! \{                                                                 */ 
    139139 
    140     virtual void changed            (ConstFieldMaskArg whichField,  
     140    virtual void changed            (ConstFieldMaskArg whichField, 
    141141                                     UInt32            origin    ); 
    142142 
    143143            void callChangedFunctors(ConstFieldMaskArg whichField); 
     
    148148    /*! \{                                                                 */ 
    149149 
    150150    OSG_SYSTEM_DLLMAPPING 
    151     virtual void pushToField     (      FieldContainerPtrConstArg pNewElement,  
     151    virtual void pushToField     (      FieldContainerPtrConstArg pNewElement, 
    152152                                  const UInt32                    uiFieldId  ); 
    153153 
    154154    OSG_SYSTEM_DLLMAPPING 
    155     virtual void insertIntoMField(const UInt32                    uiIndex,  
    156                                         FieldContainerPtrConstArg pNewElement,  
     155    virtual void insertIntoMField(const UInt32                    uiIndex, 
     156                                        FieldContainerPtrConstArg pNewElement, 
    157157                                  const UInt32                    uiFieldId  ); 
    158158 
    159159    OSG_SYSTEM_DLLMAPPING 
    160160    virtual void replaceInMField (const UInt32                    uiIndex, 
    161                                         FieldContainerPtrConstArg pNewElement,  
     161                                        FieldContainerPtrConstArg pNewElement, 
    162162                                  const UInt32                    uiFieldId  ); 
    163163 
    164164    OSG_SYSTEM_DLLMAPPING 
    165165    virtual void replaceInMField (      FieldContainerPtrConstArg pOldElement, 
    166                                         FieldContainerPtrConstArg pNewElement,  
     166                                        FieldContainerPtrConstArg pNewElement, 
    167167                                  const UInt32                    uiFieldId  ); 
    168168 
    169169    OSG_SYSTEM_DLLMAPPING 
    170     virtual void removeFromMField(const UInt32                    uiIndex,  
     170    virtual void removeFromMField(const UInt32                    uiIndex, 
    171171                                  const UInt32                    uiFieldId  ); 
    172      
     172 
    173173    OSG_SYSTEM_DLLMAPPING 
    174     virtual void removeFromMField(      FieldContainerPtrConstArg pElement,  
     174    virtual void removeFromMField(      FieldContainerPtrConstArg pElement, 
    175175                                  const UInt32                    uiFieldId  ); 
    176176 
    177177    OSG_SYSTEM_DLLMAPPING 
     
    201201    /*---------------------------------------------------------------------*/ 
    202202    /*! \name                   Field Flags                                */ 
    203203    /*! \{                                                                 */ 
    204      
     204 
    205205    const FieldFlags *getFieldFlags(void); 
    206206 
    207207    /*! \}                                                                 */ 
     
    223223    /*! \{                                                                 */ 
    224224 
    225225    OSG_SYSTEM_DLLMAPPING 
    226     virtual void dump(      UInt32    uiIndent = 0,  
     226    virtual void dump(      UInt32    uiIndent = 0, 
    227227                      const BitVector bvFlags  = 0) const; 
    228228 
    229229    /*! \}                                                                 */ 
     
    261261    /*! \name                   Constructors                               */ 
    262262    /*! \{                                                                 */ 
    263263 
    264     OSG_SYSTEM_DLLMAPPING  
     264    OSG_SYSTEM_DLLMAPPING 
    265265    FieldContainer(void); 
    266266 
    267     OSG_SYSTEM_DLLMAPPING  
     267    OSG_SYSTEM_DLLMAPPING 
    268268    FieldContainer(const FieldContainer &source); 
    269269 
    270270    /*! \}                                                                 */ 
     
    272272    /*! \name                   Destructor                                 */ 
    273273    /*! \{                                                                 */ 
    274274 
    275     OSG_SYSTEM_DLLMAPPING  
     275    OSG_SYSTEM_DLLMAPPING 
    276276    virtual ~FieldContainer(void); 
    277277 
    278278    /*! \}                                                                 */ 
     
    295295    /*! \{                                                                 */ 
    296296 
    297297#ifdef OSG_MT_FIELDCONTAINERPTR 
    298     OSG_SYSTEM_DLLMAPPING  
     298    OSG_SYSTEM_DLLMAPPING 
    299299    virtual void execSyncV(      FieldContainer    &oFrom, 
    300300                                 ConstFieldMaskArg  whichField, 
    301301                                 ConstFieldMaskArg  syncMode  , 
    302302                           const UInt32             uiSyncInfo, 
    303303                                 UInt32             uiCopyOffset) = 0; 
    304304 
    305     OSG_SYSTEM_DLLMAPPING  
     305    OSG_SYSTEM_DLLMAPPING 
    306306            void execSync (      FieldContainer    *pFrom, 
    307307                                 ConstFieldMaskArg  whichField, 
    308308                                 ConstFieldMaskArg  syncMode  , 
     
    310310                                 UInt32             uiCopyOffset); 
    311311#endif 
    312312#ifdef OSG_MT_CPTR_ASPECT 
    313     OSG_SYSTEM_DLLMAPPING  
     313    OSG_SYSTEM_DLLMAPPING 
    314314    virtual void execSyncV(      FieldContainer    &oFrom, 
    315315                                 ConstFieldMaskArg  whichField, 
    316316                                 AspectOffsetStore &oOffsets, 
    317317                                 ConstFieldMaskArg         syncMode  , 
    318318                           const UInt32                    uiSyncInfo) = 0; 
    319319 
    320     OSG_SYSTEM_DLLMAPPING  
     320    OSG_SYSTEM_DLLMAPPING 
    321321            void execSync (      FieldContainer    *pFrom, 
    322322                                 ConstFieldMaskArg  whichField, 
    323323                                 AspectOffsetStore &oOffsets, 
     
    331331    /*! \{                                                                 */ 
    332332 
    333333#if 0 
    334     OSG_SYSTEM_DLLMAPPING  
    335     virtual void execBeginEditV(ConstFieldMaskArg whichField,  
     334    OSG_SYSTEM_DLLMAPPING 
     335    virtual void execBeginEditV(ConstFieldMaskArg whichField, 
    336336                                UInt32            uiAspect, 
    337337                                UInt32            uiContainerSize) = 0; 
    338338 
    339     OSG_SYSTEM_DLLMAPPING  
    340             void execBeginEdit (ConstFieldMaskArg whichField,  
     339    OSG_SYSTEM_DLLMAPPING 
     340            void execBeginEdit (ConstFieldMaskArg whichField, 
    341341                                UInt32            uiAspect, 
    342342                                UInt32            uiContainerSize); 
    343343#endif 
     
    347347    /*! \name                MT Construction                               */ 
    348348    /*! \{                                                                 */ 
    349349 
    350     OSG_SYSTEM_DLLMAPPING  
     350    OSG_SYSTEM_DLLMAPPING 
    351351            void onCreateAspect(const FieldContainer *createAspect, 
    352352                                const FieldContainer *source      = NULL); 
    353     OSG_SYSTEM_DLLMAPPING  
     353    OSG_SYSTEM_DLLMAPPING 
    354354            void onCreate      (const FieldContainer *source      = NULL); 
    355355 
    356356    OSG_SYSTEM_DLLMAPPING 
    357357    virtual void onDestroy     (      UInt32          uiContainerId     ); 
    358358 
    359     OSG_SYSTEM_DLLMAPPING        
     359    OSG_SYSTEM_DLLMAPPING 
    360360    virtual bool deregister    (      UInt32          uiContainerId     ); 
    361361 
    362362#ifdef OSG_MT_CPTR_ASPECT 
     
    373373 
    374374    OSG_SYSTEM_DLLMAPPING 
    375375            void registerChangedContainer (void); 
    376      
     376 
    377377    OSG_SYSTEM_DLLMAPPING 
    378378    virtual void registerChangedContainerV(void); 
    379379 
     
    423423}; 
    424424 
    425425OSG_SYSTEM_DLLMAPPING 
    426 FieldContainerPtr deepClone(      FieldContainerPtrConstArg  src, 
    427                             const std::vector<std::string>  &share           ); 
     426void 
     427appendTypesVector (const std::vector<std::string>                &typeNames, 
     428                         std::vector<const FieldContainerType *> &types       ); 
    428429 
    429430OSG_SYSTEM_DLLMAPPING 
    430 FieldContainerPtr deepClone(      FieldContainerPtrConstArg  src, 
    431                             const std::vector<UInt16>       &shareGroupIds   ); 
     431void 
     432appendGroupsVector(const std::vector<std::string>                &groupNames, 
     433                         std::vector<UInt16>                     &groupIds    ); 
    432434 
    433435OSG_SYSTEM_DLLMAPPING 
    434 FieldContainerPtr deepClone(      FieldContainerPtrConstArg  src, 
    435                             const std::string               &shareString = ""); 
     436void 
     437appendTypesString (const std::string                             &typesString, 
     438                         std::vector<const FieldContainerType *> &types       ); 
    436439 
     440OSG_SYSTEM_DLLMAPPING 
     441FieldContainerPtr 
     442deepClone(      FieldContainerPtrConstArg                src, 
     443          const std::vector<std::string>                &shareTypeNames, 
     444          const std::vector<std::string>                &ignoreTypeNames   = 
     445              std::vector<std::string>(), 
     446          const std::vector<std::string>                &shareGroupNames   = 
     447              std::vector<std::string>(), 
     448          const std::vector<std::string>                &ignoreGroupNames  = 
     449              std::vector<std::string>()                                    ); 
    437450 
    438451OSG_SYSTEM_DLLMAPPING 
    439 void splitShareString  (const std::string              &shareString, 
    440                               std::vector<std::string> &shareList    ); 
     452FieldContainerPtr 
     453deepClone(      FieldContainerPtrConstArg                src, 
     454          const std::vector<UInt16>                     &shareGroupIds, 
     455          const std::vector<UInt16>                     &ignoreGroupIds    = 
     456              std::vector<UInt16>()                                         ); 
    441457 
    442458OSG_SYSTEM_DLLMAPPING 
    443 void fillGroupShareList(const std::vector<UInt16     > &shareGroupIds, 
    444                               std::vector<std::string> &shareList    ); 
     459FieldContainerPtr 
     460deepClone(      FieldContainerPtrConstArg                src, 
     461          const std::string                             &shareTypesString, 
     462          const std::string                             &ignoreTypesString = 
     463              std::string()                                                 ); 
    445464 
     465OSG_SYSTEM_DLLMAPPING 
     466FieldContainerPtr 
     467deepClone(      FieldContainerPtrConstArg                src, 
     468          const std::vector<const FieldContainerType *> &shareTypes        = 
     469              std::vector<const FieldContainerType *>(), 
     470          const std::vector<const FieldContainerType *> &ignoreTypes       = 
     471              std::vector<const FieldContainerType *>(), 
     472          const std::vector<UInt16>                     &shareGroupIds     = 
     473              std::vector<UInt16>(), 
     474          const std::vector<UInt16>                     &ignoreGroupIds    = 
     475              std::vector<UInt16>()                                         ); 
     476 
    446477OSG_END_NAMESPACE 
    447478 
    448479#define OSGFIELDCONTAINER_HEADER_CVSID "@(#)$Id$" 
  • Source/System/FieldContainer/Base/OSGAttachmentContainer.cpp

    old new  
    9090OSG_ABSTR_FIELD_CONTAINER_DEF(AttachmentContainer) 
    9191 
    9292/*-------------------------------------------------------------------------*/ 
    93 /*                             Comparison                                  */ 
     93/*                              Cloning                                    */ 
    9494 
     95/*! Adds the attachments of \a src to \a dst, overwriting existing attachments 
     96    of the same type and binding. By default attachments are shared, only if 
     97    an attachment's type name is in \a cloneTypeNames or if it belongs to a 
     98    group in \a cloneGroupNames it is cloned. If an attachment's type is in 
     99    \a ignoreTypeNames or belongs to a group in \a ignoreGroupNames it is 
     100    ignored altogether. 
    95101 
    96 /** Deep clone of attachements. */ 
    97 void OSG::deepCloneAttachments( 
     102    \param[in] src AttachmentContainer whose attachments are cloned. 
     103    \param[out] dst AttachmentContainer where cloned attachments are added. 
     104    \param[in] cloneTypeNames List of type names that are cloned. 
     105    \param[in] ignoreTypeNames List of type names that are ignored. 
     106    \param[in] cloneGroupNames List of group names that are cloned. 
     107    \param[in] ignoreGroupNames LIst of group names that are ignored. 
     108 */ 
     109void 
     110OSG::cloneAttachments( 
    98111          AttachmentContainerPtrConstArg  src, 
    99112          AttachmentContainerPtrArg       dst, 
    100     const std::vector<std::string>       &share) 
     113    const std::vector<std::string>       &cloneTypeNames, 
     114    const std::vector<std::string>       &ignoreTypeNames, 
     115    const std::vector<std::string>       &cloneGroupNames, 
     116    const std::vector<std::string>       &ignoreGroupNames) 
    101117{ 
    102     const FieldContainerType   &type     = dst->getType(); 
     118    std::vector<const FieldContainerType *> cloneTypes; 
     119    std::vector<const FieldContainerType *> ignoreTypes; 
     120    std::vector<UInt16>                     cloneGroupIds; 
     121    std::vector<UInt16>                     ignoreGroupIds; 
    103122 
    104     const FieldDescriptionBase *fdesc    = type.getFieldDesc("attachments"); 
     123    appendTypesVector (cloneTypeNames,   cloneTypes    ); 
     124    appendTypesVector (ignoreTypeNames,  ignoreTypes   ); 
     125    appendGroupsVector(cloneGroupNames,  cloneGroupIds ); 
     126    appendGroupsVector(ignoreGroupNames, ignoreGroupIds); 
    105127 
    106     const Field                *srcField = src->getField("attachments"); 
     128    OSG::cloneAttachments(src, dst, cloneTypes,    ignoreTypes, 
     129                                    cloneGroupIds, ignoreGroupIds); 
     130
    107131 
    108           BitVector             mask     = fdesc->getFieldMask(); 
     132/*! Adds the attachments of \a src to \a dst, overwriting existing attachments 
     133    of the same type and binding. By default attachments are shared, only if 
     134    an attachment belongs to a group in \a cloneGroupIds it is cloned. If the 
     135    attachment belongs to a group in \a ignoreGroupIds it is ignored altogether. 
    109136 
    110     fdesc->cloneValuesV(srcField, mask, share, dst); 
     137    \param[in] src AttachmentContainer whose attachments are cloned. 
     138    \param[out] dst AttachmentContainer where cloned attachments are added. 
     139    \param[in] cloneGroupIds List of group ids, whose members are cloned. 
     140    \param[in] ignoreGroupIds List of group ids, whose members are ignored. 
     141 */ 
     142void 
     143OSG::cloneAttachments( 
     144          AttachmentContainerPtrConstArg  src, 
     145          AttachmentContainerPtrArg       dst, 
     146    const std::vector<UInt16>            &cloneGroupIds, 
     147    const std::vector<UInt16>            &ignoreGroupIds) 
     148
     149    std::vector<const FieldContainerType *> cloneTypes; 
     150    std::vector<const FieldContainerType *> ignoreTypes; 
     151 
     152    OSG::cloneAttachments(src, dst, cloneTypes,    ignoreTypes, 
     153                                    cloneGroupIds, ignoreGroupIds); 
    111154} 
    112155 
    113 void OSG::deepCloneAttachments( 
     156/*! Adds the attachments of \a src to \a dst, overwriting existing attachments 
     157    of the same type and binding. By default attachments are shared, only if 
     158    an attachment's type is in the comma separated string of type names 
     159    \a cloneTypesString it is cloned. If the type is in the comma separated 
     160    string of type names \a ignoreTypesString the attachment is ignored 
     161    altog