PLCnext API Documentation 25.0.2.69
|
This class defines a base class for all enumerator implementations and some predefined enumerators as nested classes. More...
#include <Enumerator.hxx>
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, every call to Enumerator<T>::Empty::MoveNext() will return false . More... | |
class | Filter |
This class implements a filtering enumerator. It enumerates all nodes of the source enumerator matching a given predicate. More... | |
class | IteratorAdapters |
This class implements several adapter of STL iterators to extract specific properties. More... | |
class | StackComposite |
Use this class to build a single enumerator by multiple other enumerators using a stack More... | |
class | StlAdapter |
This class implements an enumerator adapter for STL container based on iterators. More... | |
class | Transform |
This class implements a transforming enumerator. A transform operation is applied to each element. More... | |
Public Member Functions | |
Enumerator (void) | |
Constructs a default Enumerator instance. | |
Enumerator (const Enumerator &arg)=delete | |
Enumerator (Enumerator &&arg) noexcept | |
Move constructor. More... | |
Enumerator & | operator= (const Enumerator &arg)=delete |
Enumerator & | operator= (Enumerator &&arg) noexcept |
Move assignment operator. More... | |
~Enumerator (void) override | |
Destructs this instance and frees all resources. | |
T | GetCurrent (void) override |
Gets the element at the current position. More... | |
template<class S , class O > | |
IEnumerator< T >::Ptr | CreateTransform (std::shared_ptr< S > sourcePtr, O transformOperation) |
Creates a transforming adapter enumerating applying a transform operation to each element. More... | |
![]() | |
IEnumerator (void)=default | |
Constructs an IEnumerator instance. | |
IEnumerator (const IEnumerator &arg)=default | |
Deleted copy constructor. | |
IEnumerator (IEnumerator &&arg) noexcept=default | |
Move constructor. | |
IEnumerator & | operator= (const IEnumerator &arg)=default |
Deleted copy-assignment IEnumerator. | |
IEnumerator & | operator= (IEnumerator &&arg) noexcept=default |
Move-assignment operator. | |
virtual | ~IEnumerator (void)=default |
Destructs this instance and frees all resources. | |
virtual bool | MoveNext (void)=0 |
Moves this enumerator to the next position. More... | |
virtual T | GetCurrent (void)=0 |
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 | CreateStlAdapter (const 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) |
Protected Attributes | |
TCurrent | current {} |
The current field of this enumerator. | |
Additional Inherited Members | |
![]() | |
using | Ptr = std::shared_ptr< IEnumerator > |
The smart pointer type of this interface. | |
using | ValueType = T |
Type of the enumerated values | |
This class defines a base class for all enumerator implementations and some predefined enumerators as nested classes.
T | The element type of the container or collection, respectively. |
Derive a specialized enumerator implementation from this class to inherit the current
field an its getter operation Enumerator<T>::GetCurrent(). Override the Enumerator<T>::MoveNext() operations to implement specific enumeration logic.
T | The enumerated type. |
|
inlinedefaultnoexcept |
Move constructor.
arg | The argument to move. |
|
inlinestatic |
Creates a composite enumerator from the two given enumerators, e.g. to enumerate trees easily.
first | The first enumerator to create a composite from. |
second | The second enumerator to create a composite from. |
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 children, the tree is enumerated in DFS manner. If the arguments are passed vice-versa, the tree is enumerated in BFS manner.
|
inlinestatic |
Creates an empty enumerator.
|
inlinestatic |
Creates a filtering adapter enumerating only the nodes matching a given predicate.
source | The source enumerator. |
filter | The filter to apply to each element of the source. |
Predicate | The type of the filter to apply to each element. |
|
inlinestatic |
Creates an enumerator adapter from the given const STL map enumerating the keys.
c | The const STL map to enumerate. |
TContainer | The type of the map. |
|
inlinestatic |
Creates an enumerator adapter from the given STL map enumerating the keys.
c | The STL map to enumerate. |
TContainer | The type of the map. |
|
inlinestatic |
Creates an enumerator adapter from the given const STL map enumerating the mapped items.
c | The const STL map to enumerate. |
TContainer | The type of the map. |
|
inlinestatic |
Creates an enumerator adapter from the given STL map enumerating the mapped items.
c | The STL map to enumerate. |
TContainer | The type of the map. |
|
inlinestatic |
Creates an enumerator adapter from the given STL container.
c | The const container to enumerate. |
TContainer | The type of the container. |
|
inlinestatic |
Creates an enumerator adapter from the given STL container.
c | The container to enumerate. |
TContainer | The type of the container. |
|
inlinestatic |
Creates an enumerator adapter from the given STL iterators.
begin | The begin iterator of the container to enumerate. |
end | The end iterator of the container to enumerate. |
TIterator | The iterator type of the container. |
|
inline |
Creates a transforming adapter enumerating applying a transform operation to each element.
sourcePtr | The source enumerator. |
transformOperation | The transform operation to apply to each element of the source. |
S | The type of the source enumerator. This may differ from the result enumerator. |
O | The type of the transform operation. This may be a function, function object or lambda. |
|
inlineoverridevirtual |
Gets the element at the current position.
Depending on the template parameter type of this interface, a reference or even const reference might be returned.
InvalidOperationException | When GetCurrent() is called before MoveNext() or after MoveNext() has returned false once. |
Implements Arp::Base::Core::IEnumerator< T >.
|
inlinedefaultnoexcept |
Move assignment operator.
arg | The argument to assign to this instance. |