8#include "Arp/Base/Core/Exception.hpp"
9#include "Arp/Base/Core/Detail/Enumerator.hxx"
10namespace Arp {
namespace Base {
namespace Core
23 Composite(
const Composite& arg) =
delete;
61 : first(
std::move(first))
62 , second(
std::move(second))
72 if (this->first->MoveNext())
81 if (this->second->MoveNext())
97 return this->first->GetCurrent();
102 return this->second->GetCurrent();
105 throw Exception(
"Enumerator<T>::Composite::GetCurrent() fails: Composite enumerator is empty or enumerating has ended yet.");
124 return std::make_shared<Composite>(first, second);
Use this class to build a single enumerator by two given enumerator, e.g. to enumerate multiple conta...
Definition: Enumerator.Composite.hxx:20
Composite & operator=(Composite &&arg) noexcept
Move assignment operator.
bool MoveNext(void) override
Moves this enumerator to the next position.
Definition: Enumerator.Composite.hxx:68
T GetCurrent(void) override
Gets the element at the current position.
Definition: Enumerator.Composite.hxx:93
Composite(Composite &&arg) noexcept
Move constructor.
Composite(typename IEnumerator< T >::Ptr first, typename IEnumerator< T >::Ptr second)
Constructs an Enumerator<T>::Composite instance.
Definition: Enumerator.Composite.hxx:60
~Composite(void) override
Destructs this instance and frees all resources.
This class defines a base class for all enumerator implementations and some predefined enumerators as...
Definition: Enumerator.hxx:24
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.
Definition: Enumerator.Composite.hxx:122
T GetCurrent(void) override
Gets the element at the current position.
Definition: Enumerator.hxx:113
This is the base class of all Arp exception classes.
Definition: Exception.hpp:21
Declares the interface of the enumerator pattern, which is leaned on .NET enumerator idiom.
Definition: IEnumerator.hxx:49
virtual bool MoveNext(void)=0
Moves this enumerator to the next position.
std::shared_ptr< IEnumerator > Ptr
The smart pointer type of this interface.
Definition: IEnumerator.hxx:52
Root namespace for the PLCnext API
Namespace of the C++ standard library