OSGTypedGeoIntegralProperty.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *                     Copyright 2000-2002 by OpenSG Forum                   *
00006  *                                                                           *
00007  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
00008  *                                                                           *
00009 \*---------------------------------------------------------------------------*/
00010 /*---------------------------------------------------------------------------*\
00011  *                                License                                    *
00012  *                                                                           *
00013  * This library is free software; you can redistribute it and/or modify it   *
00014  * under the terms of the GNU Library General Public License as published    *
00015  * by the Free Software Foundation, version 2.                               *
00016  *                                                                           *
00017  * This library is distributed in the hope that it will be useful, but       *
00018  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00020  * Library General Public License for more details.                          *
00021  *                                                                           *
00022  * You should have received a copy of the GNU Library General Public         *
00023  * License along with this library; if not, write to the Free Software       *
00024  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
00025  *                                                                           *
00026 \*---------------------------------------------------------------------------*/
00027 /*---------------------------------------------------------------------------*\
00028  *                                Changes                                    *
00029  *                                                                           *
00030  *                                                                           *
00031  *                                                                           *
00032  *                                                                           *
00033  *                                                                           *
00034  *                                                                           *
00035 \*---------------------------------------------------------------------------*/
00036 
00037 #ifndef _OSGTYPEDGEOINTEGRALPROPERTY_H_
00038 #define _OSGTYPEDGEOINTEGRALPROPERTY_H_
00039 #ifdef __sgi
00040 #pragma once
00041 #endif
00042 
00043 #include "OSGGL.h"
00044 
00045 #include "OSGDrawableDef.h"
00046 #include "OSGVecMFields.h"
00047 #include "OSGGeoIntegralProperty.h"
00048 
00049 OSG_BEGIN_NAMESPACE
00050 
00058 template <class GeoPropertyDesc>
00059 class TypedGeoIntegralProperty : public GeoIntegralProperty
00060 {
00061     /*==========================  PRIVATE  ================================*/
00062 
00063   private:
00064 
00065     /*==========================  PUBLIC  =================================*/
00066 
00067   public:
00068 
00069     typedef          GeoIntegralProperty                       Inherited;
00070     typedef          GeoIntegralProperty                       ParentContainer;
00071     
00072     typedef          GeoPropertyDesc                           PropDesc;
00073 
00074     typedef typename Inherited::TypeObject                     TypeObject;
00075     typedef typename TypeObject::InitPhase                     InitPhase;
00076 
00077     typedef          TypedGeoIntegralProperty<GeoPropertyDesc> Self;
00078 
00079     OSG_GEN_INTERNALPTR(Self);
00080 
00081     typedef typename GeoPropertyDesc::StoredType      StoredType;
00082     typedef typename GeoPropertyDesc::StoredFieldType StoredFieldType;
00083 
00084     typedef typename StoredFieldType::EditHandle      StoredEditHandle;
00085     typedef typename StoredFieldType::EditHandlePtr   StoredEditHandlePtr;
00086     typedef typename StoredFieldType::GetHandle       StoredGetHandle;
00087     typedef typename StoredFieldType::GetHandlePtr    StoredGetHandlePtr;
00088 
00089     typedef typename StoredFieldType::reference       reference;
00090     typedef typename StoredFieldType::const_reference const_reference;
00091 
00092     enum
00093     {
00094         GeoPropDataFieldId = GeoIntegralProperty::NextFieldId,
00095 
00096         NextFieldId        = GeoPropDataFieldId + 1
00097     };
00098 
00099     static const BitVector GeoPropDataFieldMask = 
00100                            1 << static_cast<Int32>(GeoPropDataFieldId);
00101 
00102     OSG_FIELD_CONTAINER_TMPL_DECL;
00103 
00104     /*---------------------------------------------------------------------*/
00108 #ifdef OSG_1_GET_COMPAT
00109           StoredFieldType *getFieldPtr (void);
00110           StoredFieldType &getField    (void);
00111 #endif
00112 
00113           StoredFieldType *editFieldPtr(void);
00114     const StoredFieldType *getFieldPtr (void) const;
00115 
00116           StoredFieldType &editField   (void);
00117     const StoredFieldType &getField    (void) const;
00118 
00119     virtual GeoIntegralPropertyPtr clone(void);
00120 
00121     virtual       UInt32  getFormat    (void) const;
00122     virtual       UInt32  getFormatSize(void) const;
00123     virtual       UInt32  getStride    (void) const;
00124     virtual       UInt32  getDimension (void) const;
00125     virtual const UInt8  *getData      (void) const;
00126     virtual       UInt32  size         (void) const;
00127 
00128             const StoredFieldType &operator->(      void               ) const;
00129 
00130                   StoredType       getValue  (const UInt32      index  ) const;
00131             void                   getValue  (      StoredType &val,
00132                                               const UInt32      index  ) const;
00133 
00134             void                   setValue  (const StoredType &val,
00135                                               const UInt32      index  );
00136 
00137             void                   addValue  (const StoredType &val    );
00138 
00139     virtual void                   clear     (      void               );
00140     virtual void                   resize    (      size_t      newsize);
00141     virtual void                   push_back (const StoredType &val    );
00142 
00143     template <class ExternalType>
00144     ExternalType getValue(const UInt32 index)
00145     {
00146         return static_cast<ExternalType>(_field[index]);
00147     }
00148 
00149     template <class ExternalType>
00150     void setValue(ExternalType val, const UInt32 index)
00151     {
00152         editMField(GeoPropDataFieldMask, _field);
00153 
00154         _field[index] = static_cast<StoredType>(val);
00155     }
00156 
00157     // These are copied from OSGGeoIntegralProperty.h
00158     // They need to be replicated as C++ name lookup won't find them
00159     template <class ExternalType>
00160     void addValue(const ExternalType &val)
00161     {
00162          push_back(val);
00163     }
00164     
00165     template <class ExternalType>
00166     void push_back(const ExternalType &val)
00167     {
00168         resize(size() + 1);
00169         setValue(val, size() - 1);
00170     }
00171     
00173     /*---------------------------------------------------------------------*/
00177     inline reference       operator [](UInt32 index);
00178     inline const_reference operator [](UInt32 index) const;
00179 
00181     /*---------------------------------------------------------------------*/
00185     TypedGeoIntegralProperty &operator =(const TypedGeoIntegralProperty &source);
00186 
00188     /*---------------------------------------------------------------------*/
00192     virtual void dump(      UInt32    uiIndent = 0,
00193                       const BitVector bvFlags  = 0) const;
00194 
00196     /*=========================  PROTECTED  ===============================*/    
00197   protected:
00198 
00199     friend class FieldContainer;
00200 
00201     StoredFieldType _field;
00202 
00203     /*---------------------------------------------------------------------*/
00207     TypedGeoIntegralProperty(void);
00208     TypedGeoIntegralProperty(const TypedGeoIntegralProperty &source);
00209     
00211     /*---------------------------------------------------------------------*/
00215     virtual ~TypedGeoIntegralProperty(void);
00216 
00218     /*---------------------------------------------------------------------*/
00222     virtual void getGenericValue(      MaxTypeT &val, const UInt32 index) const;
00223     virtual void setGenericValue(const MaxTypeT &val, const UInt32 index);
00224 
00226     /*---------------------------------------------------------------------*/
00230 #ifdef OSG_MT_CPTR_ASPECT
00231     virtual ObjPtr createAspectCopy(void) const;
00232 #endif
00233 
00235     /*---------------------------------------------------------------------*/
00239 #ifdef OSG_MT_CPTR_ASPECT
00240     virtual void execSyncV(      FieldContainer    &oFrom,
00241                                  ConstFieldMaskArg  whichField,
00242                                  AspectOffsetStore &oOffsets,
00243                                  ConstFieldMaskArg  syncMode  ,
00244                            const UInt32             uiSyncInfo);
00245 
00246             void execSync (      Self              *pFrom,
00247                                  ConstFieldMaskArg  whichField,
00248                                  AspectOffsetStore &oOffsets,
00249                                  ConstFieldMaskArg  syncMode  ,
00250                            const UInt32             uiSyncInfo);
00252     /*---------------------------------------------------------------------*/
00256     virtual void resolveLinks(void);
00257 #endif
00258 
00260     /*---------------------------------------------------------------------*/
00264     EditFieldHandlePtr editHandleField(void);
00265     GetFieldHandlePtr  getHandleField (void) const;
00266 
00268     /*---------------------------------------------------------------------*/
00272     virtual void changed        (ConstFieldMaskArg whichField, 
00273                                  UInt32            origin,
00274                                  BitVector         detail);
00275             
00277     /*---------------------------------------------------------------------*/
00281     virtual UInt32 getBinSize (ConstFieldMaskArg  whichField);
00282     virtual void   copyToBin  (BinaryDataHandler &pMem,
00283                                ConstFieldMaskArg  whichField);
00284     virtual void   copyFromBin(BinaryDataHandler &pMem,
00285                                ConstFieldMaskArg  whichField);
00286 
00288     /*==========================  PRIVATE  ================================*/
00289 
00290   private:
00291 
00292     static void classDescInserter(TypeObject &oType);
00293 
00294     static void initMethod(InitPhase ePhase);
00295 
00296 //    static const ObjPtr NullPtr;
00297 
00298     static TypeObject  _type;
00299 };
00300 
00301 struct TypedGeoIntegralPropertyDescBase
00302 {
00303     typedef GeoIntegralProperty       PropertParent;
00304     
00305     typedef PropertParent::TypeObject TypeObject;
00306     typedef TypeObject::InitPhase     InitPhase;
00307 
00308     static const Char8 *getGroupName (void) 
00309     {
00310         return "TypedGeoIntegralProperty";  
00311     }
00312 
00313     static void initMethod(InitPhase OSG_CHECK_ARG(ePhase)) {}
00314 
00315     static UInt32         getStride    (void) { return 0; }
00316 
00317     static UInt32         getDimension (void) { return 1; }
00318 };
00319 
00320 
00326 struct GeoUInt8PropertyDesc : public TypedGeoIntegralPropertyDescBase
00327 {    
00328     static const Char8 *getTypeName (void) { return "GeoUInt8Property";  }
00329 
00330     static UInt32             getFormat    (void) { return GL_UNSIGNED_BYTE;}
00331     static UInt32             getFormatSize(void) { return sizeof(GLubyte); }
00332     
00333     typedef UInt8             StoredType;
00334     typedef MFUInt8           StoredFieldType;
00335 };
00336 
00337 #if !defined(OSG_DO_DOC) // created as a dummy class, remove to prevent doubles
00338 
00339 typedef TypedGeoIntegralProperty<GeoUInt8PropertyDesc> GeoUInt8Property;
00340 
00341 typedef GeoUInt8Property::ObjPtr                       GeoUInt8PropertyPtr;
00342 
00343 #endif
00344 
00345 
00351 struct GeoUInt16PropertyDesc : public TypedGeoIntegralPropertyDescBase
00352 {    
00353     static const Char8 *getTypeName (void) { return "GeoUInt16Property";  }
00354 
00355     static UInt32             getFormat    (void) { return GL_UNSIGNED_SHORT;}
00356     static UInt32             getFormatSize(void) { return sizeof(GLushort); }
00357     
00358     typedef UInt16            StoredType;
00359     typedef MFUInt16          StoredFieldType;
00360 };
00361 
00362 #if !defined(OSG_DO_DOC) // created as a dummy class, remove to prevent doubles
00363 
00364 typedef TypedGeoIntegralProperty<GeoUInt16PropertyDesc> GeoUInt16Property;
00365 
00366 typedef GeoUInt16Property::ObjPtr                       GeoUInt16PropertyPtr;
00367 
00368 #endif
00369 
00370 
00371 #ifndef OSG_WINCE
00372 
00376 struct GeoUInt32PropertyDesc : public TypedGeoIntegralPropertyDescBase
00377 {    
00378     static const Char8 *getTypeName (void) { return "GeoUInt32Property";  }
00379 
00380     static UInt32             getFormat    (void) { return GL_UNSIGNED_INT;}
00381     static UInt32             getFormatSize(void) { return sizeof(GLuint); }
00382     
00383     typedef UInt32            StoredType;
00384     typedef MFUInt32          StoredFieldType;
00385 };
00386 
00387 #if !defined(OSG_DO_DOC) // created as a dummy class, remove to prevent doubles
00388 
00389 typedef TypedGeoIntegralProperty<GeoUInt32PropertyDesc> GeoUInt32Property;
00390 
00391 typedef GeoUInt32Property::ObjPtr                       GeoUInt32PropertyPtr;
00392 
00393 #endif
00394 #endif
00395 
00396 #ifdef OSG_DEPRECIATED_PROPS
00397 
00400 typedef GeoIntegralPropertyPtr GeoPTypesPtr;
00401 typedef GeoIntegralPropertyPtr GeoPLengthsPtr;
00402 
00403 typedef GeoIntegralPropertyPtr         GeoIndicesPtr;
00404 typedef GeoIntegralPropertyConstPtr    GeoIndicesConstPtr;
00405 typedef GeoIntegralPropertyPtrConst    GeoIndicesPtrConst;
00406 typedef GeoIntegralPropertyPtrConstArg GeoIndicesPtrConstArg;
00407 
00408 typedef GeoUInt8Property       GeoPTypesUI8;
00409 typedef GeoUInt8Property       GeoPLengthsUI8;
00410 typedef GeoUInt8Property       GeoIndicesUI8;
00411 typedef GeoUInt8PropertyPtr    GeoPTypesUI8Ptr;
00412 typedef GeoUInt8PropertyPtr    GeoPLengthsUI8Ptr;
00413 typedef GeoUInt8PropertyPtr    GeoIndicesUI8Ptr;
00414 
00415 typedef GeoUInt16Property      GeoPTypesUI16;
00416 typedef GeoUInt16Property      GeoPLengthsUI16;
00417 typedef GeoUInt16Property      GeoIndicesUI16;
00418 typedef GeoUInt16PropertyPtr   GeoPTypesUI16Ptr;
00419 typedef GeoUInt16PropertyPtr   GeoPLengthsUI16Ptr;
00420 typedef GeoUInt16PropertyPtr   GeoIndicesUI16Ptr;
00421 
00422 #ifndef OSG_WINCE
00423 typedef GeoUInt32Property      GeoPTypesUI32;
00424 typedef GeoUInt32Property      GeoPLengthsUI32;
00425 typedef GeoUInt32Property      GeoIndicesUI32;
00426 typedef GeoUInt32PropertyPtr   GeoPTypesUI32Ptr;
00427 typedef GeoUInt32PropertyPtr   GeoPLengthsUI32Ptr;
00428 typedef GeoUInt32PropertyPtr   GeoIndicesUI32Ptr;
00429 #endif
00430 
00431 #endif
00432 
00433 #ifdef OSG_GLES
00434 
00435 #ifdef OSG_FLOAT_PROFILE
00436 #else
00437 typedef GeoUInt16Property      GeoUIntProperty;
00438 typedef GeoUInt16PropertyPtr   GeoUIntPropertyPtr;
00439 #endif
00440 
00441 #else
00442 typedef GeoUInt32Property      GeoUIntProperty;
00443 typedef GeoUInt32PropertyPtr   GeoUIntPropertyPtr;
00444 #endif
00445  
00446 OSG_END_NAMESPACE
00447 
00448 #include "OSGTypedGeoIntegralProperty.inl"
00449 
00450 #endif /* _OSGTYPEDGEOINTEGRALPROPERTY_H_ */
00451