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_H_
00038 #define _OSGATTACHMENTIMPL_H_
00039 #ifdef __sgi
00040 #pragma once
00041 #endif
00042
00043 #ifdef OSG_DOC_FILES_IN_MODULE
00044
00047 #endif
00048
00049 #include <OSGSystemDef.h>
00050 #include <OSGBaseTypes.h>
00051 #include <OSGFieldContainer.h>
00052 #include <OSGFieldContainerPtr.h>
00053 #include <OSGSFBaseTypes.h>
00054 #include <OSGMFFieldContainerPtr.h>
00055 #include <OSGSFSysTypes.h>
00056
00057 #include <map>
00058 #include <iostream>
00059
00060 OSG_BEGIN_NAMESPACE
00061
00062 class BinaryDataHandler;
00063 class FieldDescription;
00064
00065
00066
00067
00068
00074 class OSG_SYSTEMLIB_DLLMAPPING Attachment : public FieldContainer
00075 {
00076
00077
00078 protected:
00079
00080 typedef FieldContainer Inherited;
00081
00082
00083
00084 public:
00085
00086 enum
00087 {
00088 ParentsFieldId = Inherited::NextFieldId,
00089 InternalFieldId = ParentsFieldId + 1,
00090 NextFieldId = InternalFieldId + 1
00091 };
00092
00093 static const BitVector InternalFieldMask;
00094 static const BitVector ParentsFieldMask;
00095
00096
00100 OSG_FIELD_CONTAINER_DECL(AttachmentPtr)
00101
00102
00103
00107 MFFieldContainerPtr &getParents (void );
00108 const MFFieldContainerPtr &getParents (void ) const;
00109
00110 MFFieldContainerPtr *getMFParents(void );
00111
00112 void addParent (FieldContainerPtr parent);
00113 void subParent (FieldContainerPtr parent);
00114
00115 Int32 findParent (FieldContainerPtr parent);
00116
00118
00122 SFBool &getInternal (void );
00123 const SFBool &getInternal (void ) const;
00124 SFBool *getSFInternal(void );
00125
00126 void setInternal (bool bVal);
00127
00129
00133 virtual UInt32 getBinSize (const BitVector &whichField);
00134
00135 virtual void copyToBin ( BinaryDataHandler &pMem,
00136 const BitVector &whichField);
00137 virtual void copyFromBin( BinaryDataHandler &pMem,
00138 const BitVector &whichField);
00139
00141
00145 virtual void dump( UInt32 uiIndent = 0,
00146 const BitVector bvFlags = 0) const;
00147
00149
00150
00151 protected:
00152
00153
00157 static FieldDescription *_desc[];
00158 static FieldContainerType _type;
00159
00161
00165 SFBool _sfInternal;
00166 MFFieldContainerPtr _parents;
00167
00169
00173 Attachment( void );
00174 Attachment(const Attachment &obj);
00175
00177
00181 virtual ~Attachment(void);
00182
00184
00188 virtual void onDestroy(void);
00189
00190 #if defined(OSG_FIXED_MFIELDSYNC)
00191 virtual void onDestroyAspect(UInt32 uiId, UInt32 uiAspect);
00192 #endif
00193
00195
00199 #if !defined(OSG_FIXED_MFIELDSYNC)
00200 virtual void executeSync ( FieldContainer &other,
00201 const BitVector &whichField);
00202
00203 void executeSyncImpl( Attachment *pOther,
00204 const BitVector &whichField);
00205 #else
00206 virtual void executeSync ( FieldContainer &other,
00207 const BitVector &whichField,
00208 const SyncInfo &sInfo );
00209
00210 void executeSyncImpl ( Attachment *pOther,
00211 const BitVector &whichField,
00212 const SyncInfo &sInfo );
00213
00214 virtual void execBeginEdit (const BitVector &whichField,
00215 UInt32 uiAspect,
00216 UInt32 uiContainerSize);
00217
00218 void execBeginEditImpl (const BitVector &whichField,
00219 UInt32 uiAspect,
00220 UInt32 uiContainerSize);
00221 #endif
00222
00224
00225
00226 private:
00227
00228 friend class FieldContainer;
00229
00231 void operator =(const Attachment &source);
00232 };
00233
00234
00235
00236
00237
00238
00241
00242 template <class AttachmentDescT>
00243 class SimpleAttachment : public Attachment
00244 {
00245
00246
00247 protected:
00248
00249 typedef Attachment Inherited;
00250
00251
00252
00253 public:
00254
00255 typedef typename AttachmentDescT::FieldTypeT StoredFieldType;
00256
00257 typedef SimpleAttachment<AttachmentDescT> Self;
00258
00259 typedef FCPtr<AttachmentPtr, Self > PtrType;
00260
00261 enum
00262 {
00263 SimpleFieldId = Inherited::NextFieldId,
00264 NextFieldId = SimpleFieldId + 1
00265 };
00266
00267 static const BitVector SimpleFieldMask =
00268 1 << static_cast<UInt32>(SimpleFieldId);
00269
00270
00274 OSG_FIELD_CONTAINER_TMPL_DECL(PtrType)
00275
00276
00277
00281 StoredFieldType *getFieldPtr(void);
00282
00283 StoredFieldType &getField (void);
00284 const StoredFieldType &getField (void) const;
00285
00287
00291 virtual UInt32 getBinSize (const BitVector &whichField);
00292
00293 virtual void copyToBin ( BinaryDataHandler &pMem,
00294 const BitVector &whichField);
00295 virtual void copyFromBin( BinaryDataHandler &pMem,
00296 const BitVector &whichField);
00297
00299
00303 virtual void dump( UInt32 uiIndent = 0,
00304 const BitVector bvFlags = 0) const;
00305
00307
00308
00309 protected:
00310
00311
00315 static FieldDescription *_desc[];
00316 static FieldContainerType _type;
00317
00319
00323 StoredFieldType _field;
00324
00326
00330 SimpleAttachment(void);
00331 SimpleAttachment(const SimpleAttachment &source);
00332
00334
00338 virtual ~SimpleAttachment(void);
00339
00341
00345 #if !defined(OSG_FIXED_MFIELDSYNC)
00346 virtual void executeSync ( FieldContainer &other,
00347 const BitVector &whichField);
00348
00349 void executeSyncImpl( SimpleAttachment *pOther,
00350 const BitVector &whichField);
00351 #else
00352 virtual void executeSync ( FieldContainer &other,
00353 const BitVector &whichField,
00354 const SyncInfo &sInfo );
00355
00356 void executeSyncImpl( SimpleAttachment *pOther,
00357 const BitVector &whichField,
00358 const SyncInfo &sInfo );
00359 #endif
00360
00362
00363
00364 private:
00365
00366 friend class FieldContainer;
00367
00369 SimpleAttachment &operator =(const SimpleAttachment &source);
00370 };
00371
00372
00373
00374
00375
00376
00380
00381 template <class AttachmentDescT>
00382 class DynFieldAttachment : public AttachmentDescT::Parent
00383 {
00384
00385
00386 public:
00387
00388 typedef DynFieldAttachment<AttachmentDescT> Self;
00389
00390 typedef typename AttachmentDescT::ParentPtr ParentPtrType;
00391
00392 typedef FCPtr<ParentPtrType, Self > PtrType;
00393
00394
00398 OSG_FIELD_CONTAINER_TMPL_DECL(PtrType)
00399
00400
00401
00405 UInt32 addField (const FieldDescription &fieldDesc);
00406 void subField ( UInt32 fieldId );
00407
00408 Field *getDynamicField( UInt32 index );
00409
00411
00415 FieldContainerPtr emptyCopy(void);
00416 FieldContainerPtr clone (void);
00417
00419
00423 virtual void dump( UInt32 uiIndent = 0,
00424 const BitVector bvFlags = 0) const;
00425
00427
00428
00429 protected:
00430
00431 typedef typename AttachmentDescT::Parent Inherited;
00432
00433
00437 static FieldContainerType _type;
00438
00440
00444 FieldContainerType _localType;
00445
00446 std::vector<Field *> _dynFieldsV;
00447
00449
00453 DynFieldAttachment( void );
00454 DynFieldAttachment(const DynFieldAttachment &source);
00455
00457
00461 virtual ~DynFieldAttachment(void);
00462
00464
00465
00466 private:
00467
00468 friend class FieldContainer;
00469
00471 void operator =(const DynFieldAttachment &source);
00472 };
00473
00477 typedef std::map<UInt32, AttachmentPtr> AttachmentMap;
00478
00482 OSG_SYSTEMLIB_DLLMAPPING
00483 std::ostream &operator <<( std::ostream &stream,
00484 const AttachmentMap &amap);
00485
00486 OSG_END_NAMESPACE
00487
00488 #define OSGATTACHMENT_HEADER_CVSID "@(#)$Id: $"
00489
00490 #endif