Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
ScopedCollection< I, siz > Class Template Reference

#include "lib/scoped-collection.hpp"

Description

template<class I, size_t siz = sizeof(I)>
class lib::ScopedCollection< I, siz >

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.

Template Parameters
Ithe nominal Base/Interface class for a family of types
sizmaximum storage required for the targets to be held inline

Definition at line 94 of file scoped-collection.hpp.

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...
 

Public Types

using iterator = IterAdapter< I *, const ScopedCollection * >
 
using const_iterator = IterAdapter< const I *, const ScopedCollection * >
 

Static Public Member Functions

template<typename IT >
static PullFrom< IT > pull (IT iter)
 fills by copy-constructing values pulled from the iterator IT
 

Public Member Functions

 ~ScopedCollection ()
 
 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.
 
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.
 
void clear ()
 
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.
 
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.
 
I & emplaceElement ()
 push a new element of default type to the end of this container
 
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 & operator[] (size_t index) const
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
size_t size () const
 
size_t capacity () const
 
bool empty () const
 

Friends

iterator begin (ScopedCollection &sco)
 
const iterator begin (ScopedCollection const &sco)
 
iterator end (ScopedCollection &sco)
 
const iterator end (ScopedCollection const &sco)
 
void iterNext (const ScopedCollection *, I *&pos)
 Iteration-logic: switch to next position.
 
void iterNext (const ScopedCollection *, const I *&pos)
 
template<typename POS >
bool checkPoint (const ScopedCollection *src, POS &pos)
 Iteration-logic: detect iteration end.
 

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 ()=default
 
 NonCopyable ()=default
 
 NonCopyable (NonCopyable const &)=delete
 
NonCopyableoperator= (NonCopyable const &)=delete
 

Private Attributes

size_t level_
 
size_t capacity_
 
ElementStorage elements_
 

Constructor & Destructor Documentation

◆ ~ScopedCollection()

template<class I , size_t siz = sizeof(I)>
~ScopedCollection ( )
inline

Definition at line 146 of file scoped-collection.hpp.

◆ ScopedCollection() [1/3]

template<class I , size_t siz = sizeof(I)>
ScopedCollection ( size_t  maxElements)
inlineexplicit

Definition at line 152 of file scoped-collection.hpp.

◆ ScopedCollection() [2/3]

template<class I , size_t siz = sizeof(I)>
template<class CTOR >
ScopedCollection ( size_t  maxElements,
CTOR  builder 
)
inline

creating a ScopedCollection in RAII-style: The embedded elements will be created immediately.

Ctor fails in case of any error during element creation.

Parameters
builderfunctor 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 166 of file scoped-collection.hpp.

◆ ScopedCollection() [3/3]

template<class I , size_t siz = sizeof(I)>
template<class TY >
ScopedCollection ( size_t  maxElements,
void(TY::*)(ElementHolder &)  builder,
TY *const  instance 
)
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

Parameters
buildermember function used to create the elements
instancethe owning class instance, on which the builder member function will be invoked ("this").

Definition at line 183 of file scoped-collection.hpp.

Member Typedef Documentation

◆ iterator

template<class I , size_t siz = sizeof(I)>
using iterator = IterAdapter< I *, const ScopedCollection *>

Definition at line 330 of file scoped-collection.hpp.

◆ const_iterator

template<class I , size_t siz = sizeof(I)>
using const_iterator = IterAdapter<const I *, const ScopedCollection *>

Definition at line 331 of file scoped-collection.hpp.

◆ ElementStorage

template<class I , size_t siz = sizeof(I)>
typedef std::unique_ptr<ElementHolder[]> ElementStorage
private

Definition at line 355 of file scoped-collection.hpp.

Member Function Documentation

◆ pull()

template<class I , size_t siz = sizeof(I)>
template<typename IT >
static PullFrom< IT > pull ( IT  iter)
inlinestatic

fills by copy-constructing values pulled from the iterator IT

Parameters
iterconvenience shortcut to pull from any given Lumiera Forward Iterator

Definition at line 203 of file scoped-collection.hpp.

◆ clear()

template<class I , size_t siz = sizeof(I)>
void clear ( )
inline

Definition at line 209 of file scoped-collection.hpp.

References ERROR_LOG_AND_IGNORE.

◆ populate()

template<class I , size_t siz = sizeof(I)>
void populate ( )
inline

init all elements default constructed

Definition at line 225 of file scoped-collection.hpp.

◆ populate_by() [1/2]

template<class I , size_t siz = sizeof(I)>
template<class CTOR >
void populate_by ( CTOR  builder)
inline

init all elements at once, invoking a builder functor for each.

Parameters
builderto 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 250 of file scoped-collection.hpp.

Referenced by OutputSlotImplBase::ConnectionManager< CON >::init().

+ Here is the caller graph for this function:

◆ populate_by() [2/2]

template<class I , size_t siz = sizeof(I)>
template<class TY >
void populate_by ( void(TY::*)(ElementHolder &)  builder,
TY *const  instance 
)
inline

variation of element initialisation, invoking a member function of some manager object for each collection element to be created.

Definition at line 272 of file scoped-collection.hpp.

◆ emplaceElement()

template<class I , size_t siz = sizeof(I)>
I & emplaceElement ( )
inline

push a new element of default type to the end of this container

Note
EX_STRONG

Definition at line 294 of file scoped-collection.hpp.

◆ emplace()

template<class I , size_t siz = sizeof(I)>
template<class TY = I, typename... ARGS>
TY & emplace ( ARGS &&...  args)
inline

push new entry at the end of this container and build object of type TY in place there

Definition at line 306 of file scoped-collection.hpp.

Referenced by lib::test::threadBenchmark().

+ Here is the caller graph for this function:

◆ operator[]()

template<class I , size_t siz = sizeof(I)>
I & operator[] ( size_t  index) const
inline

Definition at line 319 of file scoped-collection.hpp.

References LERR_.

◆ begin() [1/2]

template<class I , size_t siz = sizeof(I)>
iterator begin ( )
inline

Definition at line 334 of file scoped-collection.hpp.

◆ begin() [2/2]

template<class I , size_t siz = sizeof(I)>
const_iterator begin ( ) const
inline

Definition at line 335 of file scoped-collection.hpp.

◆ end() [1/2]

template<class I , size_t siz = sizeof(I)>
iterator end ( )
inline

Definition at line 336 of file scoped-collection.hpp.

◆ end() [2/2]

template<class I , size_t siz = sizeof(I)>
const_iterator end ( ) const
inline

Definition at line 337 of file scoped-collection.hpp.

◆ size()

template<class I , size_t siz = sizeof(I)>
size_t size ( ) const
inline

Definition at line 340 of file scoped-collection.hpp.

Referenced by OutputSlotImplBase::ConnectionManager< CON >::isActive().

+ Here is the caller graph for this function:

◆ capacity()

template<class I , size_t siz = sizeof(I)>
size_t capacity ( ) const
inline

Definition at line 341 of file scoped-collection.hpp.

◆ empty()

template<class I , size_t siz = sizeof(I)>
bool empty ( ) const
inline

Definition at line 342 of file scoped-collection.hpp.

◆ __ensureSufficientCapacity()

template<class I , size_t siz = sizeof(I)>
void __ensureSufficientCapacity ( )
inlineprivate

Definition at line 364 of file scoped-collection.hpp.

References LERR_.

◆ _access_begin()

template<class I , size_t siz = sizeof(I)>
I * _access_begin ( ) const
inlineprivate

Definition at line 407 of file scoped-collection.hpp.

◆ _access_end()

template<class I , size_t siz = sizeof(I)>
I * _access_end ( ) const
inlineprivate

Definition at line 408 of file scoped-collection.hpp.

Member Data Documentation

◆ level_

template<class I , size_t siz = sizeof(I)>
size_t level_
private

Definition at line 357 of file scoped-collection.hpp.

◆ capacity_

template<class I , size_t siz = sizeof(I)>
size_t capacity_
private

Definition at line 358 of file scoped-collection.hpp.

◆ elements_

template<class I , size_t siz = sizeof(I)>
ElementStorage elements_
private

Definition at line 359 of file scoped-collection.hpp.

Friends And Related Symbol Documentation

◆ begin [1/2]

template<class I , size_t siz = sizeof(I)>
iterator begin ( ScopedCollection< I, siz > &  sco)
friend

Definition at line 346 of file scoped-collection.hpp.

◆ begin [2/2]

template<class I , size_t siz = sizeof(I)>
const iterator begin ( ScopedCollection< I, siz > const &  sco)
friend

Definition at line 347 of file scoped-collection.hpp.

◆ end [1/2]

template<class I , size_t siz = sizeof(I)>
iterator end ( ScopedCollection< I, siz > &  sco)
friend

Definition at line 348 of file scoped-collection.hpp.

◆ end [2/2]

template<class I , size_t siz = sizeof(I)>
const iterator end ( ScopedCollection< I, siz > const &  sco)
friend

Definition at line 349 of file scoped-collection.hpp.

◆ iterNext [1/2]

template<class I , size_t siz = sizeof(I)>
void iterNext ( const ScopedCollection< I, siz > *  ,
I *&  pos 
)
friend

Iteration-logic: switch to next position.

Note
assuming here that the start address of the embedded object coincides with the start of an array element (ElementHolder)

Definition at line 379 of file scoped-collection.hpp.

◆ iterNext [2/2]

template<class I , size_t siz = sizeof(I)>
void iterNext ( const ScopedCollection< I, siz > *  ,
const I *&  pos 
)
friend

Definition at line 386 of file scoped-collection.hpp.

◆ checkPoint

template<class I , size_t siz = sizeof(I)>
template<typename POS >
bool checkPoint ( const ScopedCollection< I, siz > *  src,
POS &  pos 
)
friend

Iteration-logic: detect iteration end.

Definition at line 395 of file scoped-collection.hpp.

+ Inheritance diagram for ScopedCollection< I, siz >:
+ Collaboration diagram for ScopedCollection< I, siz >:

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