Lumiera  0.pre.03
»edit your freedom«
BufferMetadata Class Reference

#include "steam/engine/buffer-metadata.hpp"

Description

Registry for managing buffer metadata.

This is an implementation level service, used by the standard BufferProvider implementation. Each metadata registry (instance) defines and maintains a family of "buffer types"; beyond the buffer storage size, the concrete meaning of those types is tied to the corresponding BufferProvider implementation and remains opaque. These types are represented as hierarchically linked hash keys. The implementation may bind a TypeHandler to a specific type, allowing automatic invocation of a "constructor" and "destructor" function on each buffer of this type, when locking or freeing the corresponding buffer.

Definition at line 539 of file buffer-metadata.hpp.

Public Types

typedef metadata::Entry Entry
 
typedef metadata::Key Key
 

Public Member Functions

 BufferMetadata (Literal implementationID)
 establish a metadata registry. More...
 
Entryget (HashVal hashID)
 access the metadata record registered with the given hash key. More...
 
bool isKnown (HashVal key) const
 
bool isLocked (HashVal key) const
 
Key key (size_t storageSize, TypeHandler instanceFunc=RAW_BUFFER, LocalKey specifics=UNSPECIFIC)
 combine the distinguishing properties into a single type key, which will be known/remembered from that point on. More...
 
Key key (Key const &parentKey, TypeHandler const &instanceFunc)
 create a sub-type, using a different type/handler functor
 
Key key (Key const &parentKey, LocalKey specifics)
 create a sub-type, using a different private-ID (implementation defined)
 
Key const & key (Key const &parentKey, void *concreteBuffer, LocalKey const &implID=UNSPECIFIC)
 shortcut to access the Key part of a (probably new) Entry describing a concrete buffer at the given address More...
 
Entrylock (Key const &parentKey, void *concreteBuffer, LocalKey const &implID=UNSPECIFIC, bool onlyNew=false)
 core operation to access or create a concrete buffer metadata entry. More...
 
EntrymarkLocked (Key const &parentKey, void *buffer, LocalKey const &implID=UNSPECIFIC)
 combine the type (Key) with a concrete buffer, thereby marking this buffer as locked. More...
 
void release (HashVal key)
 purge the bare metadata Entry from the metadata tables. More...
 
void release (Entry const &entry)
 

Private Member Functions

void maybeStore (Key const &key)
 
Entrystore_and_lock (Entry const &metadata)
 
template<typename PAR , typename DEF >
Key trackKey (PAR parent, DEF specialisation)
 
- Private Member Functions inherited from NonCopyable
 NonCopyable (NonCopyable const &)=delete
 
NonCopyableoperator= (NonCopyable const &)=delete
 

Private Attributes

HashVal family_
 
Literal id_
 
metadata::Table table_
 

Constructor & Destructor Documentation

◆ BufferMetadata()

BufferMetadata ( Literal  implementationID)
inline

establish a metadata registry.

Such will maintain a family of buffer type entries and provide a service for storing and retrieving metadata for concrete buffer entries associated with these types.

Parameters
implementationIDto distinguish families of type keys belonging to different registries.

Definition at line 559 of file buffer-metadata.hpp.

Member Function Documentation

◆ key() [1/2]

Key key ( size_t  storageSize,
TypeHandler  instanceFunc = RAW_BUFFER,
LocalKey  specifics = UNSPECIFIC 
)
inline

combine the distinguishing properties into a single type key, which will be known/remembered from that point on.

Properties are combined according to a fixed type specialisation order, with the buffer size forming the base level, possible TypeHandler functors the second level, and implementation defined LocalKey entries the third level. All these levels describe abstract type keys, not entries for concrete buffers. The latter are always created as children of a known type key.

Definition at line 575 of file buffer-metadata.hpp.

◆ key() [2/2]

Key const& key ( Key const &  parentKey,
void *  concreteBuffer,
LocalKey const &  implID = UNSPECIFIC 
)
inline

shortcut to access the Key part of a (probably new) Entry describing a concrete buffer at the given address

Note
might create/register a new Entry as a side-effect

Definition at line 611 of file buffer-metadata.hpp.

◆ lock()

Entry& lock ( Key const &  parentKey,
void *  concreteBuffer,
LocalKey const &  implID = UNSPECIFIC,
bool  onlyNew = false 
)
inline

core operation to access or create a concrete buffer metadata entry.

The hashID of the entry in question is built, based on the parentKey, which denotes a buffer type, and the concrete buffer address. If yet unknown, a new concrete buffer metadata Entry is created and initialised to LOCKED state. Otherwise just the existing Entry is fetched.

Note
this function really activates the buffer. In case the type (Key) involves a TypeHandler (functor), its constructor function will be invoked, if actually a new entry gets created. Typically this mechanism will be used to placement-create an object into the buffer.
Parameters
parentKeya key describing the type of the buffer
concreteBufferstorage pointer, must not be NULL
onlyNewdisallow fetching an existing entry
Exceptions
error::Logicwhen #onlyNew is set, but an equivalent entry was registered previously. This indicates a serious error in buffer lifecycle management.
error::Invalidwhen invoked with NULL buffer. Use the key functions instead to register and track type keys.
Returns
reference to the entry stored in the metadata table.
Warning
the exposed reference might become invalid when the buffer is released or re-used later.

Definition at line 643 of file buffer-metadata.hpp.

◆ get()

Entry& get ( HashVal  hashID)
inline

access the metadata record registered with the given hash key.

This might be a pseudo entry in case of a Key describing a buffer type. Otherwise, the entry associated with a concrete buffer pointer is returned by reference, an can be modified (e.g. state change)

Parameters
hashIDwhich can be calculated from the Key
Exceptions
error::Invalidwhen there is no such entry
Note
use #isKnown to check existence

Definition at line 678 of file buffer-metadata.hpp.

References steam::mobject::session::query::anonymous_namespace{fake-configrules.cpp}::entry(), and Table::fetch().

Referenced by WrappedStandardExeBuilder::__call__().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ markLocked()

Entry& markLocked ( Key const &  parentKey,
void *  buffer,
LocalKey const &  implID = UNSPECIFIC 
)
inline

combine the type (Key) with a concrete buffer, thereby marking this buffer as locked.

Store a concrete metadata Entry to account for this fact. This might include invoking a constructor function, in case the type (Key) defines a (nontrivial) TypeHandler.

Exceptions
error::Fatalwhen locking a NULL buffer
exceptionswhich might be raised by a TypeHandler's constructor function. In this case, the Entry remains created, but is marked as FREE

Definition at line 716 of file buffer-metadata.hpp.

◆ release()

void release ( HashVal  key)
inline

purge the bare metadata Entry from the metadata tables.

Exceptions
error::Logicif the entry isn't marked FREE already

Definition at line 729 of file buffer-metadata.hpp.

References steam::mobject::session::query::anonymous_namespace{fake-configrules.cpp}::entry(), Table::fetch(), and steam::engine::FREE.

+ Here is the call graph for this function:
+ Inheritance diagram for BufferMetadata:
+ Collaboration diagram for BufferMetadata:

The documentation for this class was generated from the following file: