1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2003 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
46 #include "OSGFieldTraits.h"
47 #include "OSGFieldType.h"
48 #include "OSGFieldHandle.h"
49 #include "OSGFieldDescFactory.h"
51 #include <boost/shared_ptr.hpp>
55 /*! Base class for all single fields, for example SFMatrix.
57 \ingroup GrpBaseFieldSingle
58 \ingroup GrpLibOSGBase
61 template<class ValueT
, Int32 iNamespace
= 0>
62 class SField
: public Field
64 /*========================== PUBLIC =================================*/
68 typedef FieldTraits
<ValueT
, iNamespace
> SFieldTraits
;
69 typedef SField
<ValueT
, iNamespace
> Self
;
71 typedef ValueT StoredType
;
72 typedef ValueT
&reference
;
73 typedef const ValueT
&const_reference
;
75 typedef typename
SFieldTraits::ArgumentType ArgumentType
;
77 typedef FieldDescription
<
79 FieldType::SingleField
> Description
;
81 typedef EditSFieldHandle
<Self
> EditHandle
;
82 typedef boost::shared_ptr
<EditHandle
> EditHandlePtr
;
85 typedef GetSFieldHandle
<Self
> GetHandle
;
86 typedef boost::shared_ptr
<GetHandle
> GetHandlePtr
;
88 /*---------------------------------------------------------------------*/
90 static const Int32 Namespace
= iNamespace
;
92 static const bool isSField
= true;
93 static const bool isMField
= false;
95 static const bool isPointerField
= false;
97 static const FieldType::Class Class
= FieldType::ValueField
;
99 /*---------------------------------------------------------------------*/
100 /*! \name Class Get */
103 static const FieldType
&getClassType(void);
106 /*---------------------------------------------------------------------*/
107 /*! \name Constructors */
111 SField(const SField
&obj
);
112 explicit SField( ArgumentType value
);
115 /*---------------------------------------------------------------------*/
116 /*! \name Destructor */
122 /*---------------------------------------------------------------------*/
126 reference
getValue(void);
127 const_reference
getValue(void) const;
130 /*---------------------------------------------------------------------*/
134 void setValue ( ArgumentType value
);
135 void setValue (const Self
&obj
);
137 void setValueFromCString(const Char8
*str
);
140 /*---------------------------------------------------------------------*/
144 void pushValueToString (std::string
&str
) const;
145 void pushValueFromStream(std::istream
&str
);
146 void pushValueToStream (OutStream
&str
) const;
147 void pushSizeToStream (OutStream
&str
) const;
150 /*---------------------------------------------------------------------*/
151 /*! \name Binary Interface */
154 SizeT
getBinSize (void ) const;
156 void copyToBin (BinaryDataHandler
&pMem
) const;
157 void copyFromBin(BinaryDataHandler
&pMem
);
160 /*---------------------------------------------------------------------*/
164 #ifdef OSG_MT_CPTR_ASPECT
165 void syncWith(Self
&source
);
169 /*---------------------------------------------------------------------*/
173 bool operator ==(const SField
&source
) const;
176 /*---------------------------------------------------------------------*/
180 const SField
&operator =(const SField
&source
);
183 /*========================= PROTECTED ===============================*/
188 /*---------------------------------------------------------------------*/
189 /*! \name Type information */
192 typedef Field Inherited
;
195 /*---------------------------------------------------------------------*/
199 static FieldType _fieldType
;
203 #if defined(OSG_TMPL_STATIC_MEMBER_NEEDS_HELPER_FCT)
204 const FieldType
&fieldTypeExportHelper(void);
207 static FieldDescriptionBase
*
208 createFieldDescription (const Char8
*szFieldname
,
210 FieldEditMethod fEditMethod
,
211 FieldGetMethod fGetMethod
);
213 static FieldDescriptionBase
*
214 createIdxFieldDescription(const Char8
*szFieldname
,
216 FieldIndexEditMethod fEditMethod
,
217 FieldIndexGetMethod fGetMethod
);
220 /*========================== PRIVATE ================================*/
227 #include "OSGSField.inl"
229 #endif /* _OSGSFIELD_H_ */