Lumiera
0.pre.03
»edit your freedom«
|
#include "lib/opaque-holder.hpp"
Inline buffer to hold and own an object while concealing the concrete type.
The object is given either as ctor parameter or by direct assignment; it is copy-constructed into the buffer. It is necessary to specify the required buffer storage space as a template parameter. InPlaceAnyHolder may be created empty or cleared afterwards, and this #empty() state may be detected at runtime. In a similar vein, when the stored object has a bool
validity check, this can be accessed though isValid(). Moreover !empty() && isValid()
may be tested as by bool
conversion of the Holder object. The whole compound is copyable if and only if the contained object is copyable.
Definition at line 210 of file opaque-holder.hpp.
Public Member Functions | |
template<class SUB > | |
InPlaceAnyHolder (SUB const &obj) | |
InPlaceAnyHolder (InPlaceAnyHolder const &ref) | |
void | clear () |
bool | empty () const |
template<class SUB > | |
SUB & | get () const |
re-accessing the concrete contained object. More... | |
bool | isValid () const |
operator bool () const | |
InPlaceAnyHolder & | operator= (InPlaceAnyHolder const &ref) |
template<class SUB > | |
InPlaceAnyHolder & | operator= (SUB const &newContent) |
Classes | |
struct | Buff |
concrete subclass to manage a specific kind of contained object. More... | |
struct | Buffer |
Inner capsule managing the contained object (interface) More... | |
struct | EmptyBuff |
special case: no stored object More... | |
Protected Member Functions | |
BaseP | asBase () const |
< More... | |
Buffer & | buff () |
const Buffer & | buff () const |
void | clone_inBuff (InPlaceAnyHolder const &ref) |
void | killBuffer () |
void | make_emptyBuff () |
template<class SUB > | |
void | place_inBuff (SUB const &obj) |
Private Types | |
enum | { BUFFSIZE = sizeof(Buffer) } |
typedef AccessPolicy::Base * | BaseP |
Private Attributes | |
char | storage_ [BUFFSIZE] |
embedded buffer actually holding the concrete Buff object, which in turn holds and manages the target object. More... | |
|
inlineprotected |
|
inline |
re-accessing the concrete contained object.
This requires exact knowledge of the actual type of the element currently in storage. OpaqueHolder does not provide any "probing" or visitation mechanism.
lumiera::error::Logic | when conversion/access fails |
lumiera::error::Invalid | when accessing an empty holder |
Definition at line 461 of file opaque-holder.hpp.
Referenced by WrappedStandardExeBuilder::__call__().
|
private |
embedded buffer actually holding the concrete Buff object, which in turn holds and manages the target object.
Definition at line 321 of file opaque-holder.hpp.