Otawa  0.10
otawa::tsim::TreePath< T1, T2 > Class Template Reference

#include <otawa/tsim/TreePath.h>

Classes

class  Iterator
 

Public Member Functions

 TreePath (int max_childs=DEFAULT_MAX_CHILDS)
 Builds a new empty TreePath. More...
 
 TreePath (const T1 label, const T2 data, int max_childs=DEFAULT_MAX_CHILDS)
 Builds a new TreePath with initial values for its root. More...
 
 TreePath (elm::genstruct::Vector< T1 > &path, const T2 data, int max_childs=DEFAULT_MAX_CHILDS)
 Builds a new TreePath with initial values for an initial path. More...
 
 TreePath (elm::genstruct::Vector< T1 > *path, const T2 data, int max_childs=DEFAULT_MAX_CHILDS)
 Builds a new TreePath with initial values for an initial path. More...
 
 ~TreePath ()
 Destroys all his childs. More...
 
T1 rootLabel () const
 
T2 rootData () const
 
elm::Option< T2 > get (const elm::genstruct::Vector< T1 > &path, int from_index=0)
 Gives an optional value attached to the path given. More...
 
void add (elm::genstruct::Vector< T1 > &path, const T2 data, int from_index=0)
 Adds a value attached to the path given. More...
 
void add (elm::genstruct::Vector< T1 > *path, const T2 data, int from_index=0)
 Adds a value attached to the path given. More...
 

Private Member Functions

 TreePath (const T1 label, int max_childs=DEFAULT_MAX_CHILDS)
 
TreePath< T1, T2 > * searchChild (const T1 &label) const
 

Private Attributes

T1 _label
 
elm::Option< T2 > _data
 
int _max_childs
 
elm::genstruct::Vector
< TreePath< T1, T2 > * > 
_childs
 

Detailed Description

template<class T1, class T2>
class otawa::tsim::TreePath< T1, T2 >

Author
G. Cavaignac

This class is used for holding unique sequences in a tree so that it is very fast to retrieve the matched sequence with a list of elements

Parameters
T1element of the sequence
T2type holding the data of the sequence

Constructor & Destructor Documentation

template<class T1, class T2 >
otawa::tsim::TreePath< T1, T2 >::TreePath ( const T1  label,
int  max_childs = DEFAULT_MAX_CHILDS 
)
inlineprivate
template<class T1, class T2 >
otawa::tsim::TreePath< T1, T2 >::TreePath ( int  max_childs = DEFAULT_MAX_CHILDS)
inline

Builds a new empty TreePath.

Parameters
max_childsfor speed only: gives this initial capacity for the size of the vector holding childs

References otawa::tsim::TreePath< T1, T2 >::_data, and elm::none.

template<class T1, class T2>
otawa::tsim::TreePath< T1, T2 >::TreePath ( const T1  label,
const T2  data,
int  max_childs = DEFAULT_MAX_CHILDS 
)
inline

Builds a new TreePath with initial values for its root.

Parameters
labelelement of the sequence
datadata attached to the sequence [label] (length=1)
max_childsfor speed only: gives this initial capacity for the size of the vector holding childs

References otawa::tsim::TreePath< T1, T2 >::_data, and otawa::tsim::TreePath< T1, T2 >::_label.

template<class T1, class T2>
otawa::tsim::TreePath< T1, T2 >::TreePath ( elm::genstruct::Vector< T1 > &  path,
const T2  data,
int  max_childs = DEFAULT_MAX_CHILDS 
)
inline

Builds a new TreePath with initial values for an initial path.

Parameters
pathfirst path in the tree
datadata attached to the path
max_childsfor speed only: gives this initial capacity for the size of the vector holding childs

References otawa::tsim::TreePath< T1, T2 >::_data, otawa::tsim::TreePath< T1, T2 >::_label, otawa::tsim::TreePath< T1, T2 >::add(), and elm::none.

template<class T1, class T2>
otawa::tsim::TreePath< T1, T2 >::TreePath ( elm::genstruct::Vector< T1 > *  path,
const T2  data,
int  max_childs = DEFAULT_MAX_CHILDS 
)
inline

Builds a new TreePath with initial values for an initial path.

Parameters
pathfirst path in the tree
datadata attached to the path
max_childsfor speed only: gives this initial capacity for the size of the vector holding childs

References otawa::tsim::TreePath< T1, T2 >::_data, otawa::tsim::TreePath< T1, T2 >::_label, otawa::tsim::TreePath< T1, T2 >::add(), and elm::none.

template<class T1 , class T2 >
otawa::tsim::TreePath< T1, T2 >::~TreePath ( )
inline

Destroys all his childs.

Member Function Documentation

template<class T1, class T2>
void otawa::tsim::TreePath< T1, T2 >::add ( elm::genstruct::Vector< T1 > &  path,
const T2  data,
int  from_index = 0 
)
inline

Adds a value attached to the path given.

Parameters
paththe path wich we want to attach some data
datadata to attach to the path
from_indexif we don't want to start searching the path with the index 0 of the Vector

References otawa::tsim::TreePath< T1, T2 >::_childs, otawa::tsim::TreePath< T1, T2 >::_data, elm::genstruct::Vector< T >::add(), elm::genstruct::Vector< T >::length(), and otawa::tsim::TreePath< T1, T2 >::searchChild().

Referenced by otawa::tsim::BBPath::getBBPath(), and otawa::tsim::TreePath< T1, T2 >::TreePath().

template<class T1, class T2>
void otawa::tsim::TreePath< T1, T2 >::add ( elm::genstruct::Vector< T1 > *  path,
const T2  data,
int  from_index = 0 
)
inline

Adds a value attached to the path given.

Parameters
paththe path wich we want to attach some data
datadata to attach to the path
from_indexif we don't want to start searching the path with the index 0 of the Vector

References otawa::sem::add().

template<class T1, class T2 >
elm::Option< T2 > otawa::tsim::TreePath< T1, T2 >::get ( const elm::genstruct::Vector< T1 > &  path,
int  from_index = 0 
)
inline

Gives an optional value attached to the path given.

Parameters
pathpath searched
from_indexif we don't want to start searching the path with the index 0 of the Vector
Returns
optional value. If this value exists, the path have a data attached

References otawa::tsim::TreePath< T1, T2 >::_data, elm::genstruct::Vector< T >::length(), elm::none, and otawa::tsim::TreePath< T1, T2 >::searchChild().

Referenced by otawa::tsim::BBPath::getBBPath().

template<class T1 , class T2 >
T2 otawa::tsim::TreePath< T1, T2 >::rootData ( ) const
inline
Returns
label for sequence (length=1) attached to the root.
Attention
If we don't use the root, this function gives a meaningless value

Referenced by otawa::tsim::BBPath::getBBPath().

template<class T1 , class T2 >
T1 otawa::tsim::TreePath< T1, T2 >::rootLabel ( ) const
inline
Returns
label for the root
Attention
If we don't use the root, this function gives a meaningless value
template<class T1, class T2 >
TreePath< T1, T2 > * otawa::tsim::TreePath< T1, T2 >::searchChild ( const T1 &  label) const
inlineprivate

Member Data Documentation

template<class T1, class T2>
elm::genstruct::Vector<TreePath<T1,T2>*> otawa::tsim::TreePath< T1, T2 >::_childs
private
template<class T1, class T2>
T1 otawa::tsim::TreePath< T1, T2 >::_label
private
template<class T1, class T2>
int otawa::tsim::TreePath< T1, T2 >::_max_childs
private

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