PLCnext API Documentation 23.0.2.9
|
Declares the interface of the enumerator pattern, which is leaned on .NET enumerator idiom. More...
#include <IEnumerator.hxx>
Public Types | |
typedef std::shared_ptr< IEnumerator > | Ptr |
The smart pointer tpye of this interface. | |
Public Member Functions | |
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... | |
Protected Member Functions | |
IEnumerator (void)=default | |
Constructs an IEnumerator instance. | |
virtual | ~IEnumerator (void)=default |
Destructs this instance and frees all resources. | |
IEnumerator (const IEnumerator &arg)=default | |
Copies an IEnumerator instance. More... | |
IEnumerator & | operator= (const IEnumerator &arg)=default |
Assigns an IEnumerator instance. More... | |
Declares the interface of the enumerator pattern, which is leaned on .NET enumerator idiom.
T | The element type of the container or collection, respectively. |
The enumerator pattern is more easy to implement and to use, because the C++ iterator idiom always requires two arguments (begin, end) when defining algorithms or other operations working on containers or collections.
There is one big difference between iterators and enumerators: When a begin iterator is created it points to the first position of teh container/collection immediately. In contrast the enumerator has to be moved once after creation before accessing the first element of a container/collection. Thus, iterators are mostly used with for
loops (or range based for loops), but enumerators should always be used with while
loops as shown in the following example:
This interface might also be used with a reference type or even const reference type as template parameter, e.g.
|
protecteddefault |
Copies an IEnumerator instance.
arg | The argument to copy. |
|
pure virtual |
Gets the element at the current position.
Depending an the template parameter type of this interface, a reference or even const reference might be returned.
Implemented in Arp::Plc::Commons::Meta::ArrayNavigator::Enumerator, Arp::Plc::Commons::Meta::StructNavigator::Enumerator, Arp::Enumerator< T >::Empty, Arp::Enumerator< T >::Composite, Arp::Enumerator< T >::StackComposite, Arp::Enumerator< T >::StlAdapter< Iterator, IteratorAdapter >, Arp::Enumerator< T >, Arp::Enumerator< const DataInfo & >, Arp::Enumerator< ChildTypeInfo >, Arp::Enumerator< TypeInfo >, and Arp::Enumerator< const String & >.
|
pure virtual |
Moves this enumerator to the next position.
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.
Implemented in Arp::Plc::Commons::Meta::ArrayNavigator::Enumerator, Arp::Plc::Commons::Meta::StructNavigator::Enumerator, Arp::Plc::Commons::Meta::TypeSystem::TypeDefinition::ChildTypeInfoEnumerator, Arp::Plc::Commons::Meta::TypeSystem::TypeDomain::TypeInfoEnumerator, Arp::System::Commons::Configuration::PlaceholderExpression::Enumerator, Arp::Enumerator< T >::Empty, Arp::Enumerator< T >::Composite, Arp::Enumerator< T >::StackComposite, Arp::Enumerator< T >::StlAdapter< Iterator, IteratorAdapter >, Arp::Enumerator< T >, Arp::Enumerator< const DataInfo & >, Arp::Enumerator< ChildTypeInfo >, Arp::Enumerator< TypeInfo >, and Arp::Enumerator< const String & >.
|
protecteddefault |
Assigns an IEnumerator instance.
arg | The argument to assign to this instance. |