fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / Base / FieldContainer / Fields / Handle / OSGFieldContainerSFieldHandle.h
blob21e7003bfd84c2fe09f9bf8d730891fcbf7e2a6b
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 _OSGFIELDCONTAINERSFIELDHANDLE_H_
40 #define _OSGFIELDCONTAINERSFIELDHANDLE_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 #include <boost/function.hpp>
46 #include <boost/type_traits.hpp>
48 OSG_BEGIN_NAMESPACE
50 /*! \ingroup GrpBaseFieldContainerFields
51 \ingroup GrpLibOSGBase
54 template <>
55 class OSG_BASE_DLLMAPPING GetSFieldHandle<FieldContainerPtrSFieldBase> :
56 public GetFieldHandle
58 /*========================= PROTECTED ===============================*/
60 protected:
62 typedef GetFieldHandle Inherited;
64 /*========================== PUBLIC =================================*/
66 public:
68 /*---------------------------------------------------------------------*/
69 /*! \name Public Types */
70 /*! \{ */
72 typedef boost::shared_ptr<GetSFieldHandle> Ptr;
74 /*---------------------------------------------------------------------*/
75 /*! \name Constructors */
76 /*! \{ */
78 GetSFieldHandle(const GetSFieldHandle &source);
79 GetSFieldHandle(const FieldContainerPtrSFieldBase *pField,
80 const FieldDescriptionBase *pDescription,
81 FieldContainer *pContainer );
83 /*! \} */
84 /*---------------------------------------------------------------------*/
85 /*! \name Field Type Query */
86 /*! \{ */
88 virtual const FieldType &getType (void) const;
89 virtual bool isPointerField(void) const;
91 /*! \} */
92 /*---------------------------------------------------------------------*/
93 /*! \name Stream/String IO */
94 /*! \{ */
96 virtual void pushValueToStream (OutStream &str ) const;
97 virtual void pushIndexedValueToStream(OutStream &str,
98 UInt32 index) const;
99 virtual void pushSizeToStream (OutStream &str ) const;
101 /*! \} */
102 /*---------------------------------------------------------------------*/
103 /*! \name Comparison */
104 /*! \{ */
106 virtual bool equal(Inherited::Ptr rhs) const;
107 virtual SizeT size (void ) const;
109 /*! \} */
110 /*---------------------------------------------------------------------*/
111 /*! \name Access */
112 /*! \{ */
114 virtual FieldContainer *get(void) const = 0;
116 const FieldContainerPtrSFieldBase *getField (void);
118 const FieldContainerPtrSFieldBase *operator ->(void);
119 const FieldContainerPtrSFieldBase &operator * (void);
121 /*! \} */
122 /*---------------------------------------------------------------------*/
126 /*! \ingroup GrpBaseFieldContainerFields
127 \ingroup GrpLibOSGBase
130 template <>
131 class OSG_BASE_DLLMAPPING EditSFieldHandle<FieldContainerPtrSFieldBase> :
132 public EditFieldHandle
134 /*========================= PROTECTED ===============================*/
136 protected:
138 typedef EditFieldHandle Inherited;
140 typedef GetSFieldHandle<FieldContainerPtrSFieldBase> GetSFHandle;
141 typedef boost::shared_ptr<GetSFHandle> GetSFHandlePtr;
143 bool _bStoreless;
145 /*========================== PUBLIC =================================*/
147 public:
149 /*---------------------------------------------------------------------*/
150 /*! \name Public Types */
151 /*! \{ */
153 typedef boost::shared_ptr<EditSFieldHandle> Ptr;
155 /*! \} */
156 /*---------------------------------------------------------------------*/
157 /*! \name Constructors */
158 /*! \{ */
160 EditSFieldHandle(const EditSFieldHandle &source);
161 EditSFieldHandle( FieldContainerPtrSFieldBase *pField,
162 const FieldDescriptionBase *pDescription,
163 FieldContainer *pContainer );
165 /*! \} */
166 /*---------------------------------------------------------------------*/
167 /*! \name Field Type Query */
168 /*! \{ */
170 virtual bool isValid(void) const;
172 /*! \} */
173 /*---------------------------------------------------------------------*/
174 /*! \name Field Type Query */
175 /*! \{ */
177 void setStoreless(void);
179 /*! \} */
180 /*---------------------------------------------------------------------*/
181 /*! \name Field Type Query */
182 /*! \{ */
184 virtual const FieldType &getType (void) const;
185 virtual bool isPointerField(void) const;
187 virtual bool supportsSet (void) const = 0;
189 /*! \} */
190 /*---------------------------------------------------------------------*/
191 /*! \name Access */
192 /*! \{ */
194 virtual FieldContainer *get(void ) const = 0;
196 virtual bool set(FieldContainer *newFC) const = 0;
198 /*! \} */
199 /*---------------------------------------------------------------------*/
200 /*! \name Stream/String IO */
201 /*! \{ */
203 virtual void pushValueToStream ( OutStream &str ) const;
204 virtual void pushIndexedValueToStream( OutStream &str,
205 UInt32 index) const;
206 virtual void pushSizeToStream ( OutStream &str ) const;
208 virtual void pushValueFromCString (const Char8 *str );
209 virtual void pushIndexedValueFromCString(const Char8 *str ,
210 UInt32 index);
212 /*! \} */
213 /*---------------------------------------------------------------------*/
214 /*! \name Comparison */
215 /*! \{ */
217 virtual bool equal(Inherited::Ptr rhs) const;
218 virtual SizeT size (void ) const;
220 /*! \} */
221 /*---------------------------------------------------------------------*/
222 /*! \name Copy/Share/Clone */
223 /*! \{ */
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;
235 /*! \} */
236 /*---------------------------------------------------------------------*/
240 /*! \ingroup GrpBaseFieldContainerFields
241 \ingroup GrpLibOSGBase
244 template <class FieldT>
245 class GetFCPtrSFieldHandle :
246 public GetSFieldHandle<FieldContainerPtrSFieldBase>
248 /*========================= PROTECTED ===============================*/
250 protected:
252 typedef FieldT HandledField;
253 typedef GetSFieldHandle<FieldContainerPtrSFieldBase> Inherited;
255 /*========================== PUBLIC =================================*/
257 public:
259 /*---------------------------------------------------------------------*/
260 /*! \name Constructors */
261 /*! \{ */
263 GetFCPtrSFieldHandle(const GetFCPtrSFieldHandle &source);
264 GetFCPtrSFieldHandle(const FieldT *pField,
265 const FieldDescriptionBase *pDescription,
266 FieldContainer *pContainer );
268 /*! \} */
269 /*---------------------------------------------------------------------*/
270 /*! \name Field Type Query */
271 /*! \{ */
273 virtual const FieldType &getType(void) const;
275 /*! \} */
276 /*---------------------------------------------------------------------*/
277 /*! \name Stream/String IO */
278 /*! \{ */
280 virtual void pushValueToStream(OutStream &str) const;
281 virtual void pushSizeToStream (OutStream &str) const;
283 /*! \} */
284 /*---------------------------------------------------------------------*/
285 /*! \name Access */
286 /*! \{ */
288 virtual FieldContainer *get(void) const;
290 const FieldT *getField (void);
292 const FieldT *operator ->(void);
293 const FieldT &operator * (void);
295 /*! \} */
296 /*========================== PRIVATE ================================*/
298 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 ===============================*/
313 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 =================================*/
332 public:
334 /*---------------------------------------------------------------------*/
335 /*! \name Constructors */
336 /*! \{ */
338 EditFCPtrSFieldHandle(const EditFCPtrSFieldHandle &source );
339 EditFCPtrSFieldHandle( FieldT *pField,
340 const FieldDescriptionBase *pDescription,
341 FieldContainer *pContainer );
343 /*! \} */
344 /*---------------------------------------------------------------------*/
345 /*! \name Field Type Query */
346 /*! \{ */
348 virtual const FieldType &getType (void) const;
350 virtual bool supportsSet(void) const;
352 /*! \} */
353 /*---------------------------------------------------------------------*/
354 /*! \name Access */
355 /*! \{ */
357 virtual FieldContainer *get(void ) const;
359 virtual bool set(FieldContainer *newFC) const;
361 /*! \} */
362 /*---------------------------------------------------------------------*/
363 /*! \name Stream/String IO */
364 /*! \{ */
366 virtual void pushValueToStream ( OutStream &str) const;
367 virtual void pushSizeToStream ( OutStream &str) const;
369 virtual void pushValueFromCString(const Char8 *str);
371 /*! \} */
372 /*---------------------------------------------------------------------*/
373 /*! \name Callback Setup */
374 /*! \{ */
376 void setSetMethod(SetMethod fMethod);
378 /*! \} */
379 /*---------------------------------------------------------------------*/
380 /*! \name Copy/Share/Clone */
381 /*! \{ */
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;
393 /*! \} */
394 /*========================== PRIVATE ================================*/
396 private:
397 HandledField *dcast (void) const;
398 const HandledField *dcast_const(void) const;
401 OSG_END_NAMESPACE
403 #include "OSGFieldContainerSFieldHandle.inl"
405 #endif /* _OSGFIELDCONTAINERSFIELDHANDLE_H_ */