Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
TypeHandler Struct Reference

#include "steam/engine/type-handler.hpp"

Description

A pair of functors to maintain a datastructure within a buffer.

TypeHandler describes how to outfit the buffer in a specific way. Special convenience builder function(s) are provided to create a TypeHandler performing placement-new into a buffer given on invocation.

Note
engine::BufferMetadata uses a TypeHandler to represent any special treatment of a buffer space. When defined, the buffer will be prepared on locking and cleanup will be invoked automatically when releasing.
Warning
comparison and hash values are based merely on the type of the Ctor and Dtor functions – so all type handlers bound to the same functor type count as equivalent. This might not be what you'd expect, however, there is no sane way to test for equivalence of functors anyway. In the typical usage, a TypeHandler will be created by TypeHandler::create<TY>(), and thus will be dedicated to a given type to be placed into the storage buffer.

Definition at line 104 of file type-handler.hpp.

Public Types

using DoInBuffer = function< void(void *)>
 

Static Public Attributes

static const TypeHandler RAW {}
 Marker for the default case: raw buffer without type handling.
 

Public Attributes

DoInBuffer createAttached
 
DoInBuffer destroyAttached
 
HashVal identity
 

Static Public Member Functions

template<class X , typename... ARGS>
static TypeHandler create (ARGS &&...args)
 builder function for a pre-configured TypeHandler to place a new instance into the buffer, possibly with given ctor arguments.
 

Public Member Functions

 TypeHandler ()
 build an invalid NIL TypeHandler
 
template<typename CTOR , typename DTOR >
 TypeHandler (CTOR ctor, DTOR dtor)
 build a TypeHandler binding to arbitrary constructor and destructor functions.
 
bool isValid () const
 

Friends

HashVal hash_value (TypeHandler const &handler)
 
bool operator== (TypeHandler const &left, TypeHandler const &right)
 
bool operator!= (TypeHandler const &left, TypeHandler const &right)
 

Constructor & Destructor Documentation

◆ TypeHandler() [1/2]

TypeHandler ( )
inline

build an invalid NIL TypeHandler

Definition at line 116 of file type-handler.hpp.

Referenced by TypeHandler::create().

+ Here is the caller graph for this function:

◆ TypeHandler() [2/2]

template<typename CTOR , typename DTOR >
TypeHandler ( CTOR  ctor,
DTOR  dtor 
)
inline

build a TypeHandler binding to arbitrary constructor and destructor functions.

On invocation, these functions get a void* to the buffer.

Note
the functor objects created from these operations might be shared for handling multiple buffers. Be careful with any state or arguments.

Definition at line 130 of file type-handler.hpp.

Member Typedef Documentation

◆ DoInBuffer

using DoInBuffer = function<void(void*)>

Definition at line 106 of file type-handler.hpp.

Member Function Documentation

◆ create()

template<class X , typename... ARGS>
static TypeHandler create ( ARGS &&...  args)
inlinestatic

builder function for a pre-configured TypeHandler to place a new instance into the buffer, possibly with given ctor arguments.

Warning
additional ctor arguments will be materialised and stored as copy in the TypeHandler, for repeated use.
Remarks
need to change the instantiation type to LValue-ref as pointed out on [Stackoverflow]

Definition at line 146 of file type-handler.hpp.

References TypeHandler::TypeHandler().

+ Here is the call graph for this function:

◆ isValid()

bool isValid ( ) const
inline

Definition at line 153 of file type-handler.hpp.

References TypeHandler::createAttached, and TypeHandler::destroyAttached.

Referenced by BufferMetadataKey_test::verifyTypeHandler().

+ Here is the caller graph for this function:

Member Data Documentation

◆ createAttached

◆ destroyAttached

◆ identity

HashVal identity

Definition at line 110 of file type-handler.hpp.

◆ RAW

const TypeHandler RAW {}
static

Marker for the default case: raw buffer without type handling.

Definition at line 113 of file type-handler.hpp.

Referenced by steam::engine::anonymous_namespace{buffer-metadata.hpp}::nontrivial(), and BufferMetadataKey_test::verifyTypeSpecialisation().

Friends And Related Symbol Documentation

◆ hash_value

HashVal hash_value ( TypeHandler const &  handler)
friend

Definition at line 160 of file type-handler.hpp.

◆ operator==

bool operator== ( TypeHandler const &  left,
TypeHandler const &  right 
)
friend

Definition at line 166 of file type-handler.hpp.

◆ operator!=

bool operator!= ( TypeHandler const &  left,
TypeHandler const &  right 
)
friend

Definition at line 172 of file type-handler.hpp.

+ Collaboration diagram for TypeHandler:

The documentation for this struct was generated from the following files: