COPASI API
4.16.103
|
#include <CMathDependencyNodeIterator.h>
Classes | |
class | CStackElement |
Public Types | |
typedef CMathFlags< State > | Flag |
enum | State { Start = 0x00, Before = 0x01, After = 0x02, Intermediate = 0x04, End = 0x08, Recursive = 0x10 } |
enum | Type { Dependents, Prerequisites } |
Public Member Functions | |
CMathDependencyNodeIterator () | |
CMathDependencyNodeIterator (const CMathDependencyNodeIterator &src) | |
CMathDependencyNodeIterator (CMathDependencyNode *pNode, const Type &type=Dependents) | |
Flag | getProcessingModes () const |
size_t | level () const |
bool | next () |
CMathDependencyNode * | operator* () |
CMathDependencyNode * | operator-> () |
const CMathDependencyNode * | parent () |
void | setProcessingModes (const Flag &processingModes) |
const State & | skipChildren () |
const State & | state () const |
~CMathDependencyNodeIterator () | |
Private Member Functions | |
void | increment () |
Private Attributes | |
State | mCurrentState |
Flag | mProcessingModes |
std::stack< CStackElement > | mStack |
Type | mType |
std::set< const CMathDependencyNode * > | mVisited |
This class allows to iterator over the nodes of a dependency graph in both directions (Dependents and Prerequisites) which is indicated by the type.
Definition at line 27 of file CMathDependencyNodeIterator.h.
typedef CMathFlags< State > CMathDependencyNodeIterator::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
Definition at line 58 of file CMathDependencyNodeIterator.h.
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 |
Definition at line 43 of file CMathDependencyNodeIterator.h.
Type defining whether we iterate over the dependents or prerequisites
Enumerator | |
---|---|
Dependents | |
Prerequisites |
Definition at line 33 of file CMathDependencyNodeIterator.h.
CMathDependencyNodeIterator::CMathDependencyNodeIterator | ( | ) |
Default constructor
Definition at line 57 of file CMathDependencyNodeIterator.cpp.
CMathDependencyNodeIterator::CMathDependencyNodeIterator | ( | const CMathDependencyNodeIterator & | src | ) |
Copy constructor
const | CMathDependencyNodeIterator & src |
Definition at line 65 of file CMathDependencyNodeIterator.cpp.
CMathDependencyNodeIterator::CMathDependencyNodeIterator | ( | CMathDependencyNode * | pNode, |
const Type & | type = Dependents |
||
) |
Specific constructor
CMathDependencyNode | * pNode |
const | Type & type (default: Dependents) |
Definition at line 73 of file CMathDependencyNodeIterator.cpp.
References mStack, mType, and mVisited.
CMathDependencyNodeIterator::~CMathDependencyNodeIterator | ( | ) |
CMathDependencyNodeIterator::Flag CMathDependencyNodeIterator::getProcessingModes | ( | ) | const |
Retrieve the valid states for which the method next() should return
Definition at line 223 of file CMathDependencyNodeIterator.cpp.
References End, mProcessingModes, and Recursive.
|
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()
Definition at line 88 of file CMathDependencyNodeIterator.cpp.
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().
size_t CMathDependencyNodeIterator::level | ( | ) | const |
Retrieve the current nesting level of the iterator
Definition at line 213 of file CMathDependencyNodeIterator.cpp.
References mStack.
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()
Definition at line 165 of file CMathDependencyNodeIterator.cpp.
References Before, End, increment(), mCurrentState, mProcessingModes, and Start.
Referenced by CMathDependencyNode::buildUpdateSequence(), CMathDependencyNode::updateDependentState(), and CMathDependencyNode::updatePrerequisiteState().
CMathDependencyNode * CMathDependencyNodeIterator::operator* | ( | ) |
This operator dereferences the iterator and returns a pointer the node of the graph
Definition at line 193 of file CMathDependencyNodeIterator.cpp.
References mStack.
CMathDependencyNode * CMathDependencyNodeIterator::operator-> | ( | ) |
This operator dereferences the iterator and returns a pointer the node of the graph
Definition at line 198 of file CMathDependencyNodeIterator.cpp.
References mStack.
const CMathDependencyNode * CMathDependencyNodeIterator::parent | ( | ) |
Retrieve the pointer to the parent node of the current node if known otherwise NULL
Definition at line 203 of file CMathDependencyNodeIterator.cpp.
References mStack.
Referenced by CMathDependencyNode::updateDependentState(), and CMathDependencyNode::updatePrerequisiteState().
Set the valid states for which the method next() should return
const | Flag & processingModes |
Definition at line 218 of file CMathDependencyNodeIterator.cpp.
References End, mProcessingModes, and Recursive.
Referenced by CMathDependencyNode::buildUpdateSequence(), CMathDependencyNode::updateDependentState(), and CMathDependencyNode::updatePrerequisiteState().
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
Definition at line 184 of file CMathDependencyNodeIterator.cpp.
References After, mCurrentState, CMathDependencyNodeIterator::CStackElement::mEndChild, CMathDependencyNodeIterator::CStackElement::mItChild, and mStack.
Referenced by CMathDependencyNode::buildUpdateSequence(), CMathDependencyNode::updateDependentState(), and CMathDependencyNode::updatePrerequisiteState().
const CMathDependencyNodeIterator::State & CMathDependencyNodeIterator::state | ( | ) | const |
Retrieve the current state of the iterator
Definition at line 208 of file CMathDependencyNodeIterator.cpp.
References mCurrentState.
Referenced by CMathDependencyNode::buildUpdateSequence(), CMathDependencyNode::updateDependentState(), and CMathDependencyNode::updatePrerequisiteState().
|
private |
The current state of the iterator
Definition at line 241 of file CMathDependencyNodeIterator.h.
Referenced by increment(), next(), skipChildren(), and state().
|
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
Definition at line 248 of file CMathDependencyNodeIterator.h.
Referenced by getProcessingModes(), next(), and setProcessingModes().
|
private |
A stack of context for each nesting level of the iterator
Definition at line 225 of file CMathDependencyNodeIterator.h.
Referenced by CMathDependencyNodeIterator(), increment(), level(), operator*(), operator->(), parent(), and skipChildren().
|
private |
The iterator type (Dependents or Prerequisites)
Definition at line 236 of file CMathDependencyNodeIterator.h.
Referenced by CMathDependencyNodeIterator().
|
private |
A set of currently visited nodes in the stack used to determine loops or recursive dependencies
Definition at line 231 of file CMathDependencyNodeIterator.h.
Referenced by CMathDependencyNodeIterator(), and increment().