fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / Base / Field / OSGBoostPathFieldTraits.h
blob92c2a2c3055f5d4550ffce7cb812d6e24c070afc
1 /*---------------------------------------------------------------------------*\
2 * OpenSG Toolbox Toolbox *
3 * *
4 * *
5 * *
6 * *
7 * www.vrac.iastate.edu *
8 * *
9 * Authors: David Kabala *
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 \*---------------------------------------------------------------------------*/
30 #ifndef _OSGBOOSTPATHFIELDTRAITS_H_
31 #define _OSGBOOSTPATHFIELDTRAITS_H_
32 #ifdef __sgi
33 #pragma once
34 #endif
36 //---------------------------------------------------------------------------
37 // Includes
38 //---------------------------------------------------------------------------
40 #include "OSGBaseFieldTraits.h"
42 OSG_BEGIN_NAMESPACE
44 // The FieldDataTraits class contains the methods needed to implement
45 // the features a Field data element needs to have
48 template <>
49 struct FieldTraits<BoostPath> : public FieldTraitsTemplateBase<BoostPath>
51 // Static DataType descriptor, see OSGNewFieldType.cpp for implementation
52 static DataType _type;
54 typedef FieldTraits<BoostPath> Self;
56 // Define whether string conversions are available. It is strongly
57 // recommended to implement both.
59 enum { Convertible = (Self::ToStreamConvertible |
60 Self::FromStringConvertible) };
62 // access method for the DataType
63 static OSG_BASE_DLLMAPPING
64 DataType &getType (void);
66 // Access to the names of the actual Fields
67 static const Char8 *getSName (void) { return "SFBoostPath"; }
68 static const Char8 *getMName (void) { return "MFBoostPath"; }
70 // Create a default instance of the class, needed for Field creation
71 static BoostPath getDefault (void) { return BoostPath(); }
75 // This is where it gets interesting: the conversion functions
77 // String conversion
79 // Output inVal into outVal
80 static void putToStream(const BoostPath &inVal,
81 OutStream &outVal)
83 outVal << inVal.string();
86 // Setup outVal from the contents of inVal
87 static bool getFromCString( BoostPath &outVal,
88 const Char8 *&inVal)
90 std::string oPathString("");
92 if(FieldTraits<std::string>::getFromCString(oPathString, inVal))
94 outVal = oPathString;
96 return true;
98 else
100 return false;
104 // Binary conversion
106 // Return the size of the binary version in byte
107 static SizeT getBinSize(const BoostPath &oObj)
109 return FieldTraits<std::string>::getBinSize(oObj.string());
112 static SizeT getBinSize(const BoostPath *pObjStore,
113 SizeT uiNumObjs)
115 //Size:
116 //Sum of all the objs
117 SizeT uiSizeSum = 0;
119 for(SizeT i = 0; i < uiNumObjs; ++i)
121 uiSizeSum +=
122 FieldTraits<std::string>::getBinSize(pObjStore[i].string());
125 return uiSizeSum;
128 // Copy the object into the BinaryDataHandler
129 static void copyToBin ( BinaryDataHandler &oMem,
130 const BoostPath &oObj)
132 FieldTraits<std::string>::copyToBin(oMem, oObj.string());
135 static void copyToBin ( BinaryDataHandler &oMem,
136 const BoostPath *pObjStore,
137 SizeT uiNumObjs)
139 for(SizeT i = 0; i < uiNumObjs; ++i)
141 copyToBin(oMem, pObjStore[i]);
146 // Copy the object from the BinaryDataHandler
147 static void copyFromBin ( BinaryDataHandler &oMem,
148 BoostPath &oObj)
150 std::string oPathString("");
152 FieldTraits<std::string>::copyFromBin(oMem, oPathString);
154 oObj = oPathString;
157 static void copyFromBin ( BinaryDataHandler &oMem,
158 BoostPath *pObjStore,
159 SizeT uiNum)
161 for(UInt32 i = 0; i < uiNum; ++i)
163 copyFromBin(oMem, pObjStore[i]);
169 OSG_END_NAMESPACE
171 #endif /* _OSG_PATH_TYPE_H_ */