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

#include "steam/engine/buffhandle.hpp"

Description

Handle for a buffer for processing data, abstracting away the actual implementation.

The real buffer pointer can be retrieved by dereferencing this smart-handle class.

Definition at line 115 of file buffhandle.hpp.

Public Types

typedef BuffPBuff
 

Public Member Functions

 BuffHandle (BufferDescriptor const &typeInfo, void *storage=0)
 
template<typename BU >
BU & accessAs ()
 convenience shortcut: access the buffer contents casted to a specific type. More...
 
template<typename BU >
BU & create ()
 convenience shortcut: place and maintain an object within the buffer. More...
 
void emit ()
 
HashVal entryID () const
 
bool isValid () const
 
 operator bool () const
 
Buffoperator* () const
 
void release ()
 
size_t size () const
 

Private Types

typedef StreamType::ImplFacade::DataBuffer Buff
 

Private Member Functions

void emergencyCleanup ()
 
template<typename BU >
void takeOwnershipFor ()
 
void takeOwnershipFor (BufferDescriptor const &type)
 Install a standard TypeHandler for an already locked buffer. More...
 

Private Attributes

BufferDescriptor descriptor_
 
BuffpBuffer_
 

Constructor & Destructor Documentation

◆ BuffHandle()

BuffHandle ( BufferDescriptor const &  typeInfo,
void *  storage = 0 
)
inline

a buffer handle may be obtained by "locking" a buffer from the corresponding BufferProvider

Definition at line 128 of file buffhandle.hpp.

Member Function Documentation

◆ create()

BU & create ( )
inline

convenience shortcut: place and maintain an object within the buffer.

This operation performs the necessary steps to attach an object; if the buffer isn't locked yet, it will do so. Moreover, the created object will be owned by the buffer management facilities, i.e. the destructor is registered as cleanup function.

Exceptions
error::Logicin case there is already another TypeHandler registered in charge of managing the buffer contents, or when the object to create would not fit into this buffer.

Definition at line 85 of file buffhandle-attach.hpp.

◆ accessAs()

BU & accessAs ( )
inline

convenience shortcut: access the buffer contents casted to a specific type.

Warning
this is a blind cast, there is no type safety.
Note
clients can utilise the metadata::LocalKey to keep track of some specific property of the buffer, like e.g. the type of object.

Definition at line 119 of file buffhandle-attach.hpp.

◆ takeOwnershipFor() [1/2]

void takeOwnershipFor ( )
inlineprivate

helper to attach an TypeHandler after-the fact.

Note
this prepares the buffer for placement-creating an embedded object. It doesn't actually create an object
Exceptions
error::Logicin case there is already another TypeHandler registered in charge of managing the buffer contents, or when the object to create would not fit into this buffer.

Definition at line 104 of file buffhandle-attach.hpp.

References BufferProvider::getDescriptor().

+ Here is the call graph for this function:

◆ takeOwnershipFor() [2/2]

void takeOwnershipFor ( BufferDescriptor const &  type)
private

Install a standard TypeHandler for an already locked buffer.

This causes the dtor function to be invoked when releasing this buffer. The assumption is that client code will placement-construct an object into this buffer right away, and thus we're taking ownership on that object.

Parameters
typea reference BufferDescriptor defining an embedded TypeHandler to use A copy of this TypeHandler will be stored into the local metadata for this buffer only, not altering the basic buffer type in any way
Exceptions
lifecycleerror when attempting to treat an buffer not in locked state
error::Logicin case of insufficient buffer space to hold the intended target object
Note
EX_STRONG

Definition at line 307 of file buffer-provider.cpp.

+ Inheritance diagram for BuffHandle:
+ Collaboration diagram for BuffHandle:

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