41 #ifndef STEAM_ENGINE_TYPE_HANDLER_H 42 #define STEAM_ENGINE_TYPE_HANDLER_H 49 #include <boost/functional/hash.hpp> 58 using std::placeholders::_1;
67 buildIntoBuffer (
void* storageBuffer)
69 new(storageBuffer) X();
72 template<
class X,
typename A1>
74 buildIntoBuffer_A1 (
void* storageBuffer, A1 arg1)
76 new(storageBuffer) X(arg1);
81 destroyInBuffer (
void* storageBuffer)
83 X* embedded =
static_cast<X*
> (storageBuffer);
87 template<
typename CTOR,
typename DTOR>
89 deriveCombinedTypeIdenity()
92 boost::hash_combine (hash,
typeid(CTOR).hash_code());
93 boost::hash_combine (hash,
typeid(DTOR).hash_code());
120 typedef function<void(void*)> DoInBuffer;
122 DoInBuffer createAttached;
123 DoInBuffer destroyAttached;
140 template<
typename CTOR,
typename DTOR>
142 : createAttached (ctor)
143 , destroyAttached (dtor)
144 , identity{deriveCombinedTypeIdenity<CTOR,DTOR>()}
154 return TypeHandler (buildIntoBuffer<X>, destroyInBuffer<X>);
157 template<
class X,
typename A1>
161 return TypeHandler ( bind (buildIntoBuffer_A1<X,A1>, _1, a1)
162 , destroyInBuffer<X>);
168 return bool(createAttached)
169 and bool(destroyAttached);
175 return handler.identity;
181 return (not left.isValid() and not right.isValid())
182 || (left.identity == right.identity);
187 return not (left == right);
static TypeHandler create()
builder function defining a TypeHandler to place a default-constructed object into the buffer...
Steam-Layer implementation namespace root.
TypeHandler()
build an invalid NIL TypeHandler
Lumiera error handling (C++ interface).
Hash value types and utilities.
size_t HashVal
a STL compatible hash value
A pair of functors to maintain a datastructure within a buffer.
TypeHandler(CTOR ctor, DTOR dtor)
build a TypeHandler binding to arbitrary constructor and destructor functions.