Belle II Software light-2406-ragdoll
PathIterator Class Reference

Iterator over a Path (returning Module pointers). More...

#include <PathIterator.h>

Collaboration diagram for PathIterator:

Public Member Functions

 PathIterator (const PathPtr &path)
 Constructor.
 
 PathIterator (const PathPtr &path, const PathIterator &parentIterator)
 Constructor with back-reference to an iterator over the parent path.
 
void next ()
 increment.
 
void descendIfNecessary ()
 Check if we're pointing to another path and descend if that is the case.
 
bool isDone () const
 Are we finished iterating?
 
Moduleget () const
 dereference.
 

Private Attributes

PathPtr m_path
 keep the path around to ensure iterators remain valid.
 
std::list< std::shared_ptr< PathElement > >::const_iterator m_iter
 wrapped path list iterator.
 
std::list< std::shared_ptr< PathElement > >::const_iterator m_end
 iterator to end of Path.
 
std::shared_ptr< PathIteratorm_parentIterator
 If this is non-NULL, we jump to m_parentIterator+1 after m_iter is done.
 

Detailed Description

Iterator over a Path (returning Module pointers).

Definition at line 26 of file PathIterator.h.

Constructor & Destructor Documentation

◆ PathIterator() [1/2]

PathIterator ( const PathPtr path)
inlineexplicit

Constructor.

Definition at line 29 of file PathIterator.h.

29 :
30 m_path(path),
31 m_iter(path->m_elements.begin()),
32 m_end(path->m_elements.end()),
34 {
36 }
std::shared_ptr< PathIterator > m_parentIterator
If this is non-NULL, we jump to m_parentIterator+1 after m_iter is done.
Definition: PathIterator.h:82
std::list< std::shared_ptr< PathElement > >::const_iterator m_end
iterator to end of Path.
Definition: PathIterator.h:81
std::list< std::shared_ptr< PathElement > >::const_iterator m_iter
wrapped path list iterator.
Definition: PathIterator.h:80
PathPtr m_path
keep the path around to ensure iterators remain valid.
Definition: PathIterator.h:79
void descendIfNecessary()
Check if we're pointing to another path and descend if that is the case.
Definition: PathIterator.h:57

◆ PathIterator() [2/2]

PathIterator ( const PathPtr path,
const PathIterator parentIterator 
)
inlineexplicit

Constructor with back-reference to an iterator over the parent path.

Definition at line 39 of file PathIterator.h.

39 :
40 m_path(path),
41 m_iter(path->m_elements.begin()),
42 m_end(path->m_elements.end()),
43 m_parentIterator(new PathIterator(parentIterator))
44 {
46 }
PathIterator(const PathPtr &path)
Constructor.
Definition: PathIterator.h:29

Member Function Documentation

◆ descendIfNecessary()

void descendIfNecessary ( )
inline

Check if we're pointing to another path and descend if that is the case.

Definition at line 57 of file PathIterator.h.

58 {
59 if (!isDone() and dynamic_cast<Path*>(m_iter->get())) {
60 //we're pointing to another Path
61 *this = PathIterator(std::static_pointer_cast<Path>(*m_iter), *this);
62 }
63 //check _afterwards_ if we need to jump back up
64 if (isDone() and m_parentIterator) {
65 //jump back to parent iterator
66 *this = *(m_parentIterator.get());
67 next(); //go to next module
68 }
69 }
void next()
increment.
Definition: PathIterator.h:49
bool isDone() const
Are we finished iterating?
Definition: PathIterator.h:72

◆ get()

Module * get ( ) const
inline

dereference.

Definition at line 75 of file PathIterator.h.

75{ return dynamic_cast<Module*>(m_iter->get()); }

◆ isDone()

bool isDone ( ) const
inline

Are we finished iterating?

Definition at line 72 of file PathIterator.h.

72{ return (m_iter == m_end); }

◆ next()

void next ( )
inline

increment.

Definition at line 49 of file PathIterator.h.

50 {
51 if (!isDone())
52 ++m_iter;
54 }

Member Data Documentation

◆ m_end

std::list<std::shared_ptr<PathElement>>::const_iterator m_end
private

iterator to end of Path.

Definition at line 81 of file PathIterator.h.

◆ m_iter

std::list<std::shared_ptr<PathElement>>::const_iterator m_iter
private

wrapped path list iterator.

Definition at line 80 of file PathIterator.h.

◆ m_parentIterator

std::shared_ptr<PathIterator> m_parentIterator
private

If this is non-NULL, we jump to m_parentIterator+1 after m_iter is done.

Definition at line 82 of file PathIterator.h.

◆ m_path

PathPtr m_path
private

keep the path around to ensure iterators remain valid.

Definition at line 79 of file PathIterator.h.


The documentation for this class was generated from the following file: