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 #ifndef _OSGATTACHMENTIMPL_INL_
00038 #define _OSGATTACHMENTIMPL_INL_
00039
00040 #ifdef OSG_DOC_FILES_IN_MODULE
00041
00044 #endif
00045
00046 #include <stdlib.h>
00047 #include <stdio.h>
00048
00049 #include "OSGConfig.h"
00050
00051 #include <OSGFieldFactory.h>
00052 #include "OSGBinaryDataHandler.h"
00053
00054 OSG_BEGIN_NAMESPACE
00055
00056 OSG_FIELD_CONTAINER_INL_DEF(Attachment, AttachmentPtr)
00057
00058 #if defined(__hpux)
00059 template <class AttachmentDescT>
00060 const BitVector SimpleAttachment<AttachmentDescT>::SimpleFieldMask;
00061 #endif
00062
00063
00064
00065
00066 template <class AttachmentDescT>
00067 FieldDescription *SimpleAttachment<AttachmentDescT>::_desc[] =
00068 {
00069 new FieldDescription(
00070 StoredFieldType::getClassType(),
00071 AttachmentDescT::getFieldName(),
00072 OSG_FC_FIELD_IDM_DESC(SimpleField),
00073 false,
00074 (FieldAccessMethod) &SimpleAttachment<AttachmentDescT>::getFieldPtr,
00075 NULL)
00076 };
00077
00078 #if 0
00079 #if 1
00080 #if 1//defined(OSG_MICROSOFT_COMPILER_ALERT)
00081 template <class AttachmentDescT>
00082 FieldContainerType SimpleAttachment<AttachmentDescT>::_type =
00083 FieldContainerType(
00084 AttachmentDescT::getTypeName(),
00085 "Attachment",
00086 AttachmentDescT::getGroupName(),
00087 (PrototypeCreateF) &SimpleAttachment<
00088 AttachmentDescT>::createEmpty,
00089 AttachmentDescT::getInitMethod(),
00090 _desc,
00091 sizeof(FieldDescription *));
00092 #else
00093 template <class AttachmentDescT>
00094 FieldContainerType SimpleAttachment<AttachmentDescT>::_type(
00095 AttachmentDescT::getTypeName(),
00096 "Attachment",
00097 AttachmentDescT::getGroupName(),
00098 (PrototypeCreateF) &SimpleAttachment<
00099 AttachmentDescT>::createEmpty,
00100 AttachmentDescT::getInitMethod(),
00101 AttachmentDescT::getDesc(),
00102 sizeof(FieldDescription *));
00103 #endif
00104 #endif
00105 #endif
00106
00107 OSG_FIELD_CONTAINER_INL_TMPL_DEF(SimpleAttachment,
00108 AttachmentDescT,
00109 PtrType)
00110
00111
00112
00113
00114
00115
00118 template <class AttachmentDescT> inline
00119 typename SimpleAttachment<AttachmentDescT>::StoredFieldType *
00120 SimpleAttachment<AttachmentDescT>::getFieldPtr(void)
00121 {
00122 return &_field;
00123 }
00124
00128 template <class AttachmentDescT> inline
00129 typename SimpleAttachment<AttachmentDescT>::StoredFieldType &
00130 SimpleAttachment<AttachmentDescT>::getField(void)
00131 {
00132 return _field;
00133 }
00134
00138 template <class AttachmentDescT> inline
00139 const typename SimpleAttachment<AttachmentDescT>::StoredFieldType &
00140 SimpleAttachment<AttachmentDescT>::getField(void) const
00141 {
00142 return _field;
00143 }
00144
00145
00146
00147
00148 template <class AttachmentDescT> inline
00149 UInt32 SimpleAttachment<AttachmentDescT>::getBinSize(
00150 const BitVector &whichField)
00151 {
00152 UInt32 returnValue = Inherited::getBinSize(whichField);
00153
00154 if(FieldBits::NoField != (SimpleFieldMask & whichField))
00155 {
00156 returnValue += _field.getBinSize();
00157 }
00158
00159 return returnValue;
00160 }
00161
00162 template <class AttachmentDescT> inline
00163 void SimpleAttachment<AttachmentDescT>::copyToBin(
00164 BinaryDataHandler &pMem,
00165 const BitVector &whichField)
00166 {
00167 Inherited::copyToBin(pMem, whichField);
00168
00169 if(FieldBits::NoField != (SimpleFieldMask & whichField))
00170 {
00171 _field.copyToBin(pMem);
00172 }
00173 }
00174
00175 template <class AttachmentDescT> inline
00176 void SimpleAttachment<AttachmentDescT>::copyFromBin(
00177 BinaryDataHandler &pMem,
00178 const BitVector &whichField)
00179 {
00180 Inherited::copyFromBin(pMem, whichField);
00181
00182 if(FieldBits::NoField != (SimpleFieldMask & whichField))
00183 {
00184 _field.copyFromBin(pMem);
00185 }
00186 }
00187
00188
00189
00190
00191 template <class AttachmentDescT> inline
00192 void SimpleAttachment<AttachmentDescT>::dump( UInt32 uiIndent,
00193 const BitVector bvFlags ) const
00194 {
00195 Inherited::dump(uiIndent, bvFlags);
00196 }
00197
00198
00199
00200
00201 template <class AttachmentDescT> inline
00202 SimpleAttachment<AttachmentDescT>::SimpleAttachment(void) :
00203 Inherited(),
00204 _field ()
00205 {
00206 }
00207
00208 template <class AttachmentDescT> inline
00209 SimpleAttachment<AttachmentDescT>::SimpleAttachment(
00210 const SimpleAttachment &source) :
00211 Inherited(source ),
00212 _field (source._field)
00213 {
00214 }
00215
00216
00217
00218
00219 template <class AttachmentDescT> inline
00220 SimpleAttachment<AttachmentDescT>::~SimpleAttachment(void)
00221 {
00222 }
00223
00224
00225
00226
00227 #if !defined(OSG_FIXED_MFIELDSYNC)
00228 template <class AttachmentDescT> inline
00229 void SimpleAttachment<AttachmentDescT>::executeSync(
00230 FieldContainer &other,
00231 const BitVector &whichField)
00232 {
00233 this->executeSyncImpl(static_cast<SimpleAttachment *>(&other) ,
00234 whichField);
00235 }
00236
00237 template <class AttachmentDescT> inline
00238 void SimpleAttachment<AttachmentDescT>::executeSyncImpl(
00239 SimpleAttachment *pOther,
00240 const BitVector &whichField)
00241 {
00242 Inherited::executeSyncImpl(pOther, whichField);
00243
00244 if(FieldBits::NoField != (SimpleFieldMask & whichField))
00245 {
00246 _field.syncWith(pOther->_field);
00247 }
00248 }
00249 #else
00250 template <class AttachmentDescT> inline
00251 void SimpleAttachment<AttachmentDescT>::executeSync(
00252 FieldContainer &other,
00253 const BitVector &whichField,
00254 const SyncInfo &sInfo )
00255 {
00256 this->executeSyncImpl(static_cast<SimpleAttachment *>(&other) ,
00257 whichField,
00258 sInfo);
00259 }
00260
00261 template <class AttachmentDescT> inline
00262 void SimpleAttachment<AttachmentDescT>::executeSyncImpl(
00263 SimpleAttachment *pOther,
00264 const BitVector &whichField,
00265 const SyncInfo &sInfo )
00266 {
00267 Inherited::executeSyncImpl(pOther, whichField, sInfo);
00268
00269 if(FieldBits::NoField != (SimpleFieldMask & whichField))
00270 {
00271 _field.syncWith(pOther->_field);
00272 }
00273 }
00274 #endif
00275
00276
00277
00278
00279 #if 0
00280 #if defined(OSG_MICROSOFT_COMPILER_ALERT)
00281 template <class AttachmentDescT>
00282 FieldContainerType DynFieldAttachment<AttachmentDescT>::_type =
00283 FieldContainerType(
00284 AttachmentDescT::getTypeName(),
00285 AttachmentDescT::getParentTypeName(),
00286 AttachmentDescT::getGroupName(),
00287 (PrototypeCreateF) &DynFieldAttachment<AttachmentDescT>::createEmpty,
00288 NULL,
00289 NULL,
00290 0,
00291 true);
00292 #else
00293 template <class AttachmentDescT>
00294 FieldContainerType DynFieldAttachment<AttachmentDescT>::_type(
00295 AttachmentDescT::getTypeName(),
00296 AttachmentDescT::getParentTypeName(),
00297 AttachmentDescT::getGroupName(),
00298 (PrototypeCreateF) &DynFieldAttachment<AttachmentDescT>::createEmpty,
00299 NULL,
00300 NULL,
00301 0,
00302 true);
00303 #endif
00304 #endif
00305
00306 OSG_FIELD_CONTAINER_ST_INL_TMPL_DEF(DynFieldAttachment,
00307 AttachmentDescT,
00308 PtrType)
00309
00310 template <class AttachmentDescT> inline
00311 FieldContainerType &DynFieldAttachment<AttachmentDescT>::getType(void)
00312 {
00313 return _localType;
00314 }
00315
00316 template <class AttachmentDescT> inline
00317 const FieldContainerType &
00318 DynFieldAttachment<AttachmentDescT>::getType(void) const
00319 {
00320 return _localType;
00321 }
00322
00323
00324
00325
00326 template <class AttachmentDescT> inline
00327 UInt32 DynFieldAttachment<AttachmentDescT>::addField(
00328 const FieldDescription &fieldDesc)
00329 {
00330 UInt32 returnValue = 0;
00331 Field *fieldP = NULL;
00332 FieldDescription *descP = NULL;
00333
00334 returnValue = _localType.addDescription(fieldDesc);
00335
00336 if(returnValue != 0)
00337 {
00338 descP = _localType.getFieldDescription(returnValue);
00339
00340 if(descP != NULL)
00341 {
00342 descP->setFieldId (returnValue);
00343 descP->setFieldMask(
00344 TypeTraits<BitVector>::One << returnValue);
00345
00346 fieldP = FieldFactory::the().createField(fieldDesc.getTypeId());
00347
00348 if(_dynFieldsV.size() <=
00349 returnValue - Inherited::NextFieldId)
00350 {
00351 _dynFieldsV.resize((returnValue -
00352 Inherited::NextFieldId) + 1);
00353 }
00354
00355 _dynFieldsV[returnValue - Inherited::NextFieldId] = fieldP;
00356 }
00357 }
00358
00359 return returnValue;
00360 }
00361
00362 template <class AttachmentDescT> inline
00363 void DynFieldAttachment<AttachmentDescT>::subField(UInt32 fieldId)
00364 {
00365 if(_localType.subDescription(fieldId) == true)
00366 {
00367 std::vector<Field *>::iterator vIt = _dynFieldsV.begin();
00368
00369 vIt += fieldId - Inherited::NextFieldId;
00370
00371 if(vIt != _dynFieldsV.end())
00372 {
00373 delete (*vIt);
00374
00375 (*vIt) = NULL;
00376 }
00377 }
00378 }
00379
00380 template <class AttachmentDescT> inline
00381 Field *DynFieldAttachment<AttachmentDescT>::getDynamicField(
00382 UInt32 index)
00383 {
00384 return _dynFieldsV[index - Inherited::NextFieldId];
00385 }
00386
00387
00388
00389
00390 template <class AttachmentDescT> inline
00391 FieldContainerPtr DynFieldAttachment<AttachmentDescT>::emptyCopy(void)
00392 {
00393 PtrType returnValue = DynFieldAttachment<AttachmentDescT>::createEmpty();
00394
00395 for(UInt32 i = Inherited::NextFieldId;
00396 i <= _localType.getNumFieldDescs();
00397 i++)
00398 {
00399 returnValue->addField(*(_localType.getFieldDescription(i)));
00400 }
00401
00402 return returnValue;
00403 }
00404
00405 template <class AttachmentDescT> inline
00406 FieldContainerPtr DynFieldAttachment<AttachmentDescT>::clone(void)
00407 {
00408 PtrType returnValue = DynFieldAttachment<AttachmentDescT>::createEmpty();
00409 UInt32 i;
00410
00411 for(i = Inherited::NextFieldId;
00412 i <= _localType.getNumFieldDescs();
00413 i++)
00414 {
00415 returnValue->addField(*(_localType.getFieldDescription(i)));
00416 }
00417
00418 for(i = Inherited::NextFieldId;
00419 i <= _localType.getNumFieldDescs();
00420 i++)
00421 {
00422 returnValue->getDynamicField(i)->setAbstrValue(
00423 *(_dynFieldsV[i - Inherited::NextFieldId]));
00424 }
00425
00426 return returnValue;
00427 }
00428
00429
00430
00431
00432 template <class AttachmentDescT> inline
00433 void DynFieldAttachment<AttachmentDescT>::dump( UInt32 uiIndent,
00434 const BitVector ) const
00435 {
00436 PtrType thisP(*this);
00437
00438 indentLog(uiIndent, PLOG);
00439 PLOG << "DynFieldAttachment"
00440 << "("
00441 << thisP.getFieldContainerId()
00442 << ")"
00443 << std::endl;
00444
00445 indentLog(uiIndent, PLOG);
00446 PLOG << "{" << std::endl;
00447
00448 uiIndent += 4;
00449
00450 for(UInt32 i = 1; i <= getType().getNumFieldDescs(); i++)
00451 {
00452 indentLog(uiIndent, PLOG);
00453 PLOG << getType().getFieldDescription(i)->getCName ()
00454 << " ("
00455 << const_cast<Self *>(this)->getField(
00456 getType().getFieldDescription(i)->getFieldId())
00457 << ")"
00458 << std::endl;
00459 }
00460
00461 uiIndent -= 4;
00462
00463 indentLog(uiIndent, PLOG);
00464 PLOG << "}" << std::endl;
00465 }
00466
00467
00468
00469
00470 template <class AttachmentDescT> inline
00471 DynFieldAttachment<AttachmentDescT>::DynFieldAttachment(void) :
00472 Inherited ( ),
00473 _localType (_type),
00474 _dynFieldsV( )
00475 {
00476 }
00477
00478 template <class AttachmentDescT> inline
00479 DynFieldAttachment<AttachmentDescT>::DynFieldAttachment(
00480 const DynFieldAttachment &source) :
00481
00482 Inherited ( source ),
00483 _localType (_type ),
00484 _dynFieldsV( source._dynFieldsV)
00485 {
00486 }
00487
00488
00489
00490
00491 template <class AttachmentDescT> inline
00492 DynFieldAttachment<AttachmentDescT>::~DynFieldAttachment(void)
00493 {
00494 }
00495
00496 OSG_END_NAMESPACE
00497
00498 #define OSGATTACHMENT_INLINE_CVSID "@(#)$Id: $"
00499
00500 #endif