COPASI API  4.40.278
CCopasiTree< _Node > Class Template Reference

#include <CCopasiTree.h>

Classes

class  const_iterator
 
class  iterator
 

Public Types

typedef _Node Node
 

Public Member Functions

bool attachNode (_Node *pNode, _Node *pParent=NULL, _Node *pAfterChild=NULL)
 
iterator begin () const
 
 CCopasiTree ()
 
bool detachNode (_Node *pNode)
 
iterator end () const
 
_Node::Data getData () const
 
_Node * getRoot ()
 
const _Node * getRoot () const
 
bool moveNode (_Node *pNode, _Node *pParent=NULL, _Node *pAfterChild=NULL)
 
bool removeNode (_Node *pNode)
 
 ~CCopasiTree ()
 

Private Attributes

std::set< _Node * > mList
 
_Node * mpRoot
 

Friends

std::ostream & operator<< (std::ostream &os, const CCopasiTree< _Node > &A)
 

Detailed Description

template<class _Node>
class CCopasiTree< _Node >

CCopasiTree class. The template class CCopasiTree describes a tree of Nodes.

Created for COPASI by Stefan Hoops 2003

The template class CCopasiTree takes as template argument a class derived from the class CCopasiNode. It allows the construction of a tree with four simple methods. It assures that each node in the tree is unique.

In addition it provides a forward iterator useful to traverse the tree.

Note: The tree takes ownership of all nodes. Therefore, you must not use pointers to automatically created nodes in the attachNode() Function unless you use the detach node function prior to the destruction of the tree.

Member Typedef Documentation

◆ Node

template<class _Node >
typedef _Node CCopasiTree< _Node >::Node

Constructor & Destructor Documentation

◆ CCopasiTree()

template<class _Node >
CCopasiTree< _Node >::CCopasiTree ( )
inline

Default constructor

References CCopasiTree< _Node >::mList, and CCopasiTree< _Node >::mpRoot.

◆ ~CCopasiTree()

template<class _Node >
CCopasiTree< _Node >::~CCopasiTree ( )
inline

Destructor

References CCopasiTree< _Node >::mpRoot, and pdelete.

Member Function Documentation

◆ attachNode()

template<class _Node >
bool CCopasiTree< _Node >::attachNode ( _Node *  pNode,
_Node *  pParent = NULL,
_Node *  pAfterChild = NULL 
)
inline

Attach a Node to the tree Note: If pAfterChild == pParent then the child will be inserted as the first child

Parameters
Node* pNode
Node* pParent (default: NULL equivalent to the root of the tree)
Node* pAfterChild (default: NULL at the end of the children)
Returns
bool Success

References CCopasiTree< _Node >::end(), CCopasiTree< _Node >::mList, and CCopasiTree< _Node >::mpRoot.

Referenced by CCopasiTree< _Node >::moveNode().

◆ begin()

template<class _Node >
iterator CCopasiTree< _Node >::begin ( ) const
inline

Retrieve an iterator pointing to the beginning of the tree

Returns
iterator begin

References CCopasiTree< _Node >::mpRoot.

◆ detachNode()

template<class _Node >
bool CCopasiTree< _Node >::detachNode ( _Node *  pNode)
inline

Detach node. Node: After detachment of a node the tree no longer has the ownership.

Parameters
Node* pNode
Returns
bool Success

References CCopasiTree< _Node >::end(), CCopasiTree< _Node >::mList, and CCopasiTree< _Node >::mpRoot.

Referenced by CCopasiTree< _Node >::moveNode().

◆ end()

template<class _Node >
iterator CCopasiTree< _Node >::end ( ) const
inline

Retrieve an iterator pointing beyond the end of the tree

Returns
iterator end

Referenced by CCopasiTree< _Node >::attachNode(), CCopasiTree< _Node >::detachNode(), and CCopasiTree< _Node >::removeNode().

◆ getData()

template<class _Node >
_Node::Data CCopasiTree< _Node >::getData ( ) const
inline

Retrieve the data of the Tree.

Returns
Data data

References CCopasiTree< _Node >::mpRoot.

◆ getRoot() [1/2]

template<class _Node >
_Node* CCopasiTree< _Node >::getRoot ( )
inline

Retrieve the root node of the tree

Returns
Node * root

References CCopasiTree< _Node >::mpRoot.

◆ getRoot() [2/2]

template<class _Node >
const _Node* CCopasiTree< _Node >::getRoot ( ) const
inline

Retrieve the root node of the tree

Returns
Node * root

References CCopasiTree< _Node >::mpRoot.

◆ moveNode()

template<class _Node >
bool CCopasiTree< _Node >::moveNode ( _Node *  pNode,
_Node *  pParent = NULL,
_Node *  pAfterChild = NULL 
)
inline

Move a given node from its current place in the tree to the one specified by pParent and pAfterChild. The insertion behavior is similar to addChild().

Parameters
Node* pNode
Node* pParent (default: NULL equivalent to the root of the tree)
Node* pAfterChild (default: NULL at the end of the children)
Returns
bool Success

References CCopasiTree< _Node >::attachNode(), and CCopasiTree< _Node >::detachNode().

◆ removeNode()

template<class _Node >
bool CCopasiTree< _Node >::removeNode ( _Node *  pNode)
inline

Remove the given node of the tree

Parameters
Node* pNode
Returns
bool Success

References CCopasiTree< _Node >::end(), CCopasiTree< _Node >::mList, and CCopasiTree< _Node >::mpRoot.

Friends And Related Function Documentation

◆ operator<<

template<class _Node >
std::ostream& operator<< ( std::ostream &  os,
const CCopasiTree< _Node > &  A 
)
friend

Member Data Documentation

◆ mList

template<class _Node >
std::set<_Node *> CCopasiTree< _Node >::mList
private

The list of all nodes. This is used to keep the tree consistent by avoiding multiple inserts of the same node.

Referenced by CCopasiTree< _Node >::attachNode(), CCopasiTree< _Node >::CCopasiTree(), CCopasiTree< _Node >::detachNode(), and CCopasiTree< _Node >::removeNode().

◆ mpRoot


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