Changeset 824

Show
Ignore:
Timestamp:
07/04/07 00:15:36 (1 year ago)
Author:
vossg
Message:

fixed : removed another mixin

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Source/System/FieldContainer/Base/OSGAttachmentContainer.cpp

    r782 r824  
    5353void AttachmentContainer::classDescInserter(TypeObject &oType) 
    5454{ 
    55     Inherited::classDescInserter(oType); 
     55    FieldDescriptionBase *pDesc; 
     56 
     57    typedef SFAttachmentObjPtrMap::Description SFDesc; 
     58 
     59    pDesc = new SFDesc( 
     60        SFAttachmentObjPtrMap::getClassType(), 
     61        "attachments", 
     62        "List of attachments connected.", 
     63        OSG_RC_FIELD_DESC(Attachments), 
     64        false, 
     65        Field::SFDefaultFlags, 
     66        static_cast     <FieldEditMethodSig>(&Self::invalidEditField), 
     67        reinterpret_cast<FieldGetMethodSig >(&Self::getSFAttachments), 
     68        NULL); 
     69 
     70    oType.addInitialDesc(pDesc); 
    5671} 
    5772 
     
    7186 
    7287AttachmentContainer::AttachmentContainer(void) : 
    73     Inherited() 
     88     Inherited    (), 
     89    _sfAttachments() 
    7490{ 
    7591} 
    7692 
    7793AttachmentContainer::AttachmentContainer(const AttachmentContainer &source) : 
    78     Inherited(source) 
     94     Inherited    (source               ), 
     95    _sfAttachments(source._sfAttachments) 
    7996{ 
    8097} 
     
    90107 
    91108OSG_ABSTR_FIELD_CONTAINER_DEF(AttachmentContainer) 
     109 
     110 
     111void AttachmentContainer::pushToField( 
     112          FieldContainerPtrConstArg pNewElement, 
     113    const UInt32                    uiFieldId   ) 
     114{ 
     115    Inherited::pushToField(pNewElement, uiFieldId); 
     116 
     117    if(uiFieldId == AttachmentsFieldId) 
     118    { 
     119        addAttachment(dynamic_cast<AttachmentObjPtr>(pNewElement)); 
     120    } 
     121} 
     122 
     123void AttachmentContainer::insertIntoMField( 
     124    const UInt32                    uiIndex, 
     125          FieldContainerPtrConstArg pNewElement, 
     126    const UInt32                    uiFieldId   ) 
     127{ 
     128    Inherited::insertIntoMField(uiIndex, pNewElement, uiFieldId); 
     129     
     130    FWARNING(("AttachmentContainerMixin::insertIntoMField: NIY\n")); 
     131} 
     132 
     133void AttachmentContainer::replaceInMField ( 
     134    const UInt32                    uiIndex, 
     135          FieldContainerPtrConstArg pNewElement, 
     136    const UInt32                    uiFieldId   ) 
     137{ 
     138    Inherited::replaceInMField(uiIndex, pNewElement, uiFieldId); 
     139 
     140    FWARNING(("AttachmentContainerMixin::replaceInMField: NIY\n")); 
     141} 
     142 
     143void AttachmentContainer::replaceInMField ( 
     144          FieldContainerPtrConstArg pOldElement, 
     145          FieldContainerPtrConstArg pNewElement, 
     146    const UInt32                    uiFieldId  ) 
     147{ 
     148    Inherited::replaceInMField(pOldElement, pNewElement, uiFieldId); 
     149     
     150    FWARNING(("AttachmentContainerMixin::replaceInMField: NIY\n")); 
     151} 
     152 
     153void AttachmentContainer::removeFromMField( 
     154    const UInt32                    uiIndex, 
     155    const UInt32                    uiFieldId ) 
     156{ 
     157    Inherited::removeFromMField(uiIndex, uiFieldId); 
     158     
     159    FWARNING(("AttachmentContainerMixin::removeFromMField: NIY\n")); 
     160} 
     161 
     162void AttachmentContainer::removeFromMField( 
     163          FieldContainerPtrConstArg pElement, 
     164    const UInt32                    uiFieldId ) 
     165{ 
     166    Inherited::removeFromMField(pElement, uiFieldId); 
     167     
     168    FWARNING(("AttachmentContainerMixin::removeFromMField: NIY\n")); 
     169} 
     170 
     171void AttachmentContainer::clearField(const UInt32 uiFieldId) 
     172{ 
     173    Inherited::clearField(uiFieldId); 
     174     
     175    FWARNING(("AttachmentContainerMixin::clearField: NIY\n")); 
     176} 
     177 
     178/*-------------------------------------------------------------------------*/ 
     179/* Binary access                                                           */ 
     180 
     181UInt32 AttachmentContainer::getBinSize(ConstFieldMaskArg whichField) 
     182{ 
     183    UInt32 returnValue = Inherited::getBinSize(whichField); 
     184 
     185    if(FieldBits::NoField != (AttachmentsFieldMask & whichField)) 
     186    { 
     187        returnValue += _sfAttachments.getBinSize(); 
     188    } 
     189 
     190    return returnValue; 
     191} 
     192 
     193void AttachmentContainer::copyToBin(BinaryDataHandler  &pMem,  
     194                                    ConstFieldMaskArg   whichField) 
     195{ 
     196    Inherited::copyToBin(pMem, whichField); 
     197 
     198    if(FieldBits::NoField != (AttachmentsFieldMask & whichField)) 
     199    { 
     200        _sfAttachments.copyToBin(pMem); 
     201    } 
     202} 
     203 
     204void AttachmentContainer::copyFromBin(BinaryDataHandler &pMem,  
     205                                      ConstFieldMaskArg  whichField) 
     206{ 
     207    Inherited::copyFromBin(pMem, whichField); 
     208 
     209    if(FieldBits::NoField != (AttachmentsFieldMask & whichField)) 
     210    { 
     211        _sfAttachments.copyFromBin(pMem); 
     212    } 
     213} 
     214 
     215/*-------------------------------------------------------------------------*/ 
     216/*                             Assignment                                  */ 
     217 
     218/** 
     219 * Add an attachment at the binding point. 
     220 * 
     221 * \param pAttachment  The FCPtr to attach 
     222 * \param binding      id that is combined with the groupId of the attachment 
     223 *                     to determine the slot in the attachment map. 
     224 * If the derived key (binding | group) matches an existing key this will 
     225 * replace the old entry in the map. 
     226 * The attachment will have this node set as it's parent. 
     227 */ 
     228 
     229void AttachmentContainer::addAttachment( 
     230    const AttachmentObjPtr pAttachment, 
     231          UInt16           binding) 
     232{ 
     233    UInt32 key; 
     234 
     235    if(pAttachment == NullFC) 
     236        return; 
     237 
     238    key = (UInt32 (pAttachment->getGroupId()) << 16) | binding; 
     239 
     240    addRef(pAttachment); 
     241 
     242    pAttachment->addParent(this); 
     243 
     244    Self::editSField(AttachmentsFieldMask); 
     245 
     246    AttachmentObjPtrMapIt fcI = _sfAttachments.getValue().find(key); 
     247 
     248    if(fcI != _sfAttachments.getValue().end()) 
     249    { 
     250        (*fcI).second->subParent(this); 
     251 
     252        subRef((*fcI).second); 
     253 
     254        (*fcI).second = pAttachment; 
     255    } 
     256    else 
     257    { 
     258        _sfAttachments.getValue()[key] = pAttachment; 
     259    } 
     260} 
     261 
     262/** 
     263 * Erase the attachment at the binding point. 
     264 * 
     265 * \param pAttachment  The FCPtr to detach (needed to get groupId()) 
     266 * \param binding      id that is combined with the groupId of the attachment 
     267 *                     to determine the slot in the attachment map. 
     268 * 
     269 * Attempt to find attachment in map using key (binding|groupId). 
     270 * If found, remove it. 
     271 */ 
     272 
     273void AttachmentContainer::subAttachment( 
     274    const AttachmentObjPtr pAttachment, 
     275          UInt16           binding) 
     276{ 
     277    UInt32 key; 
     278 
     279    AttachmentObjPtrMapIt fcI; 
     280 
     281    if(pAttachment == NullFC) 
     282        return; 
     283 
     284    key = (UInt32(pAttachment->getGroupId()) << 16) | binding; 
     285 
     286    Self::editSField(AttachmentsFieldMask); 
     287 
     288    fcI = _sfAttachments.getValue().find(key); 
     289 
     290    if(fcI != _sfAttachments.getValue().end()) 
     291    { 
     292        (*fcI).second->subParent(this); 
     293 
     294        subRef((*fcI).second); 
     295 
     296        _sfAttachments.getValue().erase(fcI); 
     297    } 
     298} 
     299 
     300 
     301const AttachmentContainer::SFAttachmentObjPtrMap * 
     302    AttachmentContainer::getSFAttachments(void) const 
     303{ 
     304    return &_sfAttachments; 
     305} 
     306 
     307 
     308void AttachmentContainer::dump(      UInt32    uiIndent, 
     309                               const BitVector bvFlags ) const 
     310{ 
     311    indentLog(uiIndent, PLOG); 
     312    PLOG << "attachments " << std::endl; 
     313 
     314    indentLog(uiIndent, PLOG); 
     315    PLOG << "{" << std::endl; 
     316 
     317    indentLog(uiIndent, PLOG); 
     318    PLOG << "}" << std::endl; 
     319} 
     320 
     321 
     322/*-------------------------------------------------------------------------*/ 
     323/*                             Destructor                                  */ 
     324 
     325#ifdef OSG_MT_CPTR_ASPECT 
     326void AttachmentContainer::execSync( 
     327          AttachmentContainer *pFrom, 
     328          ConstFieldMaskArg    whichField, 
     329          AspectOffsetStore   &oOffsets, 
     330          ConstFieldMaskArg    syncMode  , 
     331    const UInt32               uiSyncInfo) 
     332{ 
     333    Inherited::execSync(pFrom, whichField, oOffsets, syncMode, uiSyncInfo); 
     334 
     335    if(FieldBits::NoField != (AttachmentsFieldMask & whichField)) 
     336    { 
     337        _sfAttachments.syncWith(pFrom->_sfAttachments); 
     338    } 
     339} 
     340#endif 
     341 
     342void AttachmentContainer::resolveLinks(void) 
     343{ 
     344    Inherited::resolveLinks(); 
     345 
     346    AttachmentObjPtrMapIt fcI = _sfAttachments.getValue().begin(); 
     347    AttachmentObjPtrMapIt fcE = _sfAttachments.getValue().end  (); 
     348 
     349    while(fcI != fcE) 
     350    { 
     351        (*fcI).second->subParent(this); 
     352 
     353        subRef((*fcI).second); 
     354 
     355        ++fcI; 
     356    } 
     357} 
     358 
     359 
     360 
     361 
    92362 
    93363/*-------------------------------------------------------------------------*/ 
  • trunk/Source/System/FieldContainer/Base/OSGAttachmentContainer.h

    r782 r824  
    4444 
    4545#include "OSGFieldContainer.h" 
    46 #include "OSGAttachmentContainerParent.h" 
    4746#include "OSGFieldContainerAttachment.h" 
     47#include "OSGAttachmentMapSFields.h" 
    4848 
    4949OSG_BEGIN_NAMESPACE 
    5050 
    5151/** 
    52 * An AttachmentContainer is a field container that can store attachments to other 
    53 * FieldContainers. 
     52* An AttachmentContainer is a field container that can store attachments to  
     53  other FieldContainers. 
    5454* \ingroup baselib 
    5555*/ 
    56 class OSG_SYSTEM_DLLMAPPING AttachmentContainer : 
    57     public ContainerAttachmentContainerParent 
     56class OSG_SYSTEM_DLLMAPPING AttachmentContainer : public FieldContainer 
    5857{ 
    5958    /*==========================  PUBLIC  =================================*/ 
     
    6564    /*! \{                                                                 */ 
    6665 
    67     typedef ContainerAttachmentContainerParent                  Inherited; 
     66    typedef FieldContainer                    Inherited; 
     67    typedef Inherited::TypeObject             TypeObject; 
     68    typedef AttachmentContainer               Self; 
     69 
     70    typedef FieldContainerAttachment          AttachmentObj; 
     71    typedef FieldContainerAttachmentPtr       AttachmentObjPtr; 
     72    typedef SFFieldContainerAttachmentPtrMap  SFAttachmentObjPtrMap; 
     73 
     74    typedef SFAttachmentObjPtrMap::StoredType AttachmentObjPtrMap; 
     75    typedef AttachmentObjPtrMap::iterator     AttachmentObjPtrMapIt; 
    6876 
    6977     
     
    8290    /*! \{                                                                 */ 
    8391 
     92    OSG_RC_FIRST_FIELD_DECL(Attachments); 
     93    OSG_RC_LAST_FIELD_DECL (Attachments); 
     94 
    8495    /*! \}                                                                 */ 
    8596    /*---------------------------------------------------------------------*/ 
     
    92103    /*! \{                                                                 */ 
    93104 
     105    virtual void pushToField     (      FieldContainerPtrConstArg pNewElement, 
     106                                  const UInt32                    uiFieldId  ); 
     107 
     108    virtual void insertIntoMField(const UInt32                    uiIndex, 
     109                                        FieldContainerPtrConstArg pNewElement, 
     110                                  const UInt32                    uiFieldId  ); 
     111 
     112    virtual void replaceInMField (const UInt32                    uiIndex, 
     113                                        FieldContainerPtrConstArg pNewElement, 
     114                                  const UInt32                    uiFieldId  ); 
     115 
     116    virtual void replaceInMField (      FieldContainerPtrConstArg pOldElement, 
     117                                        FieldContainerPtrConstArg pNewElement, 
     118                                  const UInt32                    uiFieldId  ); 
     119 
     120    virtual void removeFromMField(const UInt32                    uiIndex, 
     121                                  const UInt32                    whichField ); 
     122 
     123    virtual void removeFromMField(      FieldContainerPtrConstArg pElement, 
     124                                  const UInt32                    whichField ); 
     125 
     126    virtual void clearField      (const UInt32                    whichField ); 
     127     
    94128    /*! \}                                                                 */ 
    95129    /*---------------------------------------------------------------------*/ 
     
    97131    /*! \{                                                                 */ 
    98132 
     133    virtual UInt32 getBinSize (ConstFieldMaskArg   whichField); 
     134    virtual void   copyToBin  (BinaryDataHandler  &pMem, 
     135                               ConstFieldMaskArg   whichField); 
     136    virtual void   copyFromBin(BinaryDataHandler  &pMem, 
     137                               ConstFieldMaskArg   whichField); 
     138 
    99139    /*! \}                                                                 */ 
    100140    /*---------------------------------------------------------------------*/ 
     
    102142    /*! \{                                                                 */ 
    103143 
     144    void             addAttachment (const AttachmentObjPtr   attachmentP, 
     145                                          UInt16             binding    = 0); 
     146 
     147    void             subAttachment (const AttachmentObjPtr   attachmentP, 
     148                                          UInt16             binding    = 0); 
     149 
     150    AttachmentObjPtr findAttachment(      UInt32             groupId, 
     151                                          UInt16             binding    = 0); 
     152 
     153    AttachmentObjPtr findAttachment(const FieldContainerType &type, 
     154                                          UInt16              binding    = 0); 
     155 
    104156    /*! \}                                                                 */ 
    105157    /*---------------------------------------------------------------------*/ 
     
    107159    /*! \{                                                                 */ 
    108160 
     161    const SFAttachmentObjPtrMap *getSFAttachments(void) const; 
     162 
    109163    /*! \}                                                                 */ 
    110164    /*---------------------------------------------------------------------*/ 
     
    136190    /*! \name                        Dump                                  */ 
    137191    /*! \{                                                                 */ 
     192 
     193    virtual void dump(      UInt32    uiIndent = 0, 
     194                      const BitVector bvFlags  = 0) const; 
    138195 
    139196    /*! \}                                                                 */ 
     
    156213    /*! \{                                                                 */ 
    157214 
     215    SFAttachmentObjPtrMap _sfAttachments; 
     216 
    158217    /*! \}                                                                 */ 
    159218    /*---------------------------------------------------------------------*/ 
     
    171230    /*! \{                                                                 */ 
    172231 
     232#ifdef OSG_MT_CPTR_ASPECT 
     233    void execSync  (      AttachmentContainer *pFrom, 
     234                          ConstFieldMaskArg    whichField, 
     235                          AspectOffsetStore   &oOffsets, 
     236                          ConstFieldMaskArg    syncMode  , 
     237                    const UInt32               uiSyncInfo); 
     238#endif 
     239 
    173240    /*! \}                                                                 */ 
    174241    /*---------------------------------------------------------------------*/ 
    175242    /*! \name                   MT Destruction                             */ 
    176243    /*! \{                                                                 */ 
     244 
     245    virtual void resolveLinks(void); 
    177246 
    178247    /*! \}                                                                 */ 
  • trunk/Source/System/FieldContainer/Base/OSGAttachmentContainer.inl

    r785 r824  
    4545} 
    4646 
     47/** 
     48 * Find an attachment at the binding point. 
     49 * 
     50 * \param groupId  The Group id to search for 
     51 * \param binding  id that is combined with the groupId of the attachment 
     52 *                 to determine the slot in the attachment map. 
     53 * 
     54 * Attempt to find attachment in map using key (binding|groupId). 
     55 * If found, return it, else return NullFC 
     56 */ 
     57inline 
     58AttachmentContainer::AttachmentObjPtr 
     59    AttachmentContainer::findAttachment(UInt32 groupId, 
     60                                        UInt16 binding) 
     61{ 
     62    UInt32 key = (UInt32(groupId) << 16) | binding; 
     63 
     64    AttachmentObjPtrMapIt fcI = _sfAttachments.getValue().find(key); 
     65 
     66    if(fcI == _sfAttachments.getValue().end()) 
     67    { 
     68        return NullFC; 
     69    } 
     70    else 
     71    { 
     72        return (*fcI).second; 
     73    } 
     74} 
     75 
     76/** 
     77 * Find an attachment at the binding point. 
     78 * 
     79 * \param type     FCType used to get groupId 
     80 * \param binding  id that is combined with the groupId of the attachment 
     81 *                 to determine the slot in the attachment map. 
     82 * 
     83 * Attempt to find attachment in map using key (binding|groupId). 
     84 * If found, return it, else return NullFC 
     85 */ 
     86 
     87inline 
     88AttachmentContainer::AttachmentObjPtr 
     89    AttachmentContainer::findAttachment( 
     90        const FieldContainerType &type, 
     91              UInt16              binding) 
     92{ 
     93    return findAttachment(type.getGroupId(), binding); 
     94} 
     95 
    4796OSG_ABSTR_FIELD_CONTAINER_INL_DEF(AttachmentContainer) 
    4897