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

Description

Test:
ScopedCollection manages a fixed set of objects, but these child objects are noncopyable, may be polymorphic, an can be created either all at once or chunk wise.

The API is similar to a vector and allows for element access and iteration.

Definition at line 106 of file scoped-collection-test.cpp.

Classes

class  ManagerDemo
 
class  Populator
 Functor to populate the Collection. More...
 

Private Member Functions

void building_RAII_Style ()
 
void building_StackStyle ()
 
void iterating ()
 
virtual void run (Arg)
 
void simpleUsage ()
 
void verify_defaultPopulator ()
 
void verify_embeddedCollection ()
 
void verify_iteratorPopulator ()
 
void verify_subclassPopulator ()
 

Member Function Documentation

◆ building_StackStyle()

void building_StackStyle ( )
inlineprivate
Test:
using the ScopedCollection to hold a variable and possibly increasing number of elements, within the fixed limits of the maximum capacity defined by the ctor parameter.

Any new elements will be created behind the already existing objects. In case of failure while creating an element, only this element gets destroyed, the rest of the container remains intact.

Definition at line 227 of file scoped-collection-test.cpp.

References ScopedCollection< I, siz >::emplace(), and ScopedCollection< I, siz >::emplaceElement().

+ Here is the call graph for this function:

◆ building_RAII_Style()

void building_RAII_Style ( )
inlineprivate
Test:
using the ScopedCollection according to the RAII pattern.

For this usage style, the collection is filled right away, during construction. If anything goes wrong, the whole collection is cleared and invalidated. Consequently there is no tangible "lifecycle" at the usage site. Either the collection is fully usable, or not at all. This requires the client to provide a functor (callback) to define the actual objects to be created within the ScopedCollection. These may as well be subclasses of the base type I, provided the general element storage size #siz was chosen sufficiently large to hold those subclass instances.

This test demonstrates the most elaborate usage pattern, where the client provides a full blown functor object #Populator, which even has embedded state. Generally speaking, anything exposing a suitable function call operator is acceptable.

Definition at line 307 of file scoped-collection-test.cpp.

◆ verify_defaultPopulator()

void verify_defaultPopulator ( )
inlineprivate
Test:
for using ScopedCollection in RAII style, several pre-defined "populators" are provided.

The most obvious one being just to fill the collection with default constructed objects.

Definition at line 388 of file scoped-collection-test.cpp.

◆ verify_embeddedCollection()

void verify_embeddedCollection ( )
inlineprivate
Test:
simulate the typical situation of a manager owning some embedded components.

Here, our ManagerDemo instance owns a collection of numbers 50..1. They are created right while initialising the manager, and this initialisation is done by invoking a member function of the manager

Definition at line 456 of file scoped-collection-test.cpp.

+ Inheritance diagram for ScopedCollection_test:
+ Collaboration diagram for ScopedCollection_test:

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