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 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGFIELDCONTAINERSFIELDHANDLE_H_
40 #define _OSGFIELDCONTAINERSFIELDHANDLE_H_
45 #include <boost/function.hpp>
46 #include <boost/type_traits.hpp>
50 /*! \ingroup GrpBaseFieldContainerFields
51 \ingroup GrpLibOSGBase
55 class OSG_BASE_DLLMAPPING GetSFieldHandle
<FieldContainerPtrSFieldBase
> :
58 /*========================= PROTECTED ===============================*/
62 typedef GetFieldHandle Inherited
;
64 /*========================== PUBLIC =================================*/
68 /*---------------------------------------------------------------------*/
69 /*! \name Public Types */
72 typedef boost::shared_ptr
<GetSFieldHandle
> Ptr
;
74 /*---------------------------------------------------------------------*/
75 /*! \name Constructors */
78 GetSFieldHandle(const GetSFieldHandle
&source
);
79 GetSFieldHandle(const FieldContainerPtrSFieldBase
*pField
,
80 const FieldDescriptionBase
*pDescription
,
81 FieldContainer
*pContainer
);
84 /*---------------------------------------------------------------------*/
85 /*! \name Field Type Query */
88 virtual const FieldType
&getType (void) const;
89 virtual bool isPointerField(void) const;
92 /*---------------------------------------------------------------------*/
93 /*! \name Stream/String IO */
96 virtual void pushValueToStream (OutStream
&str
) const;
97 virtual void pushIndexedValueToStream(OutStream
&str
,
99 virtual void pushSizeToStream (OutStream
&str
) const;
102 /*---------------------------------------------------------------------*/
103 /*! \name Comparison */
106 virtual bool equal(Inherited::Ptr rhs
) const;
107 virtual SizeT
size (void ) const;
110 /*---------------------------------------------------------------------*/
114 virtual FieldContainer
*get(void) const = 0;
116 const FieldContainerPtrSFieldBase
*getField (void);
118 const FieldContainerPtrSFieldBase
*operator ->(void);
119 const FieldContainerPtrSFieldBase
&operator * (void);
122 /*---------------------------------------------------------------------*/
126 /*! \ingroup GrpBaseFieldContainerFields
127 \ingroup GrpLibOSGBase
131 class OSG_BASE_DLLMAPPING EditSFieldHandle
<FieldContainerPtrSFieldBase
> :
132 public EditFieldHandle
134 /*========================= PROTECTED ===============================*/
138 typedef EditFieldHandle Inherited
;
140 typedef GetSFieldHandle
<FieldContainerPtrSFieldBase
> GetSFHandle
;
141 typedef boost::shared_ptr
<GetSFHandle
> GetSFHandlePtr
;
145 /*========================== PUBLIC =================================*/
149 /*---------------------------------------------------------------------*/
150 /*! \name Public Types */
153 typedef boost::shared_ptr
<EditSFieldHandle
> Ptr
;
156 /*---------------------------------------------------------------------*/
157 /*! \name Constructors */
160 EditSFieldHandle(const EditSFieldHandle
&source
);
161 EditSFieldHandle( FieldContainerPtrSFieldBase
*pField
,
162 const FieldDescriptionBase
*pDescription
,
163 FieldContainer
*pContainer
);
166 /*---------------------------------------------------------------------*/
167 /*! \name Field Type Query */
170 virtual bool isValid(void) const;
173 /*---------------------------------------------------------------------*/
174 /*! \name Field Type Query */
177 void setStoreless(void);
180 /*---------------------------------------------------------------------*/
181 /*! \name Field Type Query */
184 virtual const FieldType
&getType (void) const;
185 virtual bool isPointerField(void) const;
187 virtual bool supportsSet (void) const = 0;
190 /*---------------------------------------------------------------------*/
194 virtual FieldContainer
*get(void ) const = 0;
196 virtual bool set(FieldContainer
*newFC
) const = 0;
199 /*---------------------------------------------------------------------*/
200 /*! \name Stream/String IO */
203 virtual void pushValueToStream ( OutStream
&str
) const;
204 virtual void pushIndexedValueToStream( OutStream
&str
,
206 virtual void pushSizeToStream ( OutStream
&str
) const;
208 virtual void pushValueFromCString (const Char8
*str
);
209 virtual void pushIndexedValueFromCString(const Char8
*str
,
213 /*---------------------------------------------------------------------*/
214 /*! \name Comparison */
217 virtual bool equal(Inherited::Ptr rhs
) const;
218 virtual SizeT
size (void ) const;
221 /*---------------------------------------------------------------------*/
222 /*! \name Copy/Share/Clone */
225 virtual void copyValues (GetFieldHandlePtr source
) const;
226 virtual void shareValues(GetFieldHandlePtr source
) const;
228 virtual void cloneValues(
229 GetFieldHandlePtr pSrc
,
230 const TypePtrVector
&shareTypes
= TypePtrVector(),
231 const TypePtrVector
&ignoreTypes
= TypePtrVector(),
232 const TypeIdVector
&shareGroupIds
= TypeIdVector (),
233 const TypeIdVector
&ignoreGroupIds
= TypeIdVector ()) const;
236 /*---------------------------------------------------------------------*/
240 /*! \ingroup GrpBaseFieldContainerFields
241 \ingroup GrpLibOSGBase
244 template <class FieldT
>
245 class GetFCPtrSFieldHandle
:
246 public GetSFieldHandle
<FieldContainerPtrSFieldBase
>
248 /*========================= PROTECTED ===============================*/
252 typedef FieldT HandledField
;
253 typedef GetSFieldHandle
<FieldContainerPtrSFieldBase
> Inherited
;
255 /*========================== PUBLIC =================================*/
259 /*---------------------------------------------------------------------*/
260 /*! \name Constructors */
263 GetFCPtrSFieldHandle(const GetFCPtrSFieldHandle
&source
);
264 GetFCPtrSFieldHandle(const FieldT
*pField
,
265 const FieldDescriptionBase
*pDescription
,
266 FieldContainer
*pContainer
);
269 /*---------------------------------------------------------------------*/
270 /*! \name Field Type Query */
273 virtual const FieldType
&getType(void) const;
276 /*---------------------------------------------------------------------*/
277 /*! \name Stream/String IO */
280 virtual void pushValueToStream(OutStream
&str
) const;
281 virtual void pushSizeToStream (OutStream
&str
) const;
284 /*---------------------------------------------------------------------*/
288 virtual FieldContainer
*get(void) const;
290 const FieldT
*getField (void);
292 const FieldT
*operator ->(void);
293 const FieldT
&operator * (void);
296 /*========================== PRIVATE ================================*/
300 const HandledField
*dcast_const(void) const;
303 /*! \ingroup GrpBaseFieldContainerFields
304 \ingroup GrpLibOSGBase
307 template <class FieldT
>
308 class EditFCPtrSFieldHandle
:
309 public EditSFieldHandle
<FieldContainerPtrSFieldBase
>
311 /*========================= PROTECTED ===============================*/
315 typedef FieldT HandledField
;
316 typedef EditSFieldHandle
<FieldContainerPtrSFieldBase
> Inherited
;
317 typedef EditFCPtrSFieldHandle Self
;
319 typedef typename
FieldT::value_type StoredPtrType
;
321 typedef typename
boost::remove_pointer
<StoredPtrType
>::type StoredType
;
323 typedef RefCountPtr
<StoredType
,
324 UnrecordedRefCountPolicy
> StoredUnrecPtr
;
326 typedef boost::function
<void (typename
FieldT::const_value
)> SetMethod
;
328 SetMethod _fSetMethod
;
330 /*========================== PUBLIC =================================*/
334 /*---------------------------------------------------------------------*/
335 /*! \name Constructors */
338 EditFCPtrSFieldHandle(const EditFCPtrSFieldHandle
&source
);
339 EditFCPtrSFieldHandle( FieldT
*pField
,
340 const FieldDescriptionBase
*pDescription
,
341 FieldContainer
*pContainer
);
344 /*---------------------------------------------------------------------*/
345 /*! \name Field Type Query */
348 virtual const FieldType
&getType (void) const;
350 virtual bool supportsSet(void) const;
353 /*---------------------------------------------------------------------*/
357 virtual FieldContainer
*get(void ) const;
359 virtual bool set(FieldContainer
*newFC
) const;
362 /*---------------------------------------------------------------------*/
363 /*! \name Stream/String IO */
366 virtual void pushValueToStream ( OutStream
&str
) const;
367 virtual void pushSizeToStream ( OutStream
&str
) const;
369 virtual void pushValueFromCString(const Char8
*str
);
372 /*---------------------------------------------------------------------*/
373 /*! \name Callback Setup */
376 void setSetMethod(SetMethod fMethod
);
379 /*---------------------------------------------------------------------*/
380 /*! \name Copy/Share/Clone */
383 virtual void copyValues (GetFieldHandlePtr source
) const;
384 virtual void shareValues(GetFieldHandlePtr source
) const;
386 virtual void cloneValues(
387 GetFieldHandlePtr pSrc
,
388 const TypePtrVector
&shareTypes
= TypePtrVector(),
389 const TypePtrVector
&ignoreTypes
= TypePtrVector(),
390 const TypeIdVector
&shareGroupIds
= TypeIdVector (),
391 const TypeIdVector
&ignoreGroupIds
= TypeIdVector ()) const;
394 /*========================== PRIVATE ================================*/
397 HandledField
*dcast (void) const;
398 const HandledField
*dcast_const(void) const;
403 #include "OSGFieldContainerSFieldHandle.inl"
405 #endif /* _OSGFIELDCONTAINERSFIELDHANDLE_H_ */