PLCnext API Documentation  22.9.0.33
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
Arp::Enumerator< T > Class Template Referenceabstract

This class defines a base class for all enumerator implementations and some predefined enumerators as nested classes. More...

#include <Enumerator.hxx>

Inheritance diagram for Arp::Enumerator< T >:
Inheritance graph

Classes

class  Composite
 Use this class to build a single enumerator by two given enumerator, e.g. to enumerate multiple container/collections or trees. More...
 
class  Empty
 Implements an empty enumerator, that is, the first call of MoveNext() will return false. More...
 
class  StackComposite
 Use this class to build a single enumerator by two given enumerator, e.g. to enumerate multiple container/collections. More...
 
class  StlAdapter
 This class implements an enumerator adapter for STL container based on iterators. More...
 

Public Member Functions

 Enumerator (void)=default
 Constructs an Enumerator instance. More...
 
 Enumerator (const Enumerator &arg)=default
 Copy constructor. More...
 
Enumeratoroperator= (const Enumerator &arg)=default
 Assignment operator. More...
 
virtual ~Enumerator (void)=default
 Destructs this instance and frees all resources. More...
 
virtual bool MoveNext (void)=0
 Moves this enumerator to the next position. More...
 
GetCurrent (void) override
 Gets the element at the current position. More...
 

Static Public Member Functions

static IEnumerator< T >::Ptr CreateEmpty (void)
 Creates an empty enumerator. More...
 
static IEnumerator< T >::Ptr CreateComposite (typename IEnumerator< T >::Ptr first, typename IEnumerator< T >::Ptr second)
 Creates a composite enumerator from the two given enumerators, e.g. to enumerate trees easily. More...
 
template<class TIterator >
static IEnumerator< T >::Ptr CreateStlAdapter (TIterator begin, TIterator end)
 Creates an enumerator adapter from the given STL iterators. More...
 
template<class TContainer >
static IEnumerator< T >::Ptr CreateStlAdapter (TContainer &c)
 Creates an enumerator adapter from the given STL container. More...
 
template<class TContainer >
static IEnumerator< T >::Ptr CreateKeysAdapter (TContainer &c)
 Creates an enumerator adapter from the given STL map enumerating the keys. More...
 
template<class TContainer >
static IEnumerator< T >::Ptr CreateKeysAdapter (const TContainer &c)
 Creates an enumerator adapter from the given const STL map enumerating the keys. More...
 
template<class TContainer >
static IEnumerator< T >::Ptr CreateMappedAdapter (TContainer &c)
 Creates an enumerator adapter from the given STL map enumerating the mapped items. More...
 
template<class TContainer >
static IEnumerator< T >::Ptr CreateMappedAdapter (const TContainer &c)
 Creates an enumerator adapter from the given const STL map enumerating the mapped items. More...
 
template<class Predicate >
static IEnumerator< T >::Ptr CreateFilter (typename IEnumerator< T >::Ptr source, Predicate predicate)
 Creates a filtering adapter enumerating only the nodes matching a given predicate. More...
 
template<class SourceEnumerator , class TransformOperation >
static IEnumerator< T >::Ptr CreateTransform (std::shared_ptr< SourceEnumerator > source, TransformOperation transformOp)
 Creates a transforming adapter enumerating applying a transform operation to each element. More...
 

Static Public Attributes

static Empty Null
 A static empty enumerator instance. More...
 

Protected Attributes

TCurrent current
 The current field of this enumerator.
 

Additional Inherited Members

- Public Types inherited from Arp::IEnumerator< T >
typedef std::shared_ptr< IEnumeratorPtr
 The smart pointer tpye of this interface. More...
 
- Protected Member Functions inherited from Arp::IEnumerator< T >
 IEnumerator (void)=default
 Constructs an IEnumerator instance. More...
 
virtual ~IEnumerator (void)=default
 Destructs this instance and frees all resources. More...
 
 IEnumerator (const IEnumerator &arg)=default
 Copies an IEnumerator instance. More...
 
IEnumeratoroperator= (const IEnumerator &arg)=default
 Assigns an IEnumerator instance. More...
 

Detailed Description

template<class T>
class Arp::Enumerator< T >

This class defines a base class for all enumerator implementations and some predefined enumerators as nested classes.

Template Parameters
TThe element type of the container or collection, respectively.

Derive a specialized enumerator implementation by this class to inherit the current field an its getter operation GetCurrent(). Override the MoveNext() operations to implement specific enumeration logic.

Constructor & Destructor Documentation

◆ Enumerator() [1/2]

template<class T >
Arp::Enumerator< T >::Enumerator ( void  )
default

Constructs an Enumerator instance.

◆ Enumerator() [2/2]

template<class T >
Arp::Enumerator< T >::Enumerator ( const Enumerator< T > &  arg)
default

Copy constructor.

Parameters
argThe argument to copy.

◆ ~Enumerator()

template<class T >
virtual Arp::Enumerator< T >::~Enumerator ( void  )
virtualdefault

Destructs this instance and frees all resources.

Member Function Documentation

◆ CreateComposite()

template<class T >
IEnumerator< T >::Ptr Arp::Enumerator< T >::CreateComposite ( typename IEnumerator< T >::Ptr  first,
typename IEnumerator< T >::Ptr  second 
)
inlinestatic

Creates a composite enumerator from the two given enumerators, e.g. to enumerate trees easily.

Parameters
firstThe first enumerator to create a composite from.
secondThe second enumerator to create a composite from.
Returns
A composite enumerator built from the as arguments passed enumerators.

When enumerating trees using this operations, it is possible to traverse them in DFS (depth-first-search) manner or in BFS (breadth-first-search) manner, depending on the order of passed arguments: If the first enumerator is the one of the current node and the second is the new enumerator of the node childs, the tree is enumerated in DFS manner. If the arguments are passed vice-versa, the tree is enumerated in BFS manner.

◆ CreateEmpty()

template<class T >
IEnumerator< T >::Ptr Arp::Enumerator< T >::CreateEmpty ( void  )
inlinestatic

Creates an empty enumerator.

Returns
An empty enumerator of type Empty.

◆ CreateFilter()

template<class T >
template<class Predicate >
IEnumerator< T >::Ptr Arp::Enumerator< T >::CreateFilter ( typename IEnumerator< T >::Ptr  source,
Predicate  predicate 
)
inlinestatic

Creates a filtering adapter enumerating only the nodes matching a given predicate.

Parameters
sourceThe source enumerator.
predicateThe predicate to apply to each element of the source.
Returns
An filtering enumerator of the as argument passed source which is filtered by the given predicate.
Template Parameters
PredicateThe type of the predicate to apply to each element.

◆ CreateKeysAdapter() [1/2]

template<class T >
template<class TContainer >
IEnumerator< T >::Ptr Arp::Enumerator< T >::CreateKeysAdapter ( const TContainer &  c)
inlinestatic

Creates an enumerator adapter from the given const STL map enumerating the keys.

Parameters
cThe const STL map to enumerate.
Returns
An enumerator adapter of the as argument passed map enumerating the keys.
Template Parameters
TContainerThe type of the map.

◆ CreateKeysAdapter() [2/2]

template<class T >
template<class TContainer >
IEnumerator< T >::Ptr Arp::Enumerator< T >::CreateKeysAdapter ( TContainer &  c)
inlinestatic

Creates an enumerator adapter from the given STL map enumerating the keys.

Parameters
cThe STL map to enumerate.
Returns
An enumerator adapter of the as argument passed map enumerating the keys.
Template Parameters
TContainerThe type of the map.

◆ CreateMappedAdapter() [1/2]

template<class T >
template<class TContainer >
IEnumerator< T >::Ptr Arp::Enumerator< T >::CreateMappedAdapter ( const TContainer &  c)
inlinestatic

Creates an enumerator adapter from the given const STL map enumerating the mapped items.

Parameters
cThe const STL map to enumerate.
Returns
An enumerator adapter of the as argument passed map enumerating the mapped items.
Template Parameters
TContainerThe type of the map.

◆ CreateMappedAdapter() [2/2]

template<class T >
template<class TContainer >
IEnumerator< T >::Ptr Arp::Enumerator< T >::CreateMappedAdapter ( TContainer &  c)
inlinestatic

Creates an enumerator adapter from the given STL map enumerating the mapped items.

Parameters
cThe STL map to enumerate.
Returns
An enumerator adapter of the as argument passed map enumerating the mapped items.
Template Parameters
TContainerThe type of the map.

◆ CreateStlAdapter() [1/2]

template<class T >
template<class TContainer >
IEnumerator< T >::Ptr Arp::Enumerator< T >::CreateStlAdapter ( TContainer &  c)
inlinestatic

Creates an enumerator adapter from the given STL container.

Parameters
cThe container to enumerate.
Returns
An enumerator adapter of the as argument passed container.
Template Parameters
TContainerThe type of the container.

◆ CreateStlAdapter() [2/2]

template<class T >
template<class TIterator >
IEnumerator< T >::Ptr Arp::Enumerator< T >::CreateStlAdapter ( TIterator  begin,
TIterator  end 
)
inlinestatic

Creates an enumerator adapter from the given STL iterators.

Parameters
beginThe begin iterator of the container to enumerate.
endThe end iterator of the container to enumerate.
Returns
An enumerator adapter of the as arguments passed iterators.
Template Parameters
TIteratorThe iterator type of the container.

◆ CreateTransform()

template<class T >
template<class SourceEnumerator , class TransformOperation >
IEnumerator< T >::Ptr Arp::Enumerator< T >::CreateTransform ( std::shared_ptr< SourceEnumerator< T > >  source,
TransformOperation  transformOp 
)
inlinestatic

Creates a transforming adapter enumerating applying a transform operation to each element.

Parameters
sourceThe source enumerator.
transformOpThe transform operation to apply to each element of the source.
Returns
An enumerator where the transform operation is applied to each element in source.
Template Parameters
SourceEnumeratorThe type of the source enumerator. This may differ from the result enumerator.
TransformOperationThe type of the transform operation. This may be a function, function object or lambda.

◆ GetCurrent()

template<class T >
T Arp::Enumerator< T >::GetCurrent ( void  )
inlineoverridevirtual

Gets the element at the current position.

Returns
The element at the current position.

Depending an the template parameter type of this interface, a reference or even const reference might be returned.

Implements Arp::IEnumerator< T >.

◆ MoveNext()

template<class T >
virtual bool Arp::Enumerator< T >::MoveNext ( void  )
pure virtual

Moves this enumerator to the next position.

Returns
false if the end of the container/collections was reached and the enumerator was not moved, otherwise false.

See comments of interface declaration for more information about this operation.

IEnumerator

Implements Arp::IEnumerator< T >.

Implemented in Arp::System::Commons::Configuration::PlaceholderExpression::Enumerator, Arp::Plc::Commons::Meta::TypeSystem::TypeDomain::TypeInfoEnumerator, and Arp::Plc::Commons::Meta::TypeSystem::TypeDefinition::ChildTypeInfoEnumerator.

◆ operator=()

template<class T >
Enumerator& Arp::Enumerator< T >::operator= ( const Enumerator< T > &  arg)
default

Assignment operator.

Parameters
argThe argument to assign to this instance.
Returns
This instance as reference.

Member Data Documentation

◆ Null

template<class T >
Enumerator< T >::Empty Arp::Enumerator< T >::Null
static

A static empty enumerator instance.


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