| 69 | | Field::SFDefaultFlags, |
|---|
| 70 | | static_cast<FieldEditMethodSig>(&Self::editHandleAttachments), |
|---|
| 71 | | static_cast<FieldGetMethodSig >(&Self::getHandleAttachments ) ); |
|---|
| | 71 | Field::MFDefaultFlags, |
|---|
| | 72 | static_cast<FieldEditMethodSig>(&AttachmentContainer::editHandleAttachments), |
|---|
| | 73 | static_cast<FieldGetMethodSig >(&AttachmentContainer::getHandleAttachments ) ); |
|---|
| | 74 | |
|---|
| | 75 | oType.addInitialDesc(pDesc); |
|---|
| | 76 | |
|---|
| | 77 | |
|---|
| | 78 | pDesc = new MFUInt32::Description( |
|---|
| | 79 | MFUInt32::getClassType(), |
|---|
| | 80 | "attachmentBindings", |
|---|
| | 81 | "Binding Ids used by the attachments.", |
|---|
| | 82 | OSG_RC_FIELD_DESC(AttachmentContainer::AttachmentBindings), |
|---|
| | 83 | true, |
|---|
| | 84 | Field::MFDefaultFlags, |
|---|
| | 85 | static_cast<FieldEditMethodSig>(&AttachmentContainer::editHandleAttachmentBindings), |
|---|
| | 86 | static_cast<FieldGetMethodSig >(&AttachmentContainer::getHandleAttachmentBindings ) ); |
|---|
| 113 | | #if 0 |
|---|
| 114 | | void AttachmentContainer::pushToField( |
|---|
| 115 | | FieldContainerPtrConstArg pNewElement, |
|---|
| 116 | | const UInt32 uiFieldId ) |
|---|
| 117 | | { |
|---|
| 118 | | Inherited::pushToField(pNewElement, uiFieldId); |
|---|
| 119 | | |
|---|
| 120 | | if(uiFieldId == AttachmentsFieldId) |
|---|
| 121 | | { |
|---|
| 122 | | addAttachment(dynamic_cast<AttachmentObjPtr>(pNewElement)); |
|---|
| 123 | | } |
|---|
| 124 | | } |
|---|
| 125 | | |
|---|
| 126 | | void AttachmentContainer::insertIntoMField( |
|---|
| 127 | | const UInt32 uiIndex, |
|---|
| 128 | | FieldContainerPtrConstArg pNewElement, |
|---|
| 129 | | const UInt32 uiFieldId ) |
|---|
| 130 | | { |
|---|
| 131 | | Inherited::insertIntoMField(uiIndex, pNewElement, uiFieldId); |
|---|
| 132 | | |
|---|
| 133 | | FWARNING(("AttachmentContainerMixin::insertIntoMField: NIY\n")); |
|---|
| 134 | | } |
|---|
| 135 | | |
|---|
| 136 | | void AttachmentContainer::replaceInMField ( |
|---|
| 137 | | const UInt32 uiIndex, |
|---|
| 138 | | FieldContainerPtrConstArg pNewElement, |
|---|
| 139 | | const UInt32 uiFieldId ) |
|---|
| 140 | | { |
|---|
| 141 | | Inherited::replaceInMField(uiIndex, pNewElement, uiFieldId); |
|---|
| 142 | | |
|---|
| 143 | | FWARNING(("AttachmentContainerMixin::replaceInMField: NIY\n")); |
|---|
| 144 | | } |
|---|
| 145 | | |
|---|
| 146 | | void AttachmentContainer::replaceInMField ( |
|---|
| 147 | | FieldContainerPtrConstArg pOldElement, |
|---|
| 148 | | FieldContainerPtrConstArg pNewElement, |
|---|
| 149 | | const UInt32 uiFieldId ) |
|---|
| 150 | | { |
|---|
| 151 | | Inherited::replaceInMField(pOldElement, pNewElement, uiFieldId); |
|---|
| 152 | | |
|---|
| 153 | | FWARNING(("AttachmentContainerMixin::replaceInMField: NIY\n")); |
|---|
| 154 | | } |
|---|
| 155 | | |
|---|
| 156 | | void AttachmentContainer::removeFromMField( |
|---|
| 157 | | const UInt32 uiIndex, |
|---|
| 158 | | const UInt32 uiFieldId ) |
|---|
| 159 | | { |
|---|
| 160 | | Inherited::removeFromMField(uiIndex, uiFieldId); |
|---|
| 161 | | |
|---|
| 162 | | FWARNING(("AttachmentContainerMixin::removeFromMField: NIY\n")); |
|---|
| 163 | | } |
|---|
| 164 | | |
|---|
| 165 | | void AttachmentContainer::removeFromMField( |
|---|
| 166 | | FieldContainerPtrConstArg pElement, |
|---|
| 167 | | const UInt32 uiFieldId ) |
|---|
| 168 | | { |
|---|
| 169 | | Inherited::removeFromMField(pElement, uiFieldId); |
|---|
| 170 | | |
|---|
| 171 | | FWARNING(("AttachmentContainerMixin::removeFromMField: NIY\n")); |
|---|
| 172 | | } |
|---|
| 173 | | |
|---|
| 174 | | void AttachmentContainer::clearField(const UInt32 uiFieldId) |
|---|
| 175 | | { |
|---|
| 176 | | Inherited::clearField(uiFieldId); |
|---|
| 177 | | |
|---|
| 178 | | FWARNING(("AttachmentContainerMixin::clearField: NIY\n")); |
|---|
| 179 | | } |
|---|
| 180 | | #endif |
|---|
| 181 | | |
|---|
| 191 | | returnValue += _sfAttachments.getBinSize(); |
|---|
| | 148 | AttachmentsFieldType::const_iterator aI = _mfAttachments.begin(); |
|---|
| | 149 | AttachmentsFieldType::const_iterator aE = _mfAttachments.end (); |
|---|
| | 150 | |
|---|
| | 151 | UInt32 numPublicObjects = 0; |
|---|
| | 152 | |
|---|
| | 153 | for(; aI != aE; ++aI) |
|---|
| | 154 | { |
|---|
| | 155 | if((*aI)->getInternal().getValue() == false) |
|---|
| | 156 | ++numPublicObjects; |
|---|
| | 157 | } |
|---|
| | 158 | |
|---|
| | 159 | // number of objects + (binding + id) for each |
|---|
| | 160 | return sizeof(UInt32) + |
|---|
| | 161 | numPublicObjects * (sizeof(UInt16) + sizeof(UInt32)); |
|---|
| | 162 | } |
|---|
| | 163 | |
|---|
| | 164 | if(FieldBits::NoField != (AttachmentBindingsFieldMask & whichField)) |
|---|
| | 165 | { |
|---|
| | 166 | return returnValue += _mfAttachmentBindings.getBinSize(); |
|---|
| 204 | | _sfAttachments.copyToBin(pMem); |
|---|
| | 179 | AttachmentsFieldType::const_iterator aI = _mfAttachments.begin(); |
|---|
| | 180 | AttachmentsFieldType::const_iterator aE = _mfAttachments.end (); |
|---|
| | 181 | |
|---|
| | 182 | UInt32 numPublicObjects = 0; |
|---|
| | 183 | UInt32 containerId; |
|---|
| | 184 | UInt16 binding; |
|---|
| | 185 | |
|---|
| | 186 | for(; aI != aE; ++aI) |
|---|
| | 187 | { |
|---|
| | 188 | if((*aI)->getInternal().getValue() == false) |
|---|
| | 189 | ++numPublicObjects; |
|---|
| | 190 | } |
|---|
| | 191 | |
|---|
| | 192 | pMem.putValue(numPublicObjects); |
|---|
| | 193 | |
|---|
| | 194 | aI = _mfAttachments.begin(); |
|---|
| | 195 | aE = _mfAttachments.end (); |
|---|
| | 196 | |
|---|
| | 197 | AttachmentBindingsFieldType::const_iterator bI = |
|---|
| | 198 | _mfAttachmentBindings.begin(); |
|---|
| | 199 | AttachmentBindingsFieldType::const_iterator bE = |
|---|
| | 200 | _mfAttachmentBindings.end (); |
|---|
| | 201 | |
|---|
| | 202 | for(; aI != aE; ++aI, ++bI) |
|---|
| | 203 | { |
|---|
| | 204 | binding = UInt16(*bI & 0x0000FFFF); |
|---|
| | 205 | containerId = getContainerId(*aI); |
|---|
| | 206 | |
|---|
| | 207 | pMem.putValue(binding ); |
|---|
| | 208 | pMem.putValue(containerId); |
|---|
| | 209 | } |
|---|
| | 210 | } |
|---|
| | 211 | |
|---|
| | 212 | if(FieldBits::NoField != (AttachmentBindingsFieldMask & whichField)) |
|---|
| | 213 | { |
|---|
| | 214 | _mfAttachmentBindings.copyToBin(pMem); |
|---|
| 215 | | _sfAttachments.copyFromBin(pMem); |
|---|
| | 225 | UInt32 numObjects = 0; |
|---|
| | 226 | UInt32 containerId; |
|---|
| | 227 | UInt16 binding; |
|---|
| | 228 | |
|---|
| | 229 | pMem.getValue(numObjects); |
|---|
| | 230 | |
|---|
| | 231 | for(UInt32 i = 0; i < numObjects; ++i) |
|---|
| | 232 | { |
|---|
| | 233 | pMem.getValue(binding ); |
|---|
| | 234 | pMem.getValue(containerId); |
|---|
| | 235 | |
|---|
| | 236 | FieldContainerAttachmentPtr pAtt = |
|---|
| | 237 | dynamic_cast<FieldContainerAttachmentPtr>( |
|---|
| | 238 | FieldContainerFactory::the()->getMappedContainer(containerId)); |
|---|
| | 239 | |
|---|
| | 240 | addAttachment(pAtt, binding); |
|---|
| | 241 | } |
|---|
| | 242 | } |
|---|
| | 243 | |
|---|
| | 244 | if(FieldBits::NoField != (AttachmentBindingsFieldMask & whichField)) |
|---|
| | 245 | { |
|---|
| | 246 | _mfAttachmentBindings.copyFromBin(pMem); |
|---|
| 241 | | |
|---|
| 242 | | key = (UInt32 (pAttachment->getGroupId()) << 16) | binding; |
|---|
| 243 | | |
|---|
| 244 | | addRef(pAttachment); |
|---|
| 245 | | |
|---|
| 246 | | pAttachment->addParent(this); |
|---|
| 247 | | |
|---|
| 248 | | Self::editSField(AttachmentsFieldMask); |
|---|
| 249 | | |
|---|
| 250 | | AttachmentObjPtrMapIt fcI = _sfAttachments.getValue().find(key); |
|---|
| 251 | | |
|---|
| 252 | | if(fcI != _sfAttachments.getValue().end()) |
|---|
| 253 | | { |
|---|
| 254 | | (*fcI).second->subParent(this); |
|---|
| 255 | | |
|---|
| 256 | | subRef((*fcI).second); |
|---|
| 257 | | |
|---|
| 258 | | (*fcI).second = pAttachment; |
|---|
| | 270 | |
|---|
| | 271 | UInt32 key = (UInt32(pAttachment->getGroupId()) << 16) | binding; |
|---|
| | 272 | |
|---|
| | 273 | Self::editMField(AttachmentsFieldMask, _mfAttachments ); |
|---|
| | 274 | Self::editMField(AttachmentBindingsFieldMask, _mfAttachmentBindings); |
|---|
| | 275 | |
|---|
| | 276 | MFUInt32::iterator bI = |
|---|
| | 277 | std::find(_mfAttachmentBindings.begin(), |
|---|
| | 278 | _mfAttachmentBindings.end (), key); |
|---|
| | 279 | |
|---|
| | 280 | if(bI != _mfAttachmentBindings.end()) |
|---|
| | 281 | { |
|---|
| | 282 | _mfAttachments[std::distance(_mfAttachmentBindings.begin(), bI)] = |
|---|
| | 283 | pAttachment; |
|---|
| 287 | | |
|---|
| 288 | | key = (UInt32(pAttachment->getGroupId()) << 16) | binding; |
|---|
| 289 | | |
|---|
| 290 | | Self::editSField(AttachmentsFieldMask); |
|---|
| 291 | | |
|---|
| 292 | | fcI = _sfAttachments.getValue().find(key); |
|---|
| 293 | | |
|---|
| 294 | | if(fcI != _sfAttachments.getValue().end()) |
|---|
| 295 | | { |
|---|
| 296 | | (*fcI).second->subParent(this); |
|---|
| 297 | | |
|---|
| 298 | | subRef((*fcI).second); |
|---|
| 299 | | |
|---|
| 300 | | _sfAttachments.getValue().erase(fcI); |
|---|
| 301 | | } |
|---|
| 302 | | } |
|---|
| 303 | | |
|---|
| 304 | | |
|---|
| 305 | | const AttachmentContainer::SFAttachmentObjPtrMap * |
|---|
| 306 | | AttachmentContainer::getSFAttachments(void) const |
|---|
| 307 | | { |
|---|
| 308 | | return &_sfAttachments; |
|---|
| 309 | | } |
|---|
| 310 | | |
|---|
| | 309 | |
|---|
| | 310 | UInt32 key = (UInt32(pAttachment->getGroupId()) << 16) | binding; |
|---|
| | 311 | |
|---|
| | 312 | Self::editMField(AttachmentsFieldMask, _mfAttachments ); |
|---|
| | 313 | Self::editMField(AttachmentBindingsFieldMask, _mfAttachmentBindings); |
|---|
| | 314 | |
|---|
| | 315 | MFUInt32::iterator bI = |
|---|
| | 316 | std::find(_mfAttachmentBindings.begin(), |
|---|
| | 317 | _mfAttachmentBindings.end (), key); |
|---|
| | 318 | |
|---|
| | 319 | if(bI != _mfAttachmentBindings.end()) |
|---|
| | 320 | { |
|---|
| | 321 | _mfAttachments.erase( |
|---|
| | 322 | _mfAttachments.begin() + |
|---|
| | 323 | std::distance(_mfAttachmentBindings.begin(), bI)); |
|---|
| | 324 | _mfAttachmentBindings.erase(bI); |
|---|
| | 325 | } |
|---|
| | 326 | } |
|---|
| | 327 | |
|---|
| | 328 | |
|---|
| | 329 | MFFieldContainerAttachmentChildPtr const * |
|---|
| | 330 | AttachmentContainer::getMFAttachments(void) const |
|---|
| | 331 | { |
|---|
| | 332 | return &_mfAttachments; |
|---|
| | 333 | } |
|---|
| | 334 | |
|---|
| | 335 | MFFieldContainerAttachmentChildPtr const & |
|---|
| | 336 | AttachmentContainer::getAttachments(void) const |
|---|
| | 337 | { |
|---|
| | 338 | return _mfAttachments; |
|---|
| | 339 | } |
|---|
| | 340 | |
|---|
| | 341 | MFUInt32 const * |
|---|
| | 342 | AttachmentContainer::getMFAttachmentBindings(void) const |
|---|
| | 343 | { |
|---|
| | 344 | return &_mfAttachmentBindings; |
|---|
| | 345 | } |
|---|
| | 346 | |
|---|
| | 347 | MFUInt32 const & |
|---|
| | 348 | AttachmentContainer::getAttachmentBindings(void) const |
|---|
| | 349 | { |
|---|
| | 350 | return _mfAttachmentBindings; |
|---|
| | 351 | } |
|---|
| 390 | | |
|---|
| 391 | | |
|---|
| | 431 | EditFieldHandlePtr |
|---|
| | 432 | AttachmentContainer::editHandleAttachmentBindings(void) |
|---|
| | 433 | { |
|---|
| | 434 | AttachmentBindingsFieldType::EditHandlePtr returnValue( |
|---|
| | 435 | new AttachmentBindingsFieldType::EditHandle( |
|---|
| | 436 | &_mfAttachmentBindings, |
|---|
| | 437 | this->getType().getFieldDesc(AttachmentBindingsFieldId))); |
|---|
| | 438 | |
|---|
| | 439 | editMField(AttachmentBindingsFieldMask, _mfAttachmentBindings); |
|---|
| | 440 | |
|---|
| | 441 | return returnValue; |
|---|
| | 442 | } |
|---|
| | 443 | |
|---|
| | 444 | GetFieldHandlePtr |
|---|
| | 445 | AttachmentContainer::getHandleAttachmentBindings(void) const |
|---|
| | 446 | { |
|---|
| | 447 | AttachmentBindingsFieldType::GetHandlePtr returnValue( |
|---|
| | 448 | new AttachmentBindingsFieldType::GetHandle( |
|---|
| | 449 | &_mfAttachmentBindings, |
|---|
| | 450 | this->getType().getFieldDesc(AttachmentBindingsFieldId))); |
|---|
| | 451 | |
|---|
| | 452 | return returnValue; |
|---|
| | 453 | } |
|---|
| 521 | | const SFFieldContainerAttachmentPtrMap *pAttMap = |
|---|
| 522 | | src->getSFAttachments(); |
|---|
| 523 | | |
|---|
| 524 | | FieldContainerAttachmentMap::const_iterator mapIt = |
|---|
| 525 | | pAttMap->getValue().begin(); |
|---|
| 526 | | |
|---|
| 527 | | FieldContainerAttachmentMap::const_iterator mapEnd = |
|---|
| 528 | | pAttMap->getValue().end(); |
|---|
| 529 | | |
|---|
| 530 | | for(; mapIt != mapEnd; ++mapIt) |
|---|
| 531 | | { |
|---|
| 532 | | FieldContainerAttachmentRefPtr att(mapIt->second); |
|---|
| 533 | | UInt16 uiBinding = UInt16(mapIt->first & |
|---|
| 534 | | 0x0000FFFF ); |
|---|
| 535 | | |
|---|
| | 583 | AttachmentContainer::AttachmentsFieldType::const_iterator attI = |
|---|
| | 584 | src->getMFAttachments()->begin(); |
|---|
| | 585 | AttachmentContainer::AttachmentsFieldType::const_iterator attE = |
|---|
| | 586 | src->getMFAttachments()->end(); |
|---|
| | 587 | |
|---|
| | 588 | AttachmentContainer::AttachmentBindingsFieldType::const_iterator bindI = |
|---|
| | 589 | src->getMFAttachmentBindings()->begin(); |
|---|
| | 590 | AttachmentContainer::AttachmentBindingsFieldType::const_iterator bindE = |
|---|
| | 591 | src->getMFAttachmentBindings()->end(); |
|---|
| | 592 | |
|---|
| | 593 | for(; attI != attE; ++attI, bindI) |
|---|
| | 594 | { |
|---|
| | 595 | FieldContainerAttachmentRefPtr att (*attI ); |
|---|
| | 596 | UInt16 uiBind(*bindI & 0x0000FFFF); |
|---|
| | 597 | |
|---|
| 693 | | const SFFieldContainerAttachmentPtrMap *pAttMap = |
|---|
| 694 | | src->getSFAttachments(); |
|---|
| 695 | | |
|---|
| 696 | | FieldContainerAttachmentMap::const_iterator mapIt = |
|---|
| 697 | | pAttMap->getValue().begin(); |
|---|
| 698 | | |
|---|
| 699 | | FieldContainerAttachmentMap::const_iterator mapEnd = |
|---|
| 700 | | pAttMap->getValue().end(); |
|---|
| 701 | | |
|---|
| 702 | | for(; mapIt != mapEnd; ++mapIt) |
|---|
| 703 | | { |
|---|
| 704 | | FieldContainerAttachmentRefPtr att(mapIt->second); |
|---|
| 705 | | UInt16 uiBinding = UInt16(mapIt->first & |
|---|
| 706 | | 0x0000FFFF ); |
|---|
| 707 | | |
|---|
| | 755 | AttachmentContainer::AttachmentsFieldType::const_iterator attI = |
|---|
| | 756 | src->getMFAttachments()->begin(); |
|---|
| | 757 | AttachmentContainer::AttachmentsFieldType::const_iterator attE = |
|---|
| | 758 | src->getMFAttachments()->end(); |
|---|
| | 759 | |
|---|
| | 760 | AttachmentContainer::AttachmentBindingsFieldType::const_iterator bindI = |
|---|
| | 761 | src->getMFAttachmentBindings()->begin(); |
|---|
| | 762 | AttachmentContainer::AttachmentBindingsFieldType::const_iterator bindE = |
|---|
| | 763 | src->getMFAttachmentBindings()->end(); |
|---|
| | 764 | |
|---|
| | 765 | for(; attI != attE; ++attI, bindI) |
|---|
| | 766 | { |
|---|
| | 767 | FieldContainerAttachmentRefPtr att (*attI ); |
|---|
| | 768 | UInt16 uiBind(*bindI & 0x0000FFFF); |
|---|
| | 769 | |
|---|