15 #ifndef HTGS_BOOKKEEPER_HPP 16 #define HTGS_BOOKKEEPER_HPP 61 static_assert(std::is_base_of<IData, T>::value,
"T must derive from IData");
69 this->
ruleManagers =
new std::list<AnyRuleManagerInOnly<T> *>();
78 ruleManager =
nullptr;
81 ruleManagers =
nullptr;
123 ruleManager->executeTask(data);
132 return "Bookkeeper -- " + std::to_string(this->
ruleManagers->size()) +
" rule(s): " +
151 HTGS_DEBUG(
"Executing rule manager: " << ruleManager->getName());
152 ruleManager->debug();
157 bool canTerminate(std::shared_ptr<AnyConnector> inputConnector)
override {
159 HTGS_ASSERT(inputConnector !=
nullptr,
"A Bookkeeper does not appear to have any input, which results in this bookkeeper not doing anything");
160 assert(inputConnector !=
nullptr);
161 if (inputConnector->isInputTerminated())
168 ruleManager->checkRuleTermination();
192 ruleManager->shutdown();
206 std::string
genDot(
int flags, std::string idStr) {
207 std::ostringstream oss;
212 std::string ruleManStr = ruleMan->getConnector()->getDotId();
215 oss << idStr <<
" -> " << ruleManStr <<
"[label=\"" << ruleMan->getName(flags) <<
"\"];" << std::endl;
220 oss << idStr <<
";" << std::endl;
226 std::string genDotProducerEdgeToTask(std::map<std::shared_ptr<AnyConnector>,
AnyITask *> &inputConnectorDotMap,
int dotFlags)
override 228 std::ostringstream oss;
230 auto connectorPair = inputConnectorDotMap.find(ruleMan->getConnector());
231 if (connectorPair != inputConnectorDotMap.end())
233 oss << this->
getDotId() <<
" -> " << connectorPair->second->getConsumerDotIds() <<
"[label=\"" << ruleMan->getName(dotFlags) <<
"\"];" << std::endl;
241 std::string genDotProducerEdgeFromConnector(std::shared_ptr<AnyConnector> connector,
int flags)
243 std::ostringstream oss;
244 if (connector !=
nullptr)
247 if (connector == ruleMan->getConnector())
249 oss << this->
getDotId() <<
" -> " << connector->getDotId() <<
"[label=\"" << ruleMan->getName(flags) <<
"\"];" << std::endl;
257 std::list<AnyRuleManagerInOnly<T> *> *getRuleManagers() {
281 #endif //HTGS_BOOKKEEPER_HPP virtual std::string getDotLabelName() override
Gets just the name "Bookkeeper" for the dot label.
Definition: Bookkeeper.hpp:140
bool canTerminate(std::shared_ptr< AnyConnector > inputConnector) override
Virtual function that is called when an ITask is checking if it can be terminated.
Definition: Bookkeeper.hpp:157
VoidData is used for data that is empty/void.
virtual ~Bookkeeper() override
Destructor destroys RuleManager memory.
Definition: Bookkeeper.hpp:75
Implements the parent ITask, which removes the template arguments of an ITask.
Definition: AnyITask.hpp:48
std::string getDotId()
Gets the id used for dot nodes.
Definition: AnyITask.hpp:497
std::string genDot(int flags, std::string idStr)
Generates the dot notation for the bookkeeper.
Definition: Bookkeeper.hpp:206
void shutdown()
Shuts down this bookkeeper and all of it's RuleManagers.
Definition: Bookkeeper.hpp:188
void addRuleManager(RuleManager< T, U > *ruleManager)
Adds rule manager to this bookkeeper.
Definition: Bookkeeper.hpp:104
Implements the base class for the rule manager, but only providing the input type.
void debug() override
Provides debug output for the rule manager.
Definition: Bookkeeper.hpp:148
std::list< AnyRuleManagerInOnly< T > * > * ruleManagers
The list of ruleManagers (one per consumer)
Definition: Bookkeeper.hpp:276
void executeTask(std::shared_ptr< T > data) override
Executes the bookkeeper on data.
Definition: Bookkeeper.hpp:119
void addRuleManager(AnyRuleManager *ruleManager)
Adds rule manager to this bookkeeper.
Definition: Bookkeeper.hpp:89
#define HTGS_DEBUG_VERBOSE(msg)
Prints a debug message to std:cerr with VERBOSE level.
Definition: debug_message.hpp:75
std::string ruleManagerInfo
A string representation of all rule managers.
Definition: Bookkeeper.hpp:277
Bookkeeper< T > * copy()
Creates a shallow copy of this bookkeeper.
Definition: Bookkeeper.hpp:201
std::string getName() override
Gets the name of this bookkeeper and all rule managers it controls.
Definition: Bookkeeper.hpp:131
size_t getNumPipelines() const
Sets the task graph communicator.
Definition: AnyITask.hpp:404
size_t getPipelineId()
Gets the pipeline ID.
Definition: AnyITask.hpp:367
Connects a Bookkeeper to another ITask using one IRule.
Definition: AnyRuleManager.hpp:53
std::string getAddress() override final
Definition: ITask.hpp:511
Implements the base class for the rule manager, but only provides the input type. ...
Definition: AnyRuleManagerInOnly.hpp:27
#define HTGS_DEBUG(msg)
Prints a debug message to std::cerr with standard level If DEBUG_FLAG is not defined, this equates to a no op Each message includes the file and line number for where the debug is called.
Definition: debug_message.hpp:65
std::string getName(int flags=0) override
Gets the name of the RuleManager and the names of all IRules that it manages.
Definition: RuleManager.hpp:112
An interface to process input data and forward results within a TaskGraph.
Definition: ITask.hpp:165
Connects a Bookkeeper to another ITask using one or more IRule(s).
Definition: RuleManager.hpp:57
void initialize() override
Initializes the bookkeeper and all RuleManagers.
Definition: Bookkeeper.hpp:178
#define HTGS_ASSERT(condition, message)
Prints a more meaningful assertion message and terminates if the condition fails. ...
Definition: debug_message.hpp:25
virtual std::string getName(int flags=0)=0
Gets the name of the RuleManager and the names of all IRules that it manages.
An interface to process input data and forward results within a TaskGraph.
Definition: Bookkeeper.hpp:23
Bookkeeper()
Constructs a bookkeeper.
Definition: Bookkeeper.hpp:68
#define DOTGEN_FLAG_SHOW_CONNECTOR_VERBOSE
Shows verbose information within each connector in the graph.
Definition: TaskGraphDotGenFlags.hpp:92
Implements a RuleManager, which connects a Bookkeeper to another ITask using an IRule.
Special task used to manage rules.
Definition: Bookkeeper.hpp:60