32 #ifndef STEAM_ENGINE_TYPE_HANDLER_H 33 #define STEAM_ENGINE_TYPE_HANDLER_H 41 #include <boost/functional/hash.hpp> 51 using std::placeholders::_1;
58 template<
class X,
typename...ARGS>
60 buildIntoBuffer (
void* storageBuffer, ARGS&& ...args)
62 new(storageBuffer) X(forward<ARGS> (args)...);
67 destroyInBuffer (
void* storageBuffer)
69 X* embedded =
static_cast<X*
> (storageBuffer);
73 template<
typename CTOR,
typename DTOR>
75 deriveCombinedTypeIdenity()
78 boost::hash_combine (hash,
typeid(CTOR).hash_code());
79 boost::hash_combine (hash,
typeid(DTOR).hash_code());
106 typedef function<void(void*)> DoInBuffer;
108 DoInBuffer createAttached;
109 DoInBuffer destroyAttached;
129 template<
typename CTOR,
typename DTOR>
131 : createAttached (ctor)
132 , destroyAttached (dtor)
133 , identity{deriveCombinedTypeIdenity<CTOR,DTOR>()}
139 template<
class X,
typename...ARGS>
143 return TypeHandler ( bind (buildIntoBuffer<X,ARGS...>, _1, forward<ARGS> (args)...)
144 , destroyInBuffer<X>);
150 return bool(createAttached)
151 and bool(destroyAttached);
157 return handler.identity;
163 return (not left.isValid() and not right.isValid())
164 || (left.identity == right.identity);
169 return not (left == right);
Steam-Layer implementation namespace root.
TypeHandler()
build an invalid NIL TypeHandler
static const TypeHandler RAW
Marker for the default case: raw buffer without type handling.
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.
HashVal hash_value(ProcID const &procID)
generate registry hash value based on the distinct data in ProcID.
TypeHandler(CTOR ctor, DTOR dtor)
build a TypeHandler binding to arbitrary constructor and destructor functions.
static TypeHandler create(ARGS &&...args)
builder function defining a TypeHandler to place an object into the buffer, possibly with given ctor ...