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

Connects a Bookkeeper to another ITask using one or more IRule(s). More...

#include <htgs/core/rules/RuleManager.hpp>

Inheritance diagram for htgs::RuleManager< T, U >:
Inheritance graph
Collaboration diagram for htgs::RuleManager< T, U >:
Collaboration graph

Public Member Functions

 RuleManager (std::shared_ptr< htgs::IRule< T, U >> rule)
 Creates a rule manager with a rule. More...
 
virtual ~RuleManager () override
 Destructor.
 
void executeTask (std::shared_ptr< T > data) override
 Processes the input data, which is forwarded to the IRule synchronously. More...
 
RuleManager< T, U > * copy () override
 Creates a copy of the RuleManager. More...
 
std::string getName (int flags=0) override
 Gets the name of the RuleManager and the names of all IRules that it manages. More...
 
void debug () override
 Provides debug output. More...
 
std::shared_ptr< AnyConnectorgetConnector () override
 Gets the output connector associated with the RuleManager. More...
 
void initialize (size_t pipelineId, size_t numPipelines, std::string address) override
 Initializes the RuleManager. More...
 
void shutdown () override
 Shuts down the RuleManager. More...
 
bool isTerminated () override
 Checks whether the RuleManager is terminated or not. More...
 
void setOutputConnector (std::shared_ptr< AnyConnector > connector) override
 Sets the output connector that the RuleManager is attached to. More...
 
void checkRuleTermination () override
 Checks if the rule can be terminated or not.
 
- Public Member Functions inherited from htgs::AnyRuleManagerInOnly< T >
virtual ~AnyRuleManagerInOnly () override
 Destructor.
 
- Public Member Functions inherited from htgs::AnyRuleManager
virtual ~AnyRuleManager ()
 Destructor.
 

Private Attributes

std::shared_ptr< IRule< T, U > > rule
 The rule associated with the RuleManager.
 
size_t pipelineId
 The execution pipeline id.
 
size_t numPipelines
 The number of execution pipelines.
 
std::string address
 The address for the rule manager.
 
std::shared_ptr< htgs::Connector< U > > connector
 The connector for producing data from the rule.
 
volatile bool terminated
 Whether this RuleManager is terminated or not.
 

Detailed Description

template<class T, class U>
class htgs::RuleManager< T, U >

Connects a Bookkeeper to another ITask using one or more IRule(s).

When data is forwarded to the RuleManager from the Bookkeeper, the data is passed to an IRule that is associated with the RuleManager. Each IRule is responsible for determining when/if data is ready to be sent to the ITask the RuleManager is bound to.

The input and output types of each IRule added to a RuleManager must match the input and output types of the RuleManager.

Example Usage:

// DataRule implements IRule<Data1, Data2> to be compatible with ruleMan
DataRule *rule = new DataRule();
// The output task for the RuleManager with input type Data2
Data2ProcessingTask *data2Task = new Data2ProcessingTask();
// Creates edge between the Bookkeeper and the Data2ProcessingTask, where rule defines when data is sent
taskGraph->addRuleEdge(bkTask, rule, data2Task);
Template Parameters
Tthe input data type for the RuleManager, T must derive from IData.
Uthe output data type for the RuleManager, U must derive from IData.

Constructor & Destructor Documentation

◆ RuleManager()

template<class T, class U>
htgs::RuleManager< T, U >::RuleManager ( std::shared_ptr< htgs::IRule< T, U >>  rule)
inline

Creates a rule manager with a rule.

Parameters
rulethe rule
Note
This function should only be called by the HTGS API

Member Function Documentation

◆ copy()

template<class T, class U>
RuleManager<T, U>* htgs::RuleManager< T, U >::copy ( )
inlineoverridevirtual

Creates a copy of the RuleManager.

The original and all copies share the same rule and access them synchronously.

Returns
the RuleManager copy
Note
This function should only be called by the HTGS API

Implements htgs::AnyRuleManager.

◆ debug()

template<class T, class U>
void htgs::RuleManager< T, U >::debug ( )
inlineoverridevirtual

Provides debug output.

Note
#define DEBUG_FLAG to enable debugging

Implements htgs::AnyRuleManager.

◆ executeTask()

template<class T, class U>
void htgs::RuleManager< T, U >::executeTask ( std::shared_ptr< T >  data)
inlineoverridevirtual

Processes the input data, which is forwarded to the IRule synchronously.

It is possible the data received is nullptr, at which it will first check for rule termination before processing the null data.

Parameters
datathe input data
Note
This function should only be called by the HTGS API

Implements htgs::AnyRuleManagerInOnly< T >.

◆ getConnector()

template<class T, class U>
std::shared_ptr<AnyConnector> htgs::RuleManager< T, U >::getConnector ( )
inlineoverridevirtual

Gets the output connector associated with the RuleManager.

Returns
the output connector
Note
This function should only be called by the HTGS API

Implements htgs::AnyRuleManager.

◆ getName()

template<class T, class U>
std::string htgs::RuleManager< T, U >::getName ( int  flags = 0)
inlineoverridevirtual

Gets the name of the RuleManager and the names of all IRules that it manages.

Returns
the name

Implements htgs::AnyRuleManager.

◆ initialize()

template<class T, class U>
void htgs::RuleManager< T, U >::initialize ( size_t  pipelineId,
size_t  numPipelines,
std::string  address 
)
inlineoverridevirtual

Initializes the RuleManager.

Parameters
pipelineIdthe pipelineID
numPipelinesthe number of pipelines
addressthe address for the bookkeeper task
Note
This function should only be called by the HTGS API

Implements htgs::AnyRuleManager.

◆ isTerminated()

template<class T, class U>
bool htgs::RuleManager< T, U >::isTerminated ( )
inlineoverridevirtual

Checks whether the RuleManager is terminated or not.

Returns
Whether the RuleManager is terminated or not
Return values
TRUEif the RuleManager is terminated
FALSEif the RuleManager is not terminated
Note
This function should only be called by the HTGS API

Implements htgs::AnyRuleManager.

◆ setOutputConnector()

template<class T, class U>
void htgs::RuleManager< T, U >::setOutputConnector ( std::shared_ptr< AnyConnector connector)
inlineoverridevirtual

Sets the output connector that the RuleManager is attached to.

Parameters
connectorthe output connector
Note
This function should only be called by the HTGS API

Implements htgs::AnyRuleManager.

◆ shutdown()

template<class T, class U>
void htgs::RuleManager< T, U >::shutdown ( )
inlineoverridevirtual

Shuts down the RuleManager.

Will also shutdown the rule associated with the RuleManager Only called if the bookkeeper associated with the RuleManager is shutting down (all rules managers are closed and input is no longer producing data)

Note
This function should only be called by the HTGS API

Implements htgs::AnyRuleManager.


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