changed: auto add updateData callback to stages so that stagedata can be updated...
[opensg.git] / Source / Base / Field / OSGSField.h
bloba113e65633754ffb254f82032c7342abb2d4363a
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2003 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
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. *
18 * *
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. *
23 * *
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. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGSFIELD_H_
40 #define _OSGSFIELD_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 #include "OSGField.h"
46 #include "OSGFieldTraits.h"
47 #include "OSGFieldType.h"
48 #include "OSGFieldHandle.h"
49 #include "OSGFieldDescFactory.h"
51 #include <boost/shared_ptr.hpp>
53 OSG_BEGIN_NAMESPACE
55 /*! Base class for all single fields, for example SFMatrix.
56 \ingroup GrpBaseField
57 \ingroup GrpBaseFieldSingle
58 \ingroup GrpLibOSGBase
61 template<class ValueT, Int32 iNamespace = 0>
62 class SField : public Field
64 /*========================== PUBLIC =================================*/
66 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<
78 SFieldTraits,
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 */
101 /*! \{ */
103 static const FieldType &getClassType(void);
105 /*! \} */
106 /*---------------------------------------------------------------------*/
107 /*! \name Constructors */
108 /*! \{ */
110 SField(void );
111 SField(const SField &obj );
112 explicit SField( ArgumentType value);
114 /*! \} */
115 /*---------------------------------------------------------------------*/
116 /*! \name Destructor */
117 /*! \{ */
119 ~SField(void);
121 /*! \} */
122 /*---------------------------------------------------------------------*/
123 /*! \name Get */
124 /*! \{ */
126 reference getValue(void);
127 const_reference getValue(void) const;
129 /*! \} */
130 /*---------------------------------------------------------------------*/
131 /*! \name Set */
132 /*! \{ */
134 void setValue ( ArgumentType value);
135 void setValue (const Self &obj );
137 void setValueFromCString(const Char8 *str );
139 /*! \} */
140 /*---------------------------------------------------------------------*/
141 /*! \name Push */
142 /*! \{ */
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;
149 /*! \} */
150 /*---------------------------------------------------------------------*/
151 /*! \name Binary Interface */
152 /*! \{ */
154 SizeT getBinSize (void ) const;
156 void copyToBin (BinaryDataHandler &pMem) const;
157 void copyFromBin(BinaryDataHandler &pMem);
159 /*! \} */
160 /*---------------------------------------------------------------------*/
161 /*! \name MT Sync */
162 /*! \{ */
164 #ifdef OSG_MT_CPTR_ASPECT
165 void syncWith(Self &source);
166 #endif
168 /*! \} */
169 /*---------------------------------------------------------------------*/
170 /*! \name Compare */
171 /*! \{ */
173 bool operator ==(const SField &source) const;
175 /*! \} */
176 /*---------------------------------------------------------------------*/
177 /*! \name Assign */
178 /*! \{ */
180 void operator =(const SField &source);
182 /*! \} */
183 /*========================= PROTECTED ===============================*/
185 protected:
188 /*---------------------------------------------------------------------*/
189 /*! \name Type information */
190 /*! \{ */
192 typedef Field Inherited;
194 /*! \} */
195 /*---------------------------------------------------------------------*/
196 /*! \name Member */
197 /*! \{ */
199 static FieldType _fieldType;
201 ValueT _fieldValue;
203 #if defined(OSG_TMPL_STATIC_MEMBER_NEEDS_HELPER_FCT)
204 const FieldType &fieldTypeExportHelper(void);
205 #endif
207 static FieldDescriptionBase *
208 createFieldDescription (const Char8 *szFieldname,
209 UInt32 uiFieldFlags,
210 FieldEditMethod fEditMethod,
211 FieldGetMethod fGetMethod );
213 static FieldDescriptionBase *
214 createIdxFieldDescription(const Char8 *szFieldname,
215 UInt32 uiFieldFlags,
216 FieldIndexEditMethod fEditMethod,
217 FieldIndexGetMethod fGetMethod );
219 /*! \} */
220 /*========================== PRIVATE ================================*/
222 private:
225 OSG_END_NAMESPACE
227 #include "OSGSField.inl"
229 #endif /* _OSGSFIELD_H_ */