fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / Base / Field / OSGOSGAnyFields.h
blob5671b78a4695bac3e1f7cfa0600f783c4e0043cc
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2008 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 _OSGANYFIELDS_H_
40 #define _OSGANYFIELDS_H_
42 #include "OSGBaseDef.h"
43 #include "OSGBaseTypes.h"
44 #include "OSGFieldTraits.h"
45 #include "OSGSField.h"
46 #include "OSGMField.h"
48 OSG_BEGIN_NAMESPACE
50 class Window;
52 /*! \ingroup GrpBaseBaseBaseTypes
53 \ingroup GrpLibOSGBase
54 \nohierarchy
57 struct OSGAny
59 bool operator ==(const OSGAny &) const
61 return true;
66 /*! \ingroup GrpBaseFieldTraits
67 \ingroup GrpLibOSGBase
70 template <>
71 struct FieldTraits<OSGAny> : public FieldTraitsTemplateBase<OSGAny>
73 private:
75 static DataType _type;
77 public:
79 typedef FieldTraits<OSGAny> Self;
81 enum { Convertible = Self::NotConvertible };
83 static OSG_BASE_DLLMAPPING
84 DataType &getType (void);
86 static const Char8 *getSName (void) { return "SFAny"; }
88 static const Char8 *getMName (void) { return "MFAny"; }
90 static OSGAny getDefault (void) { return OSGAny(); }
93 static SizeT getBinSize (const OSGAny &oObject)
95 return sizeof(UInt8);
98 static SizeT getBinSize (const OSGAny *pObjectStore,
99 SizeT uiNumObjects)
101 SizeT size = 0;
103 for(SizeT i = 0; i < uiNumObjects; ++i)
105 size += getBinSize(pObjectStore[i]);
108 return size;
112 static void copyToBin( BinaryDataHandler &pMem,
113 const OSGAny &oObject)
115 UInt8 uiTmp = 0;
117 pMem.putValue(uiTmp);
120 static void copyToBin( BinaryDataHandler &pMem,
121 const OSGAny *pObjectStore,
122 SizeT uiNumObjects)
124 for(SizeT i = 0; i < uiNumObjects; ++i)
126 copyToBin(pMem, pObjectStore[i]);
130 static void copyFromBin(BinaryDataHandler &pMem,
131 OSGAny &oObject)
133 UInt8 uiTmp = 0;
135 pMem.getValue(uiTmp);
138 static void copyFromBin(BinaryDataHandler &pMem,
139 OSGAny *pObjectStore,
140 SizeT uiNumObjects)
142 for(SizeT i = 0; i < uiNumObjects; ++i)
144 copyFromBin(pMem, pObjectStore[i]);
149 #ifndef DOXYGEN_SHOULD_SKIP_THIS
151 /*! \ingroup GrpBaseFieldSingle */
152 typedef SField<OSGAny> SFOSGAny;
153 /*! \ingroup GrpBaseFieldMulti */
154 typedef MField<OSGAny> MFOSGAny;
156 #else // these are the doxygen hacks
158 /*! \ingroup GrpBaseFieldSingle \ingroup GrpLibOSGBase */
159 struct SFOSGAny : public SField<OSGAny> {};
160 /*! \ingroup GrpBaseFieldMulti \ingroup GrpLibOSGBase */
161 struct MFOSGAny : public MField<OSGAny> {};
163 #endif // these are the doxygen hacks
165 OSG_END_NAMESPACE
167 #endif