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 _OSGCOMPUTEFUNCTORFIELDTRAITS_H_
40 #define _OSGCOMPUTEFUNCTORFIELDTRAITS_H_
45 #include "OSGFieldTraits.h"
46 #include "OSGDataType.h"
48 #include "OSGContainerForwards.h"
49 #include "OSGContribComputeBaseDef.h"
53 class HardwareContext
;
55 typedef boost::function
<void (HardwareContext
*, DrawEnv
*)> ComputeFunctor
;
57 struct ComputeFunctorCallback
61 std::string _createSymbol
;
63 typedef std::allocator
<void> Alloc
;
65 ComputeFunctorCallback(void) : _func(), _uiId(), _createSymbol() {}
68 #if !defined(OSG_DO_DOC) || (OSG_DOC_LEVEL >= 3)
70 #ifdef OSG_DOC_FILES_IN_MODULE
79 #if !defined(OSG_DOC_DEV_TRAITS)
80 /*! \hideinhierarchy */
84 struct FieldTraits
<ComputeFunctorCallback
> :
85 public FieldTraitsTemplateBase
<ComputeFunctorCallback
>
89 static DataType _type
;
93 typedef FieldTraits
<ComputeFunctorCallback
> Self
;
96 enum { Convertible
= Self::NotConvertible
};
98 static OSG_CONTRIBCOMPUTEBASE_DLLMAPPING
99 DataType
&getType (void);
101 static const Char8
*getSName (void)
103 return "SFComputeFunctorCallback";
106 static const Char8
*getMName (void)
108 return "MFComputeFunctorCallback";
111 static SizeT
getBinSize(const ComputeFunctorCallback
&)
116 static SizeT
getBinSize(const ComputeFunctorCallback
*,
119 return 0 * uiNumObjects
;
122 static void copyToBin( BinaryDataHandler
&pMem
,
123 const ComputeFunctorCallback
&pObject
)
128 if(pObject
== NullFC
)
130 // containerId=0 indicates an Null Ptr
135 containerId
= pObject
->getId();
138 pMem
.putValue(containerId
);
142 static void copyToBin( BinaryDataHandler
&pMem
,
143 const ComputeFunctorCallback
*pObjectStore
,
147 for(UInt32 i
= 0; i
< uiNumObjects
; i
++)
149 copyToBin(pMem
, pObjectStore
[i
]);
154 static void copyFromBin(BinaryDataHandler
&pMem
,
155 ComputeFunctorCallback
&pObject
)
160 pMem
.getValue(containerId
);
164 pObject
= FieldContainerFactory::the()->getMappedContainer(containerId
);
173 static void copyFromBin(BinaryDataHandler
&pMem
,
174 ComputeFunctorCallback
*pObjectStore
,
178 for(UInt32 i
= 0; i
< uiNumObjects
; i
++)
180 copyFromBin(pMem
, pObjectStore
[i
]);
187 #if !defined(OSG_DOC_DEV_TRAITS)
188 /*! \class FieldTraitsTemplateBase<NodeCorePtr> */
189 /*! \hideinhierarchy */
192 #endif // !defined(OSG_DO_DOC) || (OSG_DOC_LEVEL >= 3)
196 #endif /* _OSGCOMPUTEFUNCTORFIELDTRAITS_H_ */