HTGS  v2.0
The Hybrid Task Graph Scheduler
htgs::StateContainer< T > Class Template Reference

Class to hold one/two dimensional state information. More...

#include <htgs/api/IRule.hpp>

Collaboration diagram for htgs::StateContainer< T >:
Collaboration graph

Public Member Functions

 StateContainer (size_t height, size_t width, T emptyData)
 Constructs a state container with a width and height, and what it considers to be empty data. More...
 
 ~StateContainer ()
 Destructor.
 
void set (size_t row, size_t col, T &value) const
 Sets a value (by reference) at a row column. More...
 
void assign (size_t row, size_t col, T value) const
 Sets a value at a row column (uses assignment operator) More...
 
void set (size_t index, T &value) const
 Sets a value (by reference) at an index. More...
 
void assign (size_t index, T value) const
 Sets a value at an index (uses assignment operator) More...
 
T & get (size_t row, size_t col) const
 Gets a value from a row column. More...
 
T & get (size_t index) const
 Gets a value from an index. More...
 
void remove (size_t row, size_t col)
 Removes the data from the specified row and column. More...
 
void remove (size_t index)
 Removes the data from the specified index. More...
 
bool has (size_t row, size_t col) const
 Checks whether the specified row column has data. More...
 
bool has (size_t index) const
 Checks whether the specified index has data. More...
 
void printState ()
 Prints the state of the state container. More...
 
void printContents ()
 Prints the contents of the state container. More...
 

Private Member Functions

size_t computeIndex (size_t row, size_t col) const
 Computes the one dimensional index from two dimension. More...
 

Private Attributes

T * data
 The pointer to data for the StateContainer.
 
size_t width
 The width of the StateContainer.
 
size_t height
 The height of the StateContainer.
 
emptyData
 The data value that represents no data.
 

Detailed Description

template<class T>
class htgs::StateContainer< T >

Class to hold one/two dimensional state information.

This class provides a quick method for identifiying state information for data that is passed to an IRule.

There are four helper functions to aid in creating a StateContainer within an IRule.

The StateContainer provides three core functions for handling state.

get - Retrieves a state value from a given index that may have been stored in the past set - Sets a state value at an index has - Checks whether a state value has been set at an index

Using these functions, the IRule can quickly determine when data dependencies are satisfied and get the data needed for passing to the next ITask.

Template Parameters
Tthe type of data for the state container

Constructor & Destructor Documentation

◆ StateContainer()

template<class T>
htgs::StateContainer< T >::StateContainer ( size_t  height,
size_t  width,
emptyData 
)
inline

Constructs a state container with a width and height, and what it considers to be empty data.

The empty data is used to initialize the array of data

Parameters
heightthe height of the state container
widththe width of the state container
emptyDatathe data value that represents there is no data

Member Function Documentation

◆ assign() [1/2]

template<class T>
void htgs::StateContainer< T >::assign ( size_t  row,
size_t  col,
value 
) const
inline

Sets a value at a row column (uses assignment operator)

Parameters
rowthe row
colthe column
valuethe value

◆ assign() [2/2]

template<class T>
void htgs::StateContainer< T >::assign ( size_t  index,
value 
) const
inline

Sets a value at an index (uses assignment operator)

Parameters
indexthe index
valuethe value

◆ computeIndex()

template<class T>
size_t htgs::StateContainer< T >::computeIndex ( size_t  row,
size_t  col 
) const
inlineprivate

Computes the one dimensional index from two dimension.

Parameters
rowthe row
colthe column
Returns
the mapping from two dimensions to one dimension

◆ get() [1/2]

template<class T>
T& htgs::StateContainer< T >::get ( size_t  row,
size_t  col 
) const
inline

Gets a value from a row column.

Parameters
rowthe row
colthe column
Returns
the value at the specified row column

◆ get() [2/2]

template<class T>
T& htgs::StateContainer< T >::get ( size_t  index) const
inline

Gets a value from an index.

Parameters
indexthe index
Returns
the value at the specified index

◆ has() [1/2]

template<class T>
bool htgs::StateContainer< T >::has ( size_t  row,
size_t  col 
) const
inline

Checks whether the specified row column has data.

Parameters
rowthe row
colthe column
Returns
whether there is data at the specified row column
Return values
TRUEif there is data at the specified row column
FALSEif the data at the row column is 'emptyData'
Note
'emptyData' is specified by the constructor of the StateContainer

◆ has() [2/2]

template<class T>
bool htgs::StateContainer< T >::has ( size_t  index) const
inline

Checks whether the specified index has data.

Parameters
indexthe index
Returns
whether there is data at the specified row column
Return values
TRUEif there is data at the specified row column
FALSEif the data at the row column is 'emptyData'
Note
'emptyData' is specified by the constructor of the StateContainer

◆ printContents()

template<class T>
void htgs::StateContainer< T >::printContents ( )
inline

Prints the contents of the state container.

Iterates over all elements and prints the contents within.

◆ printState()

template<class T>
void htgs::StateContainer< T >::printState ( )
inline

Prints the state of the state container.

Iterates over all elements and prints a 1 if data is not equal to the empty data, otherwise it prints 0.

◆ remove() [1/2]

template<class T>
void htgs::StateContainer< T >::remove ( size_t  row,
size_t  col 
)
inline

Removes the data from the specified row and column.

Parameters
rowthe row to remove data from
colthe column to remove data from

◆ remove() [2/2]

template<class T>
void htgs::StateContainer< T >::remove ( size_t  index)
inline

Removes the data from the specified index.

Parameters
indexthe index to remove data from

◆ set() [1/2]

template<class T>
void htgs::StateContainer< T >::set ( size_t  row,
size_t  col,
T &  value 
) const
inline

Sets a value (by reference) at a row column.

Parameters
rowthe row
colthe column
valuethe value

◆ set() [2/2]

template<class T>
void htgs::StateContainer< T >::set ( size_t  index,
T &  value 
) const
inline

Sets a value (by reference) at an index.

Parameters
indexthe index
valuethe value

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