Changeset 824
- Timestamp:
- 07/04/07 00:15:36 (1 year ago)
- Files:
-
- trunk/Source/System/FieldContainer/Base/OSGAttachmentContainer.cpp (modified) (3 diffs)
- trunk/Source/System/FieldContainer/Base/OSGAttachmentContainer.h (modified) (10 diffs)
- trunk/Source/System/FieldContainer/Base/OSGAttachmentContainer.inl (modified) (1 diff)
- trunk/Source/System/FieldContainer/Base/OSGAttachmentContainerParent.h (deleted)
- trunk/Source/System/FieldContainer/Mixins/OSGAttachmentContainerMixin.h (deleted)
- trunk/Source/System/FieldContainer/Mixins/OSGAttachmentContainerMixin.inl (deleted)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Source/System/FieldContainer/Base/OSGAttachmentContainer.cpp
r782 r824 53 53 void AttachmentContainer::classDescInserter(TypeObject &oType) 54 54 { 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); 56 71 } 57 72 … … 71 86 72 87 AttachmentContainer::AttachmentContainer(void) : 73 Inherited() 88 Inherited (), 89 _sfAttachments() 74 90 { 75 91 } 76 92 77 93 AttachmentContainer::AttachmentContainer(const AttachmentContainer &source) : 78 Inherited(source) 94 Inherited (source ), 95 _sfAttachments(source._sfAttachments) 79 96 { 80 97 } … … 90 107 91 108 OSG_ABSTR_FIELD_CONTAINER_DEF(AttachmentContainer) 109 110 111 void 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 123 void 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 133 void 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 143 void 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 153 void 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 162 void AttachmentContainer::removeFromMField( 163 FieldContainerPtrConstArg pElement, 164 const UInt32 uiFieldId ) 165 { 166 Inherited::removeFromMField(pElement, uiFieldId); 167 168 FWARNING(("AttachmentContainerMixin::removeFromMField: NIY\n")); 169 } 170 171 void AttachmentContainer::clearField(const UInt32 uiFieldId) 172 { 173 Inherited::clearField(uiFieldId); 174 175 FWARNING(("AttachmentContainerMixin::clearField: NIY\n")); 176 } 177 178 /*-------------------------------------------------------------------------*/ 179 /* Binary access */ 180 181 UInt32 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 193 void 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 204 void 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 229 void 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 273 void 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 301 const AttachmentContainer::SFAttachmentObjPtrMap * 302 AttachmentContainer::getSFAttachments(void) const 303 { 304 return &_sfAttachments; 305 } 306 307 308 void 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 326 void 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 342 void 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 92 362 93 363 /*-------------------------------------------------------------------------*/ trunk/Source/System/FieldContainer/Base/OSGAttachmentContainer.h
r782 r824 44 44 45 45 #include "OSGFieldContainer.h" 46 #include "OSGAttachmentContainerParent.h"47 46 #include "OSGFieldContainerAttachment.h" 47 #include "OSGAttachmentMapSFields.h" 48 48 49 49 OSG_BEGIN_NAMESPACE 50 50 51 51 /** 52 * An AttachmentContainer is a field container that can store attachments to other53 *FieldContainers.52 * An AttachmentContainer is a field container that can store attachments to 53 other FieldContainers. 54 54 * \ingroup baselib 55 55 */ 56 class OSG_SYSTEM_DLLMAPPING AttachmentContainer : 57 public ContainerAttachmentContainerParent 56 class OSG_SYSTEM_DLLMAPPING AttachmentContainer : public FieldContainer 58 57 { 59 58 /*========================== PUBLIC =================================*/ … … 65 64 /*! \{ */ 66 65 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; 68 76 69 77 … … 82 90 /*! \{ */ 83 91 92 OSG_RC_FIRST_FIELD_DECL(Attachments); 93 OSG_RC_LAST_FIELD_DECL (Attachments); 94 84 95 /*! \} */ 85 96 /*---------------------------------------------------------------------*/ … … 92 103 /*! \{ */ 93 104 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 94 128 /*! \} */ 95 129 /*---------------------------------------------------------------------*/ … … 97 131 /*! \{ */ 98 132 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 99 139 /*! \} */ 100 140 /*---------------------------------------------------------------------*/ … … 102 142 /*! \{ */ 103 143 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 104 156 /*! \} */ 105 157 /*---------------------------------------------------------------------*/ … … 107 159 /*! \{ */ 108 160 161 const SFAttachmentObjPtrMap *getSFAttachments(void) const; 162 109 163 /*! \} */ 110 164 /*---------------------------------------------------------------------*/ … … 136 190 /*! \name Dump */ 137 191 /*! \{ */ 192 193 virtual void dump( UInt32 uiIndent = 0, 194 const BitVector bvFlags = 0) const; 138 195 139 196 /*! \} */ … … 156 213 /*! \{ */ 157 214 215 SFAttachmentObjPtrMap _sfAttachments; 216 158 217 /*! \} */ 159 218 /*---------------------------------------------------------------------*/ … … 171 230 /*! \{ */ 172 231 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 173 240 /*! \} */ 174 241 /*---------------------------------------------------------------------*/ 175 242 /*! \name MT Destruction */ 176 243 /*! \{ */ 244 245 virtual void resolveLinks(void); 177 246 178 247 /*! \} */ trunk/Source/System/FieldContainer/Base/OSGAttachmentContainer.inl
r785 r824 45 45 } 46 46 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 */ 57 inline 58 AttachmentContainer::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 87 inline 88 AttachmentContainer::AttachmentObjPtr 89 AttachmentContainer::findAttachment( 90 const FieldContainerType &type, 91 UInt16 binding) 92 { 93 return findAttachment(type.getGroupId(), binding); 94 } 95 47 96 OSG_ABSTR_FIELD_CONTAINER_INL_DEF(AttachmentContainer) 48 97
