27 #ifndef COSMO_ENUMERABLE_INTERFACE_H
28 #define COSMO_ENUMERABLE_INTERFACE_H
30 #include <Pt/Cosmo/AutoPtr.h>
31 #include <Pt/Cosmo/IAutoReleasePool.h>
38 class IEnumerationBase;
81 Enumerator<T> end(
const IEnumerable<T>& e)
83 return Enumerator<T>();
107 virtual bool onIsValid()
const = 0;
109 virtual void onAdvance() = 0;
116 template <
typename T>
121 typedef const T& Reference;
133 virtual const T& onGet()
const = 0;
138 template <
typename T>
143 typedef const T* Reference;
155 virtual const T* onGet()
const = 0;
179 template <
typename Enumeration,
typename Deleter>
194 , _res( std::move(other._res) )
196 if(other._e == &other._invalid)
210 if(other._e == &other._invalid)
215 _res = std::move(other._res);
222 return _e->isValid();
230 explicit operator bool()
const
232 return this->isValid();
235 bool operator !()
const
237 return ! this->isValid();
242 return ! operator !=(other);
247 const bool isValid = this->isValid() || other.isValid();
248 return _e != other._e && isValid;
252 virtual void onRelease()
override
267 virtual bool onIsValid()
const
270 virtual void onAdvance()
281 template <
typename T>
285 template <
typename P>
288 typedef const P& Reference;
294 const P& operator*()
const
302 template <
typename P>
305 typedef const P* Reference;
311 const P* operator*()
const
319 typedef long difference_type;
320 typedef typename Proxy<T>::Reference Reference;
333 template <
typename Enumeration,
typename Deleter>
351 EnumeratorBase::operator=(other);
358 Reference get()
const
363 Reference operator*()
const
368 const T* operator->()
const
379 Proxy<T> operator++(
int)
387 virtual void onRelease()
override
390 EnumeratorBase::onRelease();
401 #endif // include guard
Core module.
Definition: Allocator.h:33
Enumerable interface.
Definition: IEnumerable.h:58
Enumerator implementation.
Definition: IEnumerable.h:118
Owning smart pointer.
Definition: AutoPtr.h:123
Enumerator for IEnumerables.
Definition: IEnumerable.h:161
Auto-release pool interface.
Definition: IAutoReleasePool.h:46
Enumerator base implementation.
Definition: IEnumerable.h:91
Auto-releasable resource.
Definition: IAutoReleasePool.h:68
Enumerator for IEnumerables.
Definition: IEnumerable.h:283