OSGSField.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *           Copyright (C) 2003 by the OpenSG Forum                          *
00006  *                                                                           *
00007  *                            www.opensg.org                                 *
00008  *                                                                           *
00009  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
00010  *                                                                           *
00011 \*---------------------------------------------------------------------------*/
00012 /*---------------------------------------------------------------------------*\
00013  *                                License                                    *
00014  *                                                                           *
00015  * This library is free software; you can redistribute it and/or modify it   *
00016  * under the terms of the GNU Library General Public License as published    *
00017  * by the Free Software Foundation, version 2.                               *
00018  *                                                                           *
00019  * This library is distributed in the hope that it will be useful, but       *
00020  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00022  * Library General Public License for more details.                          *
00023  *                                                                           *
00024  * You should have received a copy of the GNU Library General Public         *
00025  * License along with this library; if not, write to the Free Software       *
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
00027  *                                                                           *
00028 \*---------------------------------------------------------------------------*/
00029 /*---------------------------------------------------------------------------*\
00030  *                                Changes                                    *
00031  *                                                                           *
00032  *                                                                           *
00033  *                                                                           *
00034  *                                                                           *
00035  *                                                                           *
00036  *                                                                           *
00037 \*---------------------------------------------------------------------------*/
00038 
00039 #ifndef _OSGSFIELD_H_
00040 #define _OSGSFIELD_H_
00041 #ifdef __sgi
00042 #pragma once
00043 #endif
00044 
00045 #include "OSGField.h"
00046 #include "OSGFieldTraits.h"
00047 #include "OSGFieldType.h"
00048 #include "OSGFieldHandle.h"
00049 
00050 #include <boost/shared_ptr.hpp>
00051 
00052 OSG_BEGIN_NAMESPACE
00053 
00054 #ifdef OSG_DOC_FILES_IN_MODULE
00055 
00059 #endif
00060 
00066 template<class ValueT, Int32 iNamespace = 0>
00067 class SField : public Field
00068 {
00069     /*==========================  PUBLIC  =================================*/
00070 
00071   public:
00072 
00073     typedef          FieldTraits      <ValueT, iNamespace>  SFieldTraits;
00074     typedef          SField           <ValueT, iNamespace>  Self;
00075 
00076     typedef          ValueT                                 StoredType;
00077     typedef          ValueT                                &reference;
00078     typedef const    ValueT                                &const_reference;
00079 
00080     typedef typename SFieldTraits::ArgumentType             ArgumentType;
00081 
00082     typedef          FieldDescription<SFieldTraits,
00083                                       SingleField        >  Description;
00084 
00085     typedef          EditSFieldHandle <Self      >          EditHandle;
00086     typedef          boost::shared_ptr<EditHandle>          EditHandlePtr;
00087 
00088 
00089     typedef          GetSFieldHandle  <Self     >           GetHandle;
00090     typedef          boost::shared_ptr<GetHandle>           GetHandlePtr;
00091 
00092     /*---------------------------------------------------------------------*/
00093 
00094     static const Int32 Namespace     = iNamespace;
00095 
00096     static const bool isSField       = true;
00097     static const bool isMField       = false;
00098 
00099     static const bool isPointerField = false;
00100 
00101     /*---------------------------------------------------------------------*/
00105     static const FieldType &getClassType(void);
00106 
00108     /*---------------------------------------------------------------------*/
00112              SField(void                     );
00113              SField(const SField       &obj  );
00114     explicit SField(      ArgumentType  value);
00115 
00117     /*---------------------------------------------------------------------*/
00121     ~SField(void); 
00122 
00124     /*---------------------------------------------------------------------*/
00128           reference getValue(void);
00129     const_reference getValue(void) const;
00130 
00132     /*---------------------------------------------------------------------*/
00136     void setValue           (      ArgumentType  value);
00137     void setValue           (const Self         &obj  );
00138 
00139     void setValueFromCString(const Char8        *str  );
00140 
00142     /*---------------------------------------------------------------------*/
00146     void pushValueToString  (std::string  &str) const;
00147     void pushValueFromStream(std::istream &str);
00148     void pushValueToStream  (OutStream    &str) const;
00149     void pushSizeToStream   (OutStream    &str) const;
00150     
00152     /*---------------------------------------------------------------------*/
00156     UInt32 getBinSize (void                   ) const;
00157     
00158     void   copyToBin  (BinaryDataHandler &pMem) const;
00159     void   copyFromBin(BinaryDataHandler &pMem);
00160 
00162     /*---------------------------------------------------------------------*/
00166 #ifdef OSG_MT_CPTR_ASPECT
00167     void syncWith(Self &source);
00168 #endif
00169 
00171     /*---------------------------------------------------------------------*/
00175     bool operator ==(const SField &source) const;
00176 
00178     /*---------------------------------------------------------------------*/
00182     void operator =(const SField &source);
00183 
00185     /*=========================  PROTECTED  ===============================*/
00186 
00187   protected:
00188 
00189     /*---------------------------------------------------------------------*/
00193     typedef Field Inherited;
00194 
00196     /*---------------------------------------------------------------------*/
00200     static FieldType _fieldType;
00201      
00202            ValueT    _fieldValue;
00203 
00204 #if defined(OSG_TMPL_STATIC_MEMBER_NEEDS_HELPER_FCT)
00205     const FieldType &fieldTypeExportHelper(void);
00206 #endif
00207 
00209     /*==========================  PRIVATE  ================================*/
00210 
00211   private:
00212 };
00213 
00214 OSG_END_NAMESPACE
00215 
00216 #include "OSGSField.inl"
00217 
00218 #endif /* _OSGSFIELD_H_ */