Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
openfluid::core::Tree< K, V > Class Template Reference

#include <core/Tree.hpp>

Collaboration diagram for openfluid::core::Tree< K, V >:
Collaboration graph
[legend]

Public Types

typedef std::map< K, Tree< K, V > > Children_t
 
typedef Children_t::iterator iterator
 
typedef Children_t::const_iterator const_iterator
 

Public Member Functions

 Tree ()
 
getValue () const
 
getValue (const V &DefaultVal) const
 
void setValue (const V &Val)
 
bool hasValue () const
 
Children_tchildren ()
 
const Children_tchildren () const
 
Tree< K, V > & child (const K &Key)
 
const Tree< K, V > & child (const K &Key) const
 
getChildValue (const K &Key, const V &DefaultVal) const
 
bool hasChild (const K &Key) const
 
Tree< K, V > & addChild (const K &Key, const V &Val)
 
Tree< K, V > & addChild (const K &Key)
 
void deleteChild (const K &Key)
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
void clear ()
 
unsigned int size () const
 
void writeToStreamHierarchically (std::ostream &OutStm, unsigned int Indent=0) const
 
void writeToStreamFlat (std::ostream &OutStm) const
 

Protected Member Functions

std::string keyToStr (const K &Key) const
 

Protected Attributes

m_Value
 
Children_t m_Children
 
bool m_HasValue
 

Member Typedef Documentation

template<typename K, typename V>
typedef std::map<K,Tree<K,V> > openfluid::core::Tree< K, V >::Children_t
template<typename K, typename V>
typedef Children_t::const_iterator openfluid::core::Tree< K, V >::const_iterator
template<typename K, typename V>
typedef Children_t::iterator openfluid::core::Tree< K, V >::iterator

Constructor & Destructor Documentation

template<typename K, typename V>
openfluid::core::Tree< K, V >::Tree ( )
inline

Member Function Documentation

template<typename K, typename V>
Tree<K,V>& openfluid::core::Tree< K, V >::addChild ( const K &  Key,
const V &  Val 
)
inline

Adds a child to the current node, identified by its key and with the given value

Parameters
[in]Keythe key of the child node
[in]Valthe value of the child node
Returns
the reference to the added child node
Exceptions
openfluid::base::FrameworkExceptionif the child already exists
template<typename K, typename V>
Tree<K,V>& openfluid::core::Tree< K, V >::addChild ( const K &  Key)
inline

Adds a child to the current node, identified by its key and with no value

Parameters
[in]Keythe key of the child node
Returns
the reference to the added child node
Exceptions
openfluid::base::FrameworkExceptionif the child already exists
template<typename K, typename V>
iterator openfluid::core::Tree< K, V >::begin ( )
inline

Returns an iterator referring to the first element of the children map

Returns
an iterator to the first element in the children map
template<typename K, typename V>
const_iterator openfluid::core::Tree< K, V >::begin ( ) const
inline

Returns a const iterator referring to the first element of the children map

Returns
a const iterator to the first element in the children map
template<typename K, typename V>
Tree<K,V>& openfluid::core::Tree< K, V >::child ( const K &  Key)
inline

Returns a reference to the child of the current node, identified by its key

Parameters
[in]Keythe key of the child node
Returns
the reference to the child node
Exceptions
openfluid::base::FrameworkExceptionif the child does not exist
template<typename K, typename V>
const Tree<K,V>& openfluid::core::Tree< K, V >::child ( const K &  Key) const
inline

Returns a const reference to the child of the current node, identified by its key

Parameters
[in]Keythe key of the child node
Returns
the reference to the child node
Exceptions
openfluid::base::FrameworkExceptionif the child does not exist
template<typename K, typename V>
Children_t& openfluid::core::Tree< K, V >::children ( )
inline

Returns a reference to the map of children of the current node

Returns
a map of children
template<typename K, typename V>
const Children_t& openfluid::core::Tree< K, V >::children ( ) const
inline

Returns a const reference to the map of children of the current node

Returns
a map of children
template<typename K, typename V>
void openfluid::core::Tree< K, V >::clear ( )
inline

Clears the tree determined by the current node

template<typename K, typename V>
void openfluid::core::Tree< K, V >::deleteChild ( const K &  Key)
inline

Deletes a child of the current node, identified by its key and with no value

Parameters
[in]Keythe key of the child node to delete
template<typename K, typename V>
iterator openfluid::core::Tree< K, V >::end ( )
inline

Returns an iterator referring to the past-the-end element of the children map

Returns
an iterator to the past-the-end element of the children map
template<typename K, typename V>
const_iterator openfluid::core::Tree< K, V >::end ( ) const
inline

Returns a const iterator referring to the past-the-end element of the children map

Returns
a const iterator to the past-the-end element of the children map
template<typename K, typename V>
V openfluid::core::Tree< K, V >::getChildValue ( const K &  Key,
const V &  DefaultVal 
) const
inline

Returns the value of the child of the current node, identified by its key. If the child node does not have a value, the given default value is returned

Parameters
[in]Keythe key of the child node
[in]DefaultValthe default value
Returns
the value of the child node or the default value
template<typename K, typename V>
V openfluid::core::Tree< K, V >::getValue ( ) const
inline

Returns the value of the current tree node

Returns
the value associated to the node
Exceptions
openfluid::base::FrameworkExceptionif the node does not have a value
template<typename K, typename V>
V openfluid::core::Tree< K, V >::getValue ( const V &  DefaultVal) const
inline

Returns the value of the current tree node, or a default value if the node does not have a value

Parameters
[in]DefaultValthe default value
Returns
the value associated to the node or the default value
template<typename K, typename V>
bool openfluid::core::Tree< K, V >::hasChild ( const K &  Key) const
inline

Returns true if the current node has a child identified by the given key

Returns
true if the child node has been found, false otherwise
template<typename K, typename V>
bool openfluid::core::Tree< K, V >::hasValue ( ) const
inline

Returns true if the node has a value

Returns
true if the node has a value, false otherwise
template<typename K, typename V>
std::string openfluid::core::Tree< K, V >::keyToStr ( const K &  Key) const
inlineprotected
template<typename K, typename V>
void openfluid::core::Tree< K, V >::setValue ( const V &  Val)
inline

Sets the value of the current tree node

Parameters
[in]Valthe value of the node
template<typename K, typename V>
unsigned int openfluid::core::Tree< K, V >::size ( ) const
inline

Returns the size of the tree determined by the current node

Returns
the size of the tree
template<typename K, typename V>
void openfluid::core::Tree< K, V >::writeToStreamFlat ( std::ostream &  OutStm) const
inline
template<typename K, typename V>
void openfluid::core::Tree< K, V >::writeToStreamHierarchically ( std::ostream &  OutStm,
unsigned int  Indent = 0 
) const
inline

Writes hierarchically the tree determined by the current node into the given stream, using the given indentation

Parameters
[in]OutStmthe output stream to write into
[in]Indentthe indent value for children nodes

Member Data Documentation

template<typename K, typename V>
Children_t openfluid::core::Tree< K, V >::m_Children
protected
template<typename K, typename V>
bool openfluid::core::Tree< K, V >::m_HasValue
protected
template<typename K, typename V>
V openfluid::core::Tree< K, V >::m_Value
protected

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