8#include "Arp/Base/Core/Exception.hpp"
9#include "Arp/Base/Core/Detail/Enumerator.hxx"
12namespace Arp {
namespace Base {
namespace Core
25 using Stack = std::stack<typename IEnumerator<T>::Ptr>;
41 size_t GetSize(
void)
const;
73 while (!this->enumerators.empty())
75 if (this->enumerators.top()->MoveNext())
80 this->enumerators.pop();
90 if (this->enumerators.empty())
92 throw Exception(
"Enumerator<T>::StackComposite::GetCurrent(): StackComposite enumerators is empty or enumerating has ended yet");
94 return this->enumerators.top()->GetCurrent();
106 this->enumerators.emplace(std::move(enumerator));
114 return this->enumerators.size();
Use this class to build a single enumerator by multiple other enumerators using a stack
Definition: Enumerator.StackComposite.hxx:23
void Push(typename IEnumerator< T >::Ptr enumerator)
Adds the as argument passed enumerator to this stack.
Definition: Enumerator.StackComposite.hxx:100
StackComposite & operator=(StackComposite &&arg) noexcept
Move assignment operator.
T GetCurrent(void) override
Gets the element at the current position.
Definition: Enumerator.StackComposite.hxx:88
StackComposite(void)
Constructs an StackComposite instance.
size_t GetSize(void) const
Get the size of this stack.
Definition: Enumerator.StackComposite.hxx:112
bool MoveNext(void) override
Moves this enumerator to the next position.
Definition: Enumerator.StackComposite.hxx:71
StackComposite(StackComposite &&arg) noexcept
Move constructor.
~StackComposite(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
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