1 /*---------------------------------------------------------------------------*\
2 * OpenSG Toolbox Toolbox *
7 * www.vrac.iastate.edu *
9 * Authors: David Kabala *
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 \*---------------------------------------------------------------------------*/
30 #ifndef _OSGBOOSTPATHFIELDTRAITS_H_
31 #define _OSGBOOSTPATHFIELDTRAITS_H_
36 //---------------------------------------------------------------------------
38 //---------------------------------------------------------------------------
40 #include "OSGBaseFieldTraits.h"
44 // The FieldDataTraits class contains the methods needed to implement
45 // the features a Field data element needs to have
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
79 // Output inVal into outVal
80 static void putToStream(const BoostPath
&inVal
,
83 outVal
<< inVal
.string();
86 // Setup outVal from the contents of inVal
87 static bool getFromCString( BoostPath
&outVal
,
90 std::string
oPathString("");
92 if(FieldTraits
<std::string
>::getFromCString(oPathString
, inVal
))
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
,
116 //Sum of all the objs
119 for(SizeT i
= 0; i
< uiNumObjs
; ++i
)
122 FieldTraits
<std::string
>::getBinSize(pObjStore
[i
].string());
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
,
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
,
150 std::string
oPathString("");
152 FieldTraits
<std::string
>::copyFromBin(oMem
, oPathString
);
157 static void copyFromBin ( BinaryDataHandler
&oMem
,
158 BoostPath
*pObjStore
,
161 for(UInt32 i
= 0; i
< uiNum
; ++i
)
163 copyFromBin(oMem
, pObjStore
[i
]);
171 #endif /* _OSG_PATH_TYPE_H_ */