Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
DelegatedIterator.h
Go to the documentation of this file.
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_Traversal_DelegatedIterator_h_
5#define _Stroika_Foundation_Traversal_DelegatedIterator_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9#include "Stroika/Foundation/Common/Common.h"
12
13/**
14 * \file
15 *
16 * TODO:
17 * @todo Review definition of DelegatedIterator<>::Rep::GetOwner(). Not sure we've selected the
18 * the best definition.
19 *
20 */
21
22namespace Stroika::Foundation::Traversal {
23
24 /**
25 * Handy helper to combine (or track) iterators
26 */
27 template <typename T, typename EXTRA_DATA = void>
28 class DelegatedIterator : public Iterator<T> {
29 public:
30 struct Rep : Iterator<T>::IRep {
31 // using RepSmartPtr = typename Iterator<T>::RepSmartPtr;
32 using IRep = typename Iterator<T>::IRep;
33 Iterator<T> fDelegateTo;
34 EXTRA_DATA fExtraData;
35 Rep (const Iterator<T>& delegateTo, const EXTRA_DATA& extraData = EXTRA_DATA ());
36 virtual unique_ptr<IRep> Clone () const override;
37 virtual void More (optional<T>* result, bool advance) override;
38 virtual bool Equals (const IRep* rhs) const override;
39 };
40 DelegatedIterator (const Iterator<T>& delegateTo, const EXTRA_DATA& extraData = EXTRA_DATA ());
41 };
42 template <typename T>
43 class DelegatedIterator<T, void> : public Iterator<T> {
44 public:
45 struct Rep : Iterator<T>::IRep {
46 // using RepSmartPtr = typename Iterator<T>::RepSmartPtr;
47 using IRep = typename Iterator<T>::IRep;
48 Iterator<T> fDelegateTo;
49 Rep (const Iterator<T>& delegateTo);
50 virtual unique_ptr<IRep> Clone () const override;
51 virtual void More (optional<T>* result, bool advance) override;
52 virtual bool Equals (const IRep* rhs) const override;
53 };
54 };
55
56}
57
58/*
59 ********************************************************************************
60 ******************************* Implementation Details *************************
61 ********************************************************************************
62 */
63#include "DelegatedIterator.inl"
64
65#endif /*_Stroika_Foundation_Traversal_DelegatedIterator_h_ */
Implementation detail for iterator implementors.
Definition Iterator.h:599
An Iterator<T> is a copyable object which allows traversing the contents of some container....
Definition Iterator.h:225