COPASI API  4.40.278
CMathDependencyNodeIterator Class Reference

#include <CMathDependencyNodeIterator.h>

Classes

class  CStackElement
 

Public Types

typedef CFlags< StateFlag
 
enum  State {
  Start , Before , After , Intermediate ,
  End , Recursive , __SIZE
}
 
enum  Type { Dependents , Prerequisites }
 

Public Member Functions

 CMathDependencyNodeIterator ()
 
 CMathDependencyNodeIterator (CMathDependencyNode *pNode, const Type &type=Dependents)
 
 CMathDependencyNodeIterator (const CMathDependencyNodeIterator &src)
 
Flag getProcessingModes () const
 
size_t level () const
 
bool next ()
 
CMathDependencyNodeoperator* ()
 
CMathDependencyNodeoperator-> ()
 
const CMathDependencyNodeparent ()
 
void setProcessingModes (const Flag &processingModes)
 
const StateskipChildren ()
 
const Statestate () const
 
 ~CMathDependencyNodeIterator ()
 

Public Attributes

std::stack< CStackElementmStack
 

Private Member Functions

void increment ()
 

Private Attributes

State mCurrentState
 
Flag mProcessingModes
 
Type mType
 
std::set< const CMathDependencyNode * > mVisited
 

Detailed Description

This class allows to iterator over the nodes of a dependency graph in both directions (Dependents and Prerequisites) which is indicated by the type.

Member Typedef Documentation

◆ Flag

A flag indicating to which state the iterator should advance. These may be any combination of the enumeration value State. Please note the iterator will always return and End and Recursive

Member Enumeration Documentation

◆ State

The state of the iterator. Please note that the graph might be recursive which will cause the iterator to stop.

Enumerator
Start 
Before 
After 
Intermediate 
End 
Recursive 
__SIZE 

◆ Type

Type defining whether we iterate over the dependents or prerequisites

Enumerator
Dependents 
Prerequisites 

Constructor & Destructor Documentation

◆ CMathDependencyNodeIterator() [1/3]

CMathDependencyNodeIterator::CMathDependencyNodeIterator ( )

Default constructor

◆ CMathDependencyNodeIterator() [2/3]

CMathDependencyNodeIterator::CMathDependencyNodeIterator ( const CMathDependencyNodeIterator src)

Copy constructor

Parameters
constCMathDependencyNodeIterator & src

◆ CMathDependencyNodeIterator() [3/3]

CMathDependencyNodeIterator::CMathDependencyNodeIterator ( CMathDependencyNode pNode,
const Type type = Dependents 
)

Specific constructor

Parameters
CMathDependencyNode* pNode
constType & type (default: Dependents)

References mStack, mType, and mVisited.

◆ ~CMathDependencyNodeIterator()

CMathDependencyNodeIterator::~CMathDependencyNodeIterator ( )

Destructor

Member Function Documentation

◆ getProcessingModes()

CMathDependencyNodeIterator::Flag CMathDependencyNodeIterator::getProcessingModes ( ) const

Retrieve the valid states for which the method next() should return

Returns
Flag processingModes

References End, mProcessingModes, and Recursive.

◆ increment()

void CMathDependencyNodeIterator::increment ( )
private

This method advances the iterator to the next internal state. The tree is traversed depth first.

Please note that the iterator points to the same node multiple times, once before every 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, intermediate or post processing phase one may check the processing mode with: const State & state()

References After, Before, End, Intermediate, mCurrentState, CMathDependencyNodeIterator::CStackElement::mEndChild, CMathDependencyNodeIterator::CStackElement::mItChild, CMathDependencyNodeIterator::CStackElement::mpNode, mStack, CMathDependencyNodeIterator::CStackElement::mType, mVisited, and Recursive.

Referenced by next().

◆ level()

size_t CMathDependencyNodeIterator::level ( ) const

Retrieve the current nesting level of the iterator

Returns
size_t level

References mStack.

◆ next()

bool CMathDependencyNodeIterator::next ( )

This method advances the iterator to the next node and state combination for which the state is in the Flag of processing modes. A return value of true indicates that such a node has been found whereas false indicates the iteration has been completed or failed. To determine the current state of the iterator use: const State & state()

Returns
bool success

References Before, End, increment(), CFlags< Enum >::isSet(), mCurrentState, mProcessingModes, and Start.

Referenced by CMathDependencyNode::buildUpdateSequence(), CMathDependencyNode::updateCalculatedState(), CMathDependencyNode::updateDependentState(), CMathDependencyNode::updateIgnoredState(), and CMathDependencyNode::updatePrerequisiteState().

◆ operator*()

CMathDependencyNode * CMathDependencyNodeIterator::operator* ( )

This operator dereferences the iterator and returns a pointer the node of the graph

Returns
CMathDependencyNode * pNode

References mStack.

◆ operator->()

CMathDependencyNode * CMathDependencyNodeIterator::operator-> ( )

This operator dereferences the iterator and returns a pointer the node of the graph

Returns
CMathDependencyNode * pNode

References mStack.

◆ parent()

const CMathDependencyNode * CMathDependencyNodeIterator::parent ( )

◆ setProcessingModes()

void CMathDependencyNodeIterator::setProcessingModes ( const Flag processingModes)

◆ skipChildren()

const CMathDependencyNodeIterator::State & CMathDependencyNodeIterator::skipChildren ( )

Calling this method causes the iterator to skip processing the children of the current node and advance to the State to next state allowed by the processing mode

Returns
const State & state

References After, mCurrentState, CMathDependencyNodeIterator::CStackElement::mEndChild, CMathDependencyNodeIterator::CStackElement::mItChild, and mStack.

Referenced by CMathDependencyNode::buildUpdateSequence(), CMathDependencyNode::updateCalculatedState(), CMathDependencyNode::updateDependentState(), and CMathDependencyNode::updatePrerequisiteState().

◆ state()

Member Data Documentation

◆ mCurrentState

State CMathDependencyNodeIterator::mCurrentState
private

The current state of the iterator

Referenced by increment(), next(), skipChildren(), and state().

◆ mProcessingModes

Flag CMathDependencyNodeIterator::mProcessingModes
private

The flag indicating to which state the iterator should advance. These may be any combination of the enumeration value State. Please note that this flag will always include return and End and Recursive

Referenced by getProcessingModes(), next(), and setProcessingModes().

◆ mStack

std::stack< CStackElement > CMathDependencyNodeIterator::mStack

A stack of context for each nesting level of the iterator

Referenced by CMathDependencyNodeIterator(), increment(), level(), operator*(), operator->(), parent(), and skipChildren().

◆ mType

Type CMathDependencyNodeIterator::mType
private

The iterator type (Dependents or Prerequisites)

Referenced by CMathDependencyNodeIterator().

◆ mVisited

std::set< const CMathDependencyNode * > CMathDependencyNodeIterator::mVisited
private

A set of currently visited nodes in the stack used to determine loops or recursive dependencies

Referenced by CMathDependencyNodeIterator(), and increment().


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