19#ifndef HEDGEHOG_EXECUTION_PIPELINE_INPUTS_MANAGEMENT_ABSTRACTION_H_
20#define HEDGEHOG_EXECUTION_PIPELINE_INPUTS_MANAGEMENT_ABSTRACTION_H_
22#include "../../parts/core_switch.h"
24#include "../base/input_output/slot_abstraction.h"
25#include "../base/input_output/receiver_abstraction.h"
27#include "../../implementors/concrete_implementor/default_slot.h"
28#include "../../implementors/concrete_implementor/queue_receiver.h"
35namespace abstraction {
39template<
class ...Inputs>
54 ExecutionPipelineImplementation>
58 std::make_shared<implementor::QueueReceiver<Inputs>>(),
61 (static_cast<behavior::MultiSwitchRules<Inputs...> * >(executionPipeline))){}
80 return this->
coreSwitch_->callSendToGraph(data, graphId);
91 (connectInputGraphForAType<Inputs>(graph), ...);
92 for (
auto slot : std::static_pointer_cast<SlotAbstraction>(graph)->slots()) {
93 switchAsNotifier->
addSlot(slot);
94 slot->addNotifier(switchAsNotifier);
101 for (
auto &slot : switchAsNotifier->connectedSlots()) {
102 for (
auto &s : slot->slots()) {
103 s->removeNotifier(switchAsNotifier);
127 std::unique_lock<std::mutex> lock(*(this->
mutex()));
146 template<
class Input>
151 receiver->addSender(switchAsSender);
Printer abstraction to get a snapshot of the metrics of the Hedgehog graph.
Switch rules behavior abstraction for different types of input.
Core abstraction to notify slots.
void addSlot(SlotAbstraction *const slot)
Add a SlotAbstraction to this notifier.
Core's abstraction to receive a piece of data.
void printEdgeInformation(Printer *printer)
Add to the printer the edge information.
std::set< ReceiverAbstraction * > const & receivers() const
Const accessor to receivers.
Core abstraction to send data.
void addReceiver(ReceiverAbstraction< Output > *const receiver)
Add a ReceiverAbstraction.
Core's abstraction to receive a signal.
void unlockSlotMutex()
Unlock mutex.
std::shared_ptr< std::mutex > const & mutex() const
Protected accessor to mutex.
void lockSlotMutex()
Lock mutex.
bool hasNotifierConnected() const
Test if there is at least one notifier connected.
std::shared_ptr< std::condition_variable > const & slotConditionVariable() const
Protected accessor to condition variable.
Input management abstraction for the execution pipeline.
bool receiversEmpty() const
Test if the receivers are empty.
bool wait()
Wait statement when the node is alive and no input data are available.
std::unique_ptr< CoreSwitch< Inputs... > > coreSwitch_
Core switch used to call user-defined rules.
void disconnectSwitch()
Disconnect the switch from all of the graphs.
void wakeUp() override
Wake up implementation (notify one node waiting on the condition variable)
void connectGraphToSwitch(std::shared_ptr< GraphInputsManagementAbstraction< Inputs... > > const graph)
Connect a graph to the switch.
ExecutionPipelineInputsManagementAbstraction(ExecutionPipelineImplementation *const executionPipeline)
Construct an Input management abstraction for the execution pipeline from an implementation of MultiS...
std::tuple< Inputs... > inputs_t
Accessor to inputs data.
bool callSendToGraph(std::shared_ptr< Input > &data, size_t const &graphId)
Interface to the user-defined switch rule.
void connectInputGraphForAType(std::shared_ptr< GraphInputsManagementAbstraction< Inputs... > > const graph)
Connect a graph to the switch for the type Input.
~ExecutionPipelineInputsManagementAbstraction() override=default
Default destructor.
CoreSwitch< Inputs... > * coreSwitch() const
Accessor to the switch core.
bool canTerminate(bool lock)
Can terminate implementation.
void printEdgesInformation(Printer *printer)
Visitor for the execution pipeline edge.
Input management abstraction for the graph.
Concept verifying that a type is in a variadic.