Lumiera
0.pre.03
»edit your freedom«
|
#include "lib/scoped-collection.hpp"
A fixed collection of non-copyable polymorphic objects.
All child objects reside in a common chunk of storage and are owned and managed by this collection holder. Array style access and iteration is provided.
I | the nominal Base/Interface class for a family of types |
siz | maximum storage required for the targets to be held inline |
Definition at line 103 of file scoped-collection.hpp.
Public Types | |
using | const_iterator = IterAdapter< const I *, const ScopedCollection * > |
using | iterator = IterAdapter< I *, const ScopedCollection * > |
Public Member Functions | |
ScopedCollection (size_t maxElements) | |
template<class CTOR > | |
ScopedCollection (size_t maxElements, CTOR builder) | |
creating a ScopedCollection in RAII-style: The embedded elements will be created immediately. More... | |
template<class TY > | |
ScopedCollection (size_t maxElements, void(TY::*builder)(ElementHolder &), TY *const instance) | |
variation of RAII-style: using a builder function, which is a member of some object. More... | |
iterator | begin () |
const_iterator | begin () const |
size_t | capacity () const |
void | clear () |
template<class TY = I, typename... ARGS> | |
TY & | emplace (ARGS &&...args) |
push new entry at the end of this container and build object of type TY in place there | |
I & | emplaceElement () |
push a new element of default type to the end of this container More... | |
bool | empty () const |
iterator | end () |
const_iterator | end () const |
I & | operator[] (size_t index) const |
void | populate () |
init all elements default constructed | |
template<class CTOR > | |
void | populate_by (CTOR builder) |
init all elements at once, invoking a builder functor for each. More... | |
template<class TY > | |
void | populate_by (void(TY::*builder)(ElementHolder &), TY *const instance) |
variation of element initialisation, invoking a member function of some manager object for each collection element to be created. | |
size_t | size () const |
Static Public Member Functions | |
template<typename IT > | |
static PullFrom< IT > | pull (IT iter) |
fills by copy-constructing values pulled from the iterator IT More... | |
Classes | |
class | ElementHolder |
Storage Frame to hold one Child object. More... | |
class | FillAll |
class | FillWith |
fills the ScopedCollection with default constructed I-instances More... | |
class | PullFrom |
fills the ScopedCollection with default constructed TY-instances More... | |
Friends | |
iterator | begin (ScopedCollection &sco) |
const iterator | begin (ScopedCollection const &sco) |
template<typename POS > | |
bool | checkPoint (const ScopedCollection *src, POS &pos) |
Iteration-logic: detect iteration end. More... | |
iterator | end (ScopedCollection &sco) |
const iterator | end (ScopedCollection const &sco) |
void | iterNext (const ScopedCollection *, I *&pos) |
Iteration-logic: switch to next position. More... | |
void | iterNext (const ScopedCollection *, const I *&pos) |
Private Types | |
typedef std::unique_ptr< ElementHolder[]> | ElementStorage |
Private Member Functions | |
void | __ensureSufficientCapacity () |
I * | _access_begin () const |
I * | _access_end () const |
Private Member Functions inherited from NonCopyable | |
NonCopyable (NonCopyable const &)=delete | |
NonCopyable & | operator= (NonCopyable const &)=delete |
Private Attributes | |
size_t | capacity_ |
ElementStorage | elements_ |
size_t | level_ |
|
inline |
creating a ScopedCollection in RAII-style: The embedded elements will be created immediately.
Ctor fails in case of any error during element creation.
builder | functor to be invoked for each "slot". It gets an ElementHolder& as parameter, and should use this to create an object of some I-subclass |
Definition at line 175 of file scoped-collection.hpp.
|
inline |
variation of RAII-style: using a builder function, which is a member of some object.
This supports the typical usage situation, where a manager object builds a ScopedCollection of some components
builder | member function used to create the elements |
instance | the owning class instance, on which the builder member function will be invoked ("this"). |
Definition at line 192 of file scoped-collection.hpp.
|
inlinestatic |
fills by copy-constructing values pulled from the iterator IT
iter | convenience shortcut to pull from any given Lumiera Forward Iterator |
Definition at line 212 of file scoped-collection.hpp.
|
inline |
init all elements at once, invoking a builder functor for each.
builder | to create the individual elements this functor is responsible to invoke the appropriate ElementHolder::create function, which places a new element into the storage frame passed as parameter. |
Definition at line 259 of file scoped-collection.hpp.
|
inline |
push a new element of default type to the end of this container
Definition at line 303 of file scoped-collection.hpp.
Referenced by ScopedCollection_test::building_StackStyle().
|
friend |
Iteration-logic: switch to next position.
Definition at line 388 of file scoped-collection.hpp.
|
friend |
Iteration-logic: detect iteration end.
Definition at line 404 of file scoped-collection.hpp.