00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifdef OSG_DOC_FILES_IN_MODULE
00038
00041 #endif
00042
00043 #define OSG_COMPILEATTACHMENTINST
00044
00045 #include <stdlib.h>
00046 #include <stdio.h>
00047
00048 #include "OSGConfig.h"
00049
00050 #include "OSGAttachment.h"
00051 #include "OSGAttachmentContainer.h"
00052 #include "OSGNodePtr.h"
00053 #include "OSGNodeFields.h"
00054
00055 OSG_USING_NAMESPACE
00056
00057
00058 const BitVector
00059 Attachment::InternalFieldMask = (1 << Attachment::InternalFieldId);
00060 const BitVector
00061 Attachment::ParentsFieldMask = (1 << Attachment::ParentsFieldId);
00062
00063 FieldDescription *Attachment::_desc[] =
00064 {
00065 new FieldDescription(
00066 SFBool::getClassType(),
00067 "internal",
00068 OSG_FC_FIELD_IDM_DESC(InternalField),
00069 false,
00070 (FieldAccessMethod) &Attachment::getSFInternal,
00071 "true"),
00072
00073 new FieldDescription(
00074 MFNodePtr::getClassType(),
00075 "parents",
00076 OSG_FC_FIELD_IDM_DESC(ParentsField),
00077 true,
00078 (FieldAccessMethod) &Attachment::getMFParents,
00079 "test")
00080 };
00081
00082 FieldContainerType Attachment::_type("Attachment",
00083 "FieldContainer",
00084 NULL,
00085 NULL,
00086 NULL,
00087 _desc,
00088 sizeof(_desc));
00089
00090 OSG_FIELD_CONTAINER_DEF(Attachment, AttachmentPtr)
00091
00092
00093
00094
00095 MFFieldContainerPtr &Attachment::getParents(void)
00096 {
00097 return _parents;
00098 }
00099
00100 const MFFieldContainerPtr &Attachment::getParents(void) const
00101 {
00102 return _parents;
00103 }
00104
00105 MFFieldContainerPtr *Attachment::getMFParents(void)
00106 {
00107 return &_parents;
00108 }
00109
00110 void Attachment::addParent(FieldContainerPtr parent)
00111 {
00112 _parents.push_back(parent);
00113 }
00114
00115 void Attachment::subParent(FieldContainerPtr parent)
00116 {
00117 MFFieldContainerPtr::iterator parentIt = _parents.find(parent);
00118
00119 if(parentIt != _parents.end())
00120 {
00121 _parents.erase(parentIt);
00122 }
00123 }
00124
00125 Int32 Attachment::findParent(FieldContainerPtr parent)
00126 {
00127 MFFieldContainerPtr::iterator parentIt = _parents.find(parent);
00128
00129 if(parentIt != _parents.end())
00130 {
00131 return parentIt - _parents.begin();
00132 }
00133 else
00134 {
00135 return -1;
00136 }
00137 }
00138
00139
00140
00141
00142 SFBool &Attachment::getInternal(void)
00143 {
00144 return _sfInternal;
00145 }
00146
00147 const SFBool &Attachment::getInternal(void) const
00148 {
00149 return _sfInternal;
00150 }
00151
00152 SFBool *Attachment::getSFInternal(void)
00153 {
00154 return &_sfInternal;
00155 }
00156
00157 void Attachment::setInternal(bool bVal)
00158 {
00159 _sfInternal.setValue(bVal);
00160 }
00161
00162
00163
00164
00165 UInt32 Attachment::getBinSize(const BitVector &whichField)
00166 {
00167 UInt32 returnValue = 0;
00168
00169 if(FieldBits::NoField != (InternalFieldMask & whichField))
00170 {
00171 returnValue += _sfInternal.getBinSize();
00172 }
00173
00174 if(FieldBits::NoField != (ParentsFieldMask & whichField))
00175 {
00176 returnValue += _parents.getBinSize();
00177 }
00178
00179 return returnValue;
00180 }
00181
00182 void Attachment::copyToBin( BinaryDataHandler &pMem,
00183 const BitVector &whichField)
00184 {
00185 if(FieldBits::NoField != (InternalFieldMask & whichField))
00186 {
00187 _sfInternal.copyToBin(pMem);
00188 }
00189
00190 if(FieldBits::NoField != (ParentsFieldMask & whichField))
00191 {
00192 _parents.copyToBin(pMem);
00193 }
00194 }
00195
00196 void Attachment::copyFromBin( BinaryDataHandler &pMem,
00197 const BitVector &whichField)
00198 {
00199 if(FieldBits::NoField != (InternalFieldMask & whichField))
00200 {
00201 _sfInternal.copyFromBin(pMem);
00202 }
00203
00204 if(FieldBits::NoField != (ParentsFieldMask & whichField))
00205 {
00206 _parents.copyFromBin(pMem);
00207 }
00208 }
00209
00210
00211
00212
00213 void Attachment::dump( UInt32 uiIndent,
00214 const BitVector OSG_CHECK_ARG(bvFlags)) const
00215 {
00216 UInt32 i;
00217
00218 AttachmentPtr thisP(this);
00219
00220 indentLog(uiIndent, PLOG);
00221
00222 PLOG << "Attachment"
00223 << "("
00224 << std::dec
00225 << thisP.getFieldContainerId()
00226 << ") : "
00227 << getType().getName()
00228 << "("
00229 << this
00230 << ")"
00231 << std::endl;
00232
00233 indentLog(uiIndent, PLOG);
00234 PLOG << "[" << std::endl;
00235
00236 indentLog(uiIndent + 4, PLOG);
00237 PLOG << "Parents : " << std::endl;
00238
00239 for(i = 0; i < _parents.size(); i++)
00240 {
00241 indentLog(uiIndent + 4, PLOG);
00242 PLOG << " " << i << ") " << &(*(_parents[i])) << std::endl;
00243 }
00244
00245
00246
00247 indentLog(uiIndent, PLOG);
00248 PLOG << "]" << std::endl;
00249
00250 indentLog(uiIndent, PLOG);
00251 PLOG << "{" << std::endl;
00252
00253 indentLog(uiIndent, PLOG);
00254 PLOG << "}" << std::endl;
00255 }
00256
00257
00258
00259
00260 Attachment::Attachment(void) :
00261 Inherited ( ),
00262 _sfInternal(false),
00263 _parents ( )
00264 {
00265 }
00266
00267 Attachment::Attachment(const Attachment &obj) :
00268 Inherited (obj ),
00269 _sfInternal(obj._sfInternal),
00270 _parents ( )
00271 {
00272 }
00273
00274
00275
00276
00277 Attachment::~Attachment(void)
00278 {
00279 }
00280
00281
00282
00283
00284
00285 void Attachment::onDestroy(void)
00286 {
00287 }
00288
00289 #if defined(OSG_FIXED_MFIELDSYNC)
00290 void Attachment::onDestroyAspect(UInt32 uiId, UInt32 uiAspect)
00291 {
00292 _parents.terminateShare(uiAspect, this->getContainerSize());
00293 }
00294 #endif
00295
00296
00297
00298
00299 #if !defined(OSG_FIXED_MFIELDSYNC)
00300 void Attachment::executeSync( FieldContainer &other,
00301 const BitVector &whichField)
00302 {
00303 this->executeSyncImpl(static_cast<Attachment *>(&other), whichField);
00304 }
00305
00306 void Attachment::executeSyncImpl( Attachment *pOther,
00307 const BitVector &whichField)
00308 {
00309 Inherited::executeSyncImpl(pOther, whichField);
00310
00311 if(FieldBits::NoField != (InternalFieldMask & whichField))
00312 {
00313 _sfInternal.syncWith(pOther->_sfInternal);
00314 }
00315
00316 if(FieldBits::NoField != (ParentsFieldMask & whichField))
00317 {
00318 _parents.syncWith(pOther->_parents);
00319 }
00320 }
00321 #else
00322 void Attachment::executeSync( FieldContainer &other,
00323 const BitVector &whichField,
00324 const SyncInfo &sInfo )
00325 {
00326 this->executeSyncImpl(static_cast<Attachment *>(&other),
00327 whichField,
00328 sInfo);
00329 }
00330
00331 void Attachment::executeSyncImpl( Attachment *pOther,
00332 const BitVector &whichField,
00333 const SyncInfo &sInfo)
00334 {
00335 Inherited::executeSyncImpl(pOther, whichField, sInfo);
00336
00337 if(FieldBits::NoField != (InternalFieldMask & whichField))
00338 {
00339 _sfInternal.syncWith(pOther->_sfInternal);
00340 }
00341
00342 if(FieldBits::NoField != (ParentsFieldMask & whichField))
00343 {
00344 _parents.syncWith(pOther->_parents, sInfo);
00345 }
00346 }
00347
00348 void Attachment::execBeginEditImpl (const BitVector &whichField,
00349 UInt32 uiAspect,
00350 UInt32 uiContainerSize)
00351 {
00352 Inherited::execBeginEditImpl(whichField, uiAspect, uiContainerSize);
00353
00354 if (FieldBits::NoField != (ParentsFieldMask & whichField))
00355 {
00356 _parents.beginEdit(uiAspect, uiContainerSize);
00357 }
00358 }
00359
00360 void Attachment::execBeginEdit(const BitVector &whichField,
00361 UInt32 uiAspect,
00362 UInt32 uiContainerSize)
00363 {
00364 this->execBeginEditImpl(whichField, uiAspect, uiContainerSize);
00365 }
00366 #endif
00367
00368 OSG_SYSTEMLIB_DLLMAPPING
00369 std::ostream &OSG::operator <<( std::ostream &stream,
00370 const AttachmentMap &OSG_CHECK_ARG(amap))
00371 {
00372 stream << "Attachment << NI" << std::endl;
00373
00374 return stream;
00375 }
00376
00377
00378
00379
00380
00381
00382 #ifdef __sgi
00383 #pragma set woff 1174
00384 #endif
00385
00386 #ifdef OSG_LINUX_ICC
00387 #pragma warning( disable : 177 )
00388 #endif
00389 namespace
00390 {
00391 static Char8 cvsid_cpp[] = "@(#)$Id: $";
00392 static Char8 cvsid_hpp[] = OSGATTACHMENT_HEADER_CVSID;
00393 static Char8 cvsid_inl[] = OSGATTACHMENT_INLINE_CVSID;
00394 }