MultiAgentDecisionProcess
TreeNode< Tcontained > Class Template Reference

TreeNode represents a node in a tree of histories, for instance observation histories. More...

#include <TreeNode.h>

Inheritance diagram for TreeNode< Tcontained >:
[legend]

Public Member Functions

bool ExistsSuccessor (LIndex sucI)
 Check whether a particular successor sucI exists. More...
 
Tcontained * GetContainedElement () const
 Returns a pointer to the contained element (Tcontained) More...
 
LIndex GetIndex () const
 Returns the index of this TreeNode (and thus corresponding to the contained element). More...
 
TreeNodeGetPredecessor () const
 Get the predecessor TreeNode*. More...
 
TreeNodeGetSuccessor (LIndex sucI)
 Get the succesor TreeNode* for the sucI'th successor. More...
 
void Print () const
 Prints the tree starting from this node of the history tree (including the successors). More...
 
void PrintThisNode () const
 Prints only this node of the history tree (not the successors). More...
 
void SetIndex (LIndex i)
 Sets the index to i. More...
 
void SetPredeccessor (TreeNode< Tcontained > *pred)
 Sets the predecessor of this node to be pred. More...
 
void SetSuccessor (LIndex sucI, TreeNode< Tcontained > *suc)
 Sets the sucI'th successor of this TreeNode to suc. More...
 
 TreeNode ()
 (default) Constructor More...
 
 TreeNode (Tcontained *const oh)
 
 TreeNode (const TreeNode &a)
 Copy constructor. More...
 
virtual ~TreeNode ()
 Destructor. More...
 

Protected Attributes

Tcontained * _m_containedElem
 The contained element. More...
 
LIndex _m_index
 The index of this TreeNode (and thus of the contained Tcontained - typically an observation history). More...
 
bool _m_indexValid
 Whether the index is valid. More...
 
TreeNode< Tcontained > * _m_pred
 A Pointer to the predecessor. More...
 
std::map< LIndex, TreeNode
< Tcontained > * > 
_m_successor
 The map that stores the pointers to the successor TreeNodes. More...
 

Detailed Description

template<class Tcontained>
class TreeNode< Tcontained >

TreeNode represents a node in a tree of histories, for instance observation histories.

TreeNode is a class that represents a wrapper for the Tcontained class. Each node also specifies a (sub-)tree so there is no actual difference between a tree and a node. This implementation assumes that ObservationHistories are always contained in exactly 1 TreeNode: i.e., deleting an object of TreeNode will free the memory of the node and the subtree represented by it as well as the memory of all the contained ObservationHistories.

Constructor & Destructor Documentation

template<class Tcontained>
TreeNode< Tcontained >::TreeNode ( )
inline

(default) Constructor

template<class Tcontained>
TreeNode< Tcontained >::TreeNode ( Tcontained *const  oh)
inline
template<class Tcontained>
TreeNode< Tcontained >::TreeNode ( const TreeNode< Tcontained > &  a)
inline

Copy constructor.

template<class Tcontained>
virtual TreeNode< Tcontained >::~TreeNode ( )
inlinevirtual

Destructor.

Member Function Documentation

template<class Tcontained >
bool TreeNode< Tcontained >::ExistsSuccessor ( LIndex  sucI)

Check whether a particular successor sucI exists.

template<class Tcontained>
Tcontained* TreeNode< Tcontained >::GetContainedElement ( ) const
inline
template<class Tcontained>
TreeNode* TreeNode< Tcontained >::GetPredecessor ( ) const
inline
template<class Tcontained >
TreeNode< Tcontained > * TreeNode< Tcontained >::GetSuccessor ( LIndex  sucI)

Get the succesor TreeNode* for the sucI'th successor.

Referenced by ObservationHistoryTree::GetSuccessor(), and JointObservationHistoryTree::GetSuccessor().

template<class Tcontained >
void TreeNode< Tcontained >::Print ( ) const

Prints the tree starting from this node of the history tree (including the successors).

Referenced by PlanningUnitMADPDiscrete::InitializeJointObservationHistories(), and PlanningUnitMADPDiscrete::Print().

template<class Tcontained >
void TreeNode< Tcontained >::PrintThisNode ( ) const

Prints only this node of the history tree (not the successors).

Referenced by TreeNode< ObservationHistory >::TreeNode(), and TreeNode< ObservationHistory >::~TreeNode().

template<class Tcontained>
void TreeNode< Tcontained >::SetPredeccessor ( TreeNode< Tcontained > *  pred)
inline

Sets the predecessor of this node to be pred.

This function is typically called by SetSuccessor (not manually).

Referenced by TreeNode< Tcontained >::SetSuccessor().

template<class Tcontained>
void TreeNode< Tcontained >::SetSuccessor ( LIndex  sucI,
TreeNode< Tcontained > *  suc 
)

Sets the sucI'th successor of this TreeNode to suc.

For example, the successor for observation number sucI. Also sets the predecessor of suc to this.

References TreeNode< Tcontained >::SetPredeccessor().

Referenced by PlanningUnitMADPDiscrete::CreateObservationHistoryTree(), PlanningUnitMADPDiscrete::InitializeJointObservationHistories(), ActionObservationHistoryTree::SetSuccessor(), and JointActionObservationHistoryTree::SetSuccessor().

Member Data Documentation

template<class Tcontained>
Tcontained* TreeNode< Tcontained >::_m_containedElem
protected
template<class Tcontained>
LIndex TreeNode< Tcontained >::_m_index
protected

The index of this TreeNode (and thus of the contained Tcontained - typically an observation history).

Referenced by TreeNode< ObservationHistory >::TreeNode().

template<class Tcontained>
bool TreeNode< Tcontained >::_m_indexValid
protected

Whether the index is valid.

Referenced by TreeNode< ObservationHistory >::TreeNode().

template<class Tcontained>
TreeNode<Tcontained>* TreeNode< Tcontained >::_m_pred
protected

A Pointer to the predecessor.

Referenced by TreeNode< ObservationHistory >::TreeNode().

template<class Tcontained>
std::map< LIndex, TreeNode<Tcontained>* > TreeNode< Tcontained >::_m_successor
protected

The map that stores the pointers to the successor TreeNodes.

Referenced by TreeNode< ObservationHistory >::TreeNode().