COPASI API  4.16.103
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
CNodeContextIterator< Node, Context > Class Template Reference

#include <CNodeIterator.h>

Inheritance diagram for CNodeContextIterator< Node, Context >:
Inheritance graph
[legend]
Collaboration diagram for CNodeContextIterator< Node, Context >:
Collaboration graph
[legend]

Classes

class  CStackElement
 

Public Member Functions

 CNodeContextIterator ()
 
 CNodeContextIterator (const CNodeContextIterator &src)
 
 CNodeContextIterator (Node *pNode, Context *pParentContext=NULL)
 
Context & context ()
 
CNodeIteratorMode::State end () const
 
CNodeIteratorMode::Flag getProcessingModes () const
 
size_t level ()
 
const CNodeIteratorMode::Statenext ()
 
Node * operator* ()
 
Node * operator-> ()
 
Context * parentContextPtr ()
 
const CNodeIteratorMode::StateprocessingMode () const
 
void setProcessingModes (const CNodeIteratorMode::Flag &processingModes)
 
const CNodeIteratorMode::StateskipChildren ()
 
 ~CNodeContextIterator ()
 

Private Member Functions

void increment ()
 

Private Attributes

CNodeIteratorMode::State mCurrentMode
 
CNodeIteratorMode::Flag mProcessingModes
 
std::stack< CStackElementmStack
 

Detailed Description

template<class Node, class Context>
class CNodeContextIterator< Node, Context >

Definition at line 40 of file CNodeIterator.h.

Constructor & Destructor Documentation

template<class Node, class Context>
CNodeContextIterator< Node, Context >::CNodeContextIterator ( )
inline

Default constructor

Definition at line 126 of file CNodeIterator.h.

template<class Node, class Context>
CNodeContextIterator< Node, Context >::CNodeContextIterator ( const CNodeContextIterator< Node, Context > &  src)
inline

Copy constructor

Parameters
constCNodeContextIterator & src

Definition at line 136 of file CNodeIterator.h.

136  :
137  mStack(src.mStack),
140  {}
std::stack< CStackElement > mStack
CNodeIteratorMode::Flag mProcessingModes
CNodeIteratorMode::State mCurrentMode
template<class Node, class Context>
CNodeContextIterator< Node, Context >::CNodeContextIterator ( Node *  pNode,
Context *  pParentContext = NULL 
)
inline

Constructor

Parameters
Node* pNode
Context* pParentContext (default: NULL)

Definition at line 147 of file CNodeIterator.h.

147  :
148  mStack(),
151  {
152  mStack.push(CStackElement(pNode, pParentContext));
153  }
std::stack< CStackElement > mStack
CNodeIteratorMode::Flag mProcessingModes
CNodeIteratorMode::State mCurrentMode
template<class Node, class Context>
CNodeContextIterator< Node, Context >::~CNodeContextIterator ( )
inline

Destructor

Definition at line 158 of file CNodeIterator.h.

158 {}

Member Function Documentation

template<class Node, class Context>
Context& CNodeContextIterator< Node, Context >::context ( )
inline
template<class Node, class Context>
CNodeIteratorMode::State CNodeContextIterator< Node, Context >::end ( ) const
inline
template<class Node, class Context>
CNodeIteratorMode::Flag CNodeContextIterator< Node, Context >::getProcessingModes ( ) const
inline

Retrieve the processing modes to which the method next will advance the iterator.

Returns
CNodeIteratorMode::Flag processingModes

Definition at line 317 of file CNodeIterator.h.

template<class Node, class Context>
void CNodeContextIterator< Node, Context >::increment ( )
inlineprivate

This method moves the iterator to the next node in the tree. The tree is traversed depth first. A return value of false indicates that the tree has been completed traversed.

Please note that the iterator points to the same node twice, once before the first child and once after the last child to allow pre and post processing. This behavior is also true for childless nodes. To determine whether the iterator is in the pre or post processing phase one may check the nextChildIndex where zero indicates pre and None indicates post processing.

Returns
bool moreNodes

Definition at line 175 of file CNodeIterator.h.

Referenced by CNodeContextIterator< Node, int >::next().

176  {
177  if (mStack.empty())
178  {
180 
181  return;
182  }
183 
184  CStackElement & Current = mStack.top();
185 
186  if (Current.mNextChildIndex < Current.mChildCount)
187  {
188  mStack.push(CStackElement(static_cast< Node * >(Current.mpNode->getChild(Current.mNextChildIndex++)), &Current.mContext));
190 
191  return;
192  }
193 
194  if (Current.mNextChildIndex == Current.mChildCount)
195  {
196  Current.mNextChildIndex++;
198 
199  return;
200  }
201 
202  mStack.pop();
203 
204  if (mStack.empty())
205  {
207 
208  return;
209  }
210 
211  CStackElement & Parent = mStack.top();
212 
213  if (Parent.mNextChildIndex < Parent.mChildCount)
214  {
216  }
217  else
218  {
220  Parent.mNextChildIndex++;
221  }
222 
223  return;
224  }
std::stack< CStackElement > mStack
CNodeIteratorMode::State mCurrentMode
template<class Node, class Context>
size_t CNodeContextIterator< Node, Context >::level ( )
inline

The nesting level of the tree. Note, the nesting level of the root of the tree is 1. This is to distinguish its level from the end of the iterator which reports 0.

Definition at line 304 of file CNodeIterator.h.

304 {return mStack.size();}
std::stack< CStackElement > mStack
template<class Node, class Context>
const CNodeIteratorMode::State& CNodeContextIterator< Node, Context >::next ( )
inline
template<class Node, class Context>
Node* CNodeContextIterator< Node, Context >::operator* ( )
inline

Dereference the iterator

Returns
Node * pNode

Definition at line 268 of file CNodeIterator.h.

268 {return mStack.top().mpNode;}
std::stack< CStackElement > mStack
template<class Node, class Context>
Node* CNodeContextIterator< Node, Context >::operator-> ( )
inline

Dereference the iterator

Returns
Node * pNode

Definition at line 274 of file CNodeIterator.h.

274 {return mStack.top().mpNode;}
std::stack< CStackElement > mStack
template<class Node, class Context>
Context* CNodeContextIterator< Node, Context >::parentContextPtr ( )
inline
template<class Node, class Context>
const CNodeIteratorMode::State& CNodeContextIterator< Node, Context >::processingMode ( ) const
inline

Retrieve the processing mode

Returns
const CNodeIteratorMode::State & processingMode

Definition at line 280 of file CNodeIterator.h.

Referenced by CMathEventN::CTrigger::compile(), CMathEventN::CTrigger::countRoots(), and CEvaluationNode::findTopMinus().

280 {return mCurrentMode;}
CNodeIteratorMode::State mCurrentMode
template<class Node, class Context>
void CNodeContextIterator< Node, Context >::setProcessingModes ( const CNodeIteratorMode::Flag processingModes)
inline

Set the processing modes to which the method next will advance the iterator. Note, the iterator will always stop at the end.

Parameters
constCNodeIteratorMode::Flag & processingModes

Definition at line 311 of file CNodeIterator.h.

Referenced by CMathEventN::CTrigger::compile(), CMathEventN::CTrigger::countRoots(), and CEvaluationNode::findTopMinus().

311 {mProcessingModes = (processingModes | CNodeIteratorMode::End);}
CNodeIteratorMode::Flag mProcessingModes
template<class Node, class Context>
const CNodeIteratorMode::State& CNodeContextIterator< Node, Context >::skipChildren ( )
inline

This method moves the iterator beyond the last child.

Definition at line 255 of file CNodeIterator.h.

Referenced by CMathEventN::CTrigger::compile(), CMathEventN::CTrigger::countRoots(), and CEvaluationNode::findTopMinus().

256  {
257  CStackElement & Current = mStack.top();
258  Current.mNextChildIndex = Current.mChildCount + 1;
260 
261  return mCurrentMode;
262  }
std::stack< CStackElement > mStack
CNodeIteratorMode::State mCurrentMode

Member Data Documentation

template<class Node, class Context>
CNodeIteratorMode::State CNodeContextIterator< Node, Context >::mCurrentMode
private
template<class Node, class Context>
CNodeIteratorMode::Flag CNodeContextIterator< Node, Context >::mProcessingModes
private

The processing modes to which the method next will advance the iterator

Definition at line 333 of file CNodeIterator.h.

Referenced by CNodeContextIterator< Node, int >::getProcessingModes(), CNodeContextIterator< Node, int >::next(), and CNodeContextIterator< Node, int >::setProcessingModes().

template<class Node, class Context>
std::stack< CStackElement > CNodeContextIterator< Node, Context >::mStack
private

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