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
00038
00039 #ifndef _OSGFIELDCONTAINERPTRIMPL_H_
00040 #define _OSGFIELDCONTAINERPTRIMPL_H_
00041 #ifdef __sgi
00042 #pragma once
00043 #endif
00044
00045 #ifdef OSG_DOC_FILES_IN_MODULE
00046
00049 #endif
00050
00051 #include <OSGConceptPropertyChecks.h>
00052 #include <OSGFieldContainerProperties.h>
00053 #include <OSGSystemDef.h>
00054 #include <OSGBaseTypes.h>
00055
00056 #include <OSGThread.h>
00057 #include <OSGLock.h>
00058 #include <OSGThreadManager.h>
00059
00060 #include <utility>
00061 #include <iostream>
00062
00063 OSG_BEGIN_NAMESPACE
00064
00065 class FieldContainer;
00066 class LockPool;
00067 class NullFieldContainerPtr;
00068
00069
00070
00071
00072
00076 #ifdef __sgi
00077 #pragma set woff 1424
00078 #endif
00079
00080 #ifdef OSG_LINUX_ICC
00081 #pragma warning( disable : 444 )
00082 #endif
00083
00084
00085
00086
00087
00088 #ifdef __sgi
00089 #pragma set woff 1375
00090 #endif
00091
00092 class OSG_SYSTEMLIB_DLLMAPPING FieldContainerPtrBase
00093 {
00094
00095
00096 public:
00097
00098 static const UInt16 InvalidParentEPos;
00099 typedef UInt8 * FieldContainerPtrBase::*unspecified_bool_type;
00100
00101
00105 FieldContainerPtrBase( void );
00106 FieldContainerPtrBase(const NullFieldContainerPtr & );
00107 FieldContainerPtrBase(const FieldContainerPtrBase &source);
00108
00110
00114 ~FieldContainerPtrBase(void);
00115
00117
00121 void setParentFieldPos(UInt16 uiParentEPos);
00122 UInt16 getParentFieldPos(void ) const;
00123
00125
00129 Int32 getRefCount (void) const;
00130 UInt32 getFieldContainerId(void) const;
00131 UInt16 getContainerSize (void) const;
00132
00134
00136
00139 FieldContainer *getBaseCPtr (void ) const;
00140 FieldContainer *getAspectCPtr(UInt32 uiAspectId) const;
00141
00143
00147 void operator =(const NullFieldContainerPtr &);
00148 void operator =(const FieldContainerPtrBase &source);
00149
00151
00155 bool operator < (const NullFieldContainerPtr & ) const;
00156
00157 bool operator == (const NullFieldContainerPtr &other) const;
00158 bool operator != (const NullFieldContainerPtr &other) const;
00159
00160
00161 bool operator < (const FieldContainerPtrBase &) const;
00162
00163 bool operator == (const FieldContainerPtrBase &other) const;
00164 bool operator != (const FieldContainerPtrBase &other) const;
00165
00166 bool operator ! (void ) const;
00167
00168 operator unspecified_bool_type() const;
00169
00171
00175 void dump( UInt32 uiIndent = 0,
00176 const BitVector bvFlags = 0) const;
00177
00179
00180
00181 protected:
00182
00183
00187 static bool initialize(void);
00188 static bool terminate (void);
00189
00191
00195 UInt16 _containerSize;
00196 UInt16 _uiParentEPos;
00197 UInt8 *_storeP;
00198 #ifdef OSG_DEBUG_FCPTR
00199 FieldContainer *_typedStoreP;
00200 #endif
00201
00203
00207 explicit FieldContainerPtrBase(const FieldContainer &source );
00208 explicit FieldContainerPtrBase(const FieldContainer *source );
00209
00210 FieldContainerPtrBase(const FieldContainer *source,
00211 const UInt16 uiSize,
00212 const UInt16 uiParentEPos);
00213
00215
00219 void executeSync(UInt32 uiFromAspect,
00220 UInt32 uiToAspect,
00221 BitVector whichField);
00222
00224
00228 Int32 *getRefCountP (void );
00229 Int32 *getRefCountP (void ) const;
00230
00231 UInt32 *getIdP (void );
00232 UInt32 *getIdP (void ) const;
00233
00234 UInt8 *getFirstElemP(void );
00235 UInt8 *getFirstElemP(void ) const;
00236
00237 UInt8 *getElemP (UInt32 uiElemNum);
00238 UInt8 *getElemP (UInt32 uiElemNum) const;
00239
00241
00245 Int32 getRefCountOff (void ) const;
00246 Int32 getIdOff (void ) const;
00247 Int32 getFirstElemOff(void ) const;
00248 Int32 getElemOff (UInt32 uiElemNum) const;
00249
00251
00255 void addRef (void) const;
00256 void subRef (void) const;
00257
00258 void deleteContainers(void) const;
00259
00261
00265 void setNull(void);
00266
00268
00269
00270 private:
00271
00272 friend class FieldContainer;
00273 friend class FieldContainerFactory;
00274 friend class ChangeList;
00275
00276 #ifndef OSG_INVALID_PTR_CHECK
00277
00278 friend OSG_SYSTEMLIB_DLLMAPPING
00279 void addRefCP (const FieldContainerPtrBase &objectP);
00280
00281 friend OSG_SYSTEMLIB_DLLMAPPING
00282 void subRefCP (const FieldContainerPtrBase &objectP);
00283
00284 friend OSG_SYSTEMLIB_DLLMAPPING
00285 void setRefdCP ( FieldContainerPtrBase &objectP,
00286 const FieldContainerPtrBase &newObjectP);
00287
00288 friend OSG_SYSTEMLIB_DLLMAPPING
00289 void clearRefCP ( FieldContainerPtrBase &objectP);
00290
00291 #else
00292
00293 friend OSG_SYSTEMLIB_DLLMAPPING
00294 bool safeAddRefCP (const FieldContainerPtrBase &objectP);
00295
00296 friend OSG_SYSTEMLIB_DLLMAPPING
00297 bool safeSubRefCP (const FieldContainerPtrBase &objectP);
00298
00299 friend OSG_SYSTEMLIB_DLLMAPPING
00300 bool safeSetRefdCP ( FieldContainerPtrBase &objectP,
00301 const FieldContainerPtrBase &newObjectP);
00302
00303 friend OSG_SYSTEMLIB_DLLMAPPING
00304 bool safeClearRefCP ( FieldContainerPtrBase &objectP);
00305
00306 #endif
00307
00308 friend OSG_SYSTEMLIB_DLLMAPPING
00309 class FieldContainerType;
00310
00311 static LockPool *_pRefCountLock;
00312 };
00313
00314 #ifdef __sgi
00315 #pragma reset woff 1375
00316 #endif
00317
00318
00319
00320
00321
00322
00323
00327 #ifdef __sgi
00328 #pragma set woff 1375
00329 #endif
00330
00331 class OSG_SYSTEMLIB_DLLMAPPING FieldContainerPtr : public FieldContainerPtrBase
00332 {
00333
00334
00335 public:
00336
00337 OSG_PROPERTY_DECL(Pointer);
00338
00339 typedef FieldContainer StoredObjectType;
00340 typedef FieldContainerPtr ObjectType;
00341
00342 typedef FieldContainerPtrBase Inherited;
00343
00344
00348 FieldContainerPtr( void );
00349 FieldContainerPtr(const NullFieldContainerPtr & );
00350 FieldContainerPtr(const FieldContainerPtr &source);
00351
00353
00357 ~FieldContainerPtr(void);
00358
00360
00364 FieldContainer *operator->(void);
00365 FieldContainer *operator->(void) const;
00366
00367 FieldContainer &operator *(void);
00368 FieldContainer &operator *(void) const;
00369
00370 FieldContainer *getCPtr (void);
00371 FieldContainer *getCPtr (void) const;
00372
00374
00378 void operator =(const NullFieldContainerPtr & );
00379 void operator =(const FieldContainerPtr &source);
00380
00382
00383
00384 protected:
00385
00386
00390 void beginEdit (BitVector whichField, UInt32 origin) const;
00391 void endEdit (BitVector whichField, UInt32 origin) const;
00392 void changed (BitVector whichField, UInt32 origin) const;
00393 void endEditNotChanged(BitVector whichField, UInt32 origin) const;
00394
00396
00400 explicit FieldContainerPtr(const FieldContainer &source);
00401 explicit FieldContainerPtr(const FieldContainer *source);
00402
00403 FieldContainerPtr(const FieldContainer *source,
00404 const UInt16 uiSize,
00405 const UInt16 uiParentEPos);
00406
00408
00409
00410 private:
00411
00412 friend class FieldContainer;
00413
00414 friend OSG_SYSTEMLIB_DLLMAPPING
00415 void beginEditCP (const FieldContainerPtr &objectP,
00416 BitVector whichField,
00417 UInt32 origin );
00418
00419 friend OSG_SYSTEMLIB_DLLMAPPING
00420 void endEditCP (const FieldContainerPtr &objectP,
00421 BitVector whichField,
00422 UInt32 origin );
00423
00424 friend OSG_SYSTEMLIB_DLLMAPPING
00425 void changedCP (const FieldContainerPtr &objectP,
00426 BitVector whichField,
00427 UInt32 origin );
00428
00429 friend OSG_SYSTEMLIB_DLLMAPPING
00430 void endEditNotChangedCP(const FieldContainerPtr &objectP,
00431 BitVector whichField,
00432 UInt32 origin );
00433 };
00434
00435
00436
00440 class OSG_SYSTEMLIB_DLLMAPPING NullFieldContainerPtr :
00441 public FieldContainerPtr
00442 {
00443
00444
00445 public:
00446
00447 typedef FieldContainerPtr Inherited;
00448
00449
00453 NullFieldContainerPtr(void);
00454
00456
00460 ~NullFieldContainerPtr(void);
00461
00463
00464 };
00465
00466
00467
00468
00469
00470
00476 class OSG_SYSTEMLIB_DLLMAPPING ConstFieldContainerPtr :
00477 public FieldContainerPtrBase
00478 {
00479
00480
00481 public:
00482
00483 OSG_PROPERTY_DECL(ConstPointer);
00484
00485 typedef FieldContainer StoredObjectType;
00486 typedef FieldContainerPtr ObjectType;
00487
00488 typedef FieldContainerPtrBase Inherited;
00489
00490
00494 ConstFieldContainerPtr( void );
00495 ConstFieldContainerPtr(const NullFieldContainerPtr & );
00496 ConstFieldContainerPtr(const FieldContainerPtr &source);
00497 ConstFieldContainerPtr(const ConstFieldContainerPtr &source);
00498
00500
00504 ~ConstFieldContainerPtr(void);
00505
00507
00511 const FieldContainer *operator->(void);
00512 const FieldContainer *operator->(void) const;
00513
00514 const FieldContainer &operator *(void);
00515 const FieldContainer &operator *(void) const;
00516
00517 const FieldContainer *getCPtr (void);
00518 const FieldContainer *getCPtr (void) const;
00519
00521
00525 void operator =(const NullFieldContainerPtr & );
00526 void operator =(const FieldContainerPtr &source);
00527 void operator =(const ConstFieldContainerPtr &source);
00528
00530
00531
00532 protected:
00533
00534
00538 explicit ConstFieldContainerPtr(const FieldContainer &source);
00539 explicit ConstFieldContainerPtr(const FieldContainer *source);
00540
00541 ConstFieldContainerPtr(const FieldContainer *source,
00542 const UInt16 uiSize,
00543 const UInt16 uiParentEPos);
00544
00546
00547
00548 private:
00549 };
00550
00551
00552
00553
00554
00555
00556
00557
00562 template <class BasePtrTypeT, class FieldContainerTypeT>
00563 class FCPtr : public BasePtrTypeT
00564 {
00565
00566
00567 public:
00568
00569 OSG_PROPERTY_REQUIREMENT(BasePtrTypeT, Pointer);
00570
00571 typedef FieldContainerTypeT StoredObjectType;
00572 typedef FCPtr ObjectType;
00573
00574 typedef BasePtrTypeT Inherited;
00575
00576 typedef FCPtr<BasePtrTypeT,
00577 FieldContainerTypeT> Self;
00578
00579
00583 template <class InTypeT> inline
00584 static FCPtr dcast(const InTypeT oIn)
00585 {
00586 return FCPtr(
00587 (dynamic_cast<const typename FCPtr::StoredObjectType *>(
00588 oIn.getCPtr())),
00589 oIn.getContainerSize(),
00590 oIn.getParentFieldPos());
00591 }
00592
00594
00598 FCPtr( void );
00599 FCPtr(const NullFieldContainerPtr & );
00600 FCPtr(const FCPtr &source);
00601
00603
00607 ~FCPtr(void);
00608
00610
00614 FieldContainerTypeT *operator->(void);
00615 FieldContainerTypeT *operator->(void) const;
00616
00617 FieldContainerTypeT &operator *(void);
00618 FieldContainerTypeT &operator *(void) const;
00619
00620 FieldContainerTypeT *getCPtr (void);
00621 FieldContainerTypeT *getCPtr (void) const;
00622
00624
00628 void operator =(const FCPtr &source);
00629 void operator =(const NullFieldContainerPtr & );
00630
00632
00638 explicit FCPtr(const FieldContainerTypeT &source);
00639 explicit FCPtr(const FieldContainerTypeT *source);
00640
00642
00643
00644 protected:
00645
00646
00650 FCPtr(const FieldContainerTypeT *source,
00651 const UInt16 uiSize,
00652 const UInt16 uiParentPos);
00653
00655
00656
00657 private:
00658
00659 friend class FieldContainer;
00660 };
00661
00662
00663
00664
00665
00666
00667
00668
00673 template <class BasePtrTypeT, class FieldContainerTypeT>
00674 class ConstFCPtr : public BasePtrTypeT
00675 {
00676
00677
00678 public:
00679
00680 OSG_PROPERTY_REQUIREMENT(BasePtrTypeT, ConstPointer);
00681
00682 typedef FieldContainerTypeT StoredObjectType;
00683 typedef ConstFCPtr ObjectType;
00684
00685 typedef BasePtrTypeT Inherited;
00686
00687 typedef FCPtr<typename FieldContainerTypeT::Ptr::Inherited,
00688 FieldContainerTypeT > NCFCPtr;
00689
00690 typedef ConstFCPtr<BasePtrTypeT,
00691 FieldContainerTypeT> Self;
00692
00693
00697 ConstFCPtr( void );
00698 ConstFCPtr(const NullFieldContainerPtr & );
00699 ConstFCPtr(const NCFCPtr &source);
00700 ConstFCPtr(const ConstFCPtr &source);
00701
00703
00707 ~ConstFCPtr(void);
00708
00710
00714 const FieldContainerTypeT *operator->(void);
00715 const FieldContainerTypeT *operator->(void) const;
00716
00717 const FieldContainerTypeT &operator *(void);
00718 const FieldContainerTypeT &operator *(void) const;
00719
00720 const FieldContainerTypeT *getCPtr (void);
00721 const FieldContainerTypeT *getCPtr (void) const;
00722
00724
00728 void operator =(const NCFCPtr & );
00729 void operator =(const ConstFCPtr &source);
00730 void operator =(const NullFieldContainerPtr &source);
00731
00733
00739 explicit ConstFCPtr(const FieldContainerTypeT &source);
00740 explicit ConstFCPtr(const FieldContainerTypeT *source);
00741
00743
00744
00745 protected:
00746
00747
00751 ConstFCPtr(const FieldContainerTypeT *source,
00752 const UInt16 uiSize,
00753 const UInt16 uiParentPos);
00754
00756
00757
00758 private:
00759
00760 friend class FieldContainer;
00761 };
00762
00763
00768 class OSG_SYSTEMLIB_DLLMAPPING CPEditor
00769 {
00770
00771
00772 public:
00773
00774
00778 inline CPEditor(void);
00779
00780 inline CPEditor(const FieldContainerPtr fc,
00781 const BitVector mask = FieldBits::AllFields);
00782
00784
00788 inline ~CPEditor();
00789
00791
00792
00793 private:
00794
00795 FieldContainerPtr _fc;
00796 BitVector _mask;
00797 };
00798
00803 #define CPEdit(fc, mask) \
00804 ::OSG::CPEditor CPEdit_##fc((fc),(mask))
00805
00806 #define CPEditAll(fc) \
00807 ::OSG::CPEditor CPEdit_##fc((fc))
00808
00809 #ifdef __sgi
00810 #pragma reset woff 1375
00811 #endif
00812
00813 #ifdef OSG_LINUX_ICC
00814 #pragma warning( default : 444 )
00815 #endif
00816
00817 #ifdef __sgi
00818 #pragma reset woff 1424
00819 #endif
00820
00824 OSG_SYSTEMLIB_DLLMAPPING
00825 std::ostream &operator <<( std::ostream &os,
00826 const FieldContainerPtr &fc);
00827
00828 extern OSG_SYSTEMLIB_DLLMAPPING const NullFieldContainerPtr NullFC;
00829
00830 OSG_END_NAMESPACE
00831
00832 #define OSGFIELDCONTAINERPTR_HEADER_CVSID "@(#)$Id: $"
00833
00834 #endif