Lumiera  0.pre.03
»edit your freedom«
OpaqueHolder< BA, siz > Class Template Reference

#include "lib/opaque-holder.hpp"

Description

template<class BA, size_t siz = sizeof(BA)>
class lib::OpaqueHolder< BA, siz >

Inline buffer to hold and own an object while concealing the concrete type.

Access to the contained object is similar to a smart-pointer, but the object isn't heap allocated. OpaqueHolder may be created empty, which can be checked by a bool test. The whole compound is copyable if and only if the contained object is copyable.

using OpaqueHolder

OpaqueHolder instances are copyable value objects. They are created either empty, by copy from an existing OpaqueHolder, or by directly specifying the concrete object to embed. This target object will be copy-constructed into the internal buffer. Additionally, you may assign a new value, which causes the old value object to be destroyed and a new one to be copy-constructed into the buffer. Later on, the embedded value might be accessed

  • using the smart-ptr-like access through the common base interface BA
  • when knowing the exact type to access, the templated get might be an option
  • the empty state of the container and a isValid() on the target may be checked
  • a combination of both is available as a bool check on the OpaqueHolder instance.

For using OpaqueHolder, several assumptions need to be fulfilled

  • any instance placed into OpaqueHolder is below the specified maximum size
  • the caller cares for thread safety. No concurrent get calls while in mutation!
Template Parameters
BAthe nominal Base/Interface class for a family of types
sizmaximum storage required for the targets to be held inline

Definition at line 539 of file opaque-holder.hpp.

Public Member Functions

template<class SUB >
 OpaqueHolder (SUB const &obj)
 
BA & operator* () const
 
BA * operator-> () const
 
template<class SUB >
OpaqueHolderoperator= (SUB const &newContent)
 
- Public Member Functions inherited from InPlaceAnyHolder< siz, InPlaceAnyHolder_useCommonBase< BA > >
 InPlaceAnyHolder (SUB const &obj)
 
 InPlaceAnyHolder (InPlaceAnyHolder const &ref)
 
void clear ()
 
bool empty () const
 
SUB & get () const
 re-accessing the concrete contained object. More...
 
bool isValid () const
 
 operator bool () const
 
InPlaceAnyHolderoperator= (InPlaceAnyHolder const &ref)
 
InPlaceAnyHolderoperator= (SUB const &newContent)
 

Private Types

typedef InPlaceAnyHolder< siz, InPlaceAnyHolder_useCommonBase< BA > > InPlaceHolder
 

Additional Inherited Members

- Protected Member Functions inherited from InPlaceAnyHolder< siz, InPlaceAnyHolder_useCommonBase< BA > >
BaseP asBase () const
 < More...
 
Buffer & buff ()
 
const Buffer & buff () const
 
void clone_inBuff (InPlaceAnyHolder const &ref)
 
void killBuffer ()
 
void make_emptyBuff ()
 
void place_inBuff (SUB const &obj)
 
+ Inheritance diagram for OpaqueHolder< BA, siz >:
+ Collaboration diagram for OpaqueHolder< BA, siz >:

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