21#ifndef HEDGEHOG_GRAPH_SINK_H
22#define HEDGEHOG_GRAPH_SINK_H
25#include "../abstractions/base/input_output/slot_abstraction.h"
26#include "../abstractions/base/node/node_abstraction.h"
27#include "../abstractions/base/input_output/receiver_abstraction.h"
29#include "../implementors/concrete_implementor/default_slot.h"
30#include "../implementors/concrete_implementor/queue_receiver.h"
39template<
class ...Outputs>
45 using ResultType_t = std::shared_ptr<std::variant<std::shared_ptr<Outputs>...>>;
50 SlotAbstraction(std::static_pointer_cast<implementor::ImplementorSlot>(std::make_shared<implementor::DefaultSlot>())),
52 std::make_shared<implementor::QueueReceiver < Outputs>>(),
64 std::unique_lock<std::mutex> lock(*(this->
mutex()));
73 res = std::make_shared<std::variant<std::shared_ptr<Outputs>...>>();
74 bool outputFound =
false;
75 (getOneAvailableResultForAType<Outputs>(outputFound, res), ...);
90 [[nodiscard]] std::vector<std::pair<std::string const, std::string const>>
ids()
const override {
91 return {{this->
id(), this->
id()}};
101 template<
class Output>
119 throw std::runtime_error(
"Try to get a node out of a core switch while there is none.");
Printer abstraction to get a snapshot of the metrics of the Hedgehog graph.
virtual void printSink(core::abstraction::NodeAbstraction const *sink)=0
Print outer graph sink.
Behavior abstraction for the base node.
Core's abstraction to receive a piece of data.
std::shared_ptr< Input > getInputData()
Get an input data from the concrete receiver implementation.
void printEdgeInformation(Printer *printer)
Add to the printer the edge information.
ReceiverAbstraction(std::shared_ptr< implementor::ImplementorReceiver< Outputs > > concreteReceiver, std::shared_ptr< std::mutex > slotMutex)
Constructor using a concrete implementation of a receiver implementor, and the mutex from the slot.
Core's abstraction to receive a signal.
std::shared_ptr< std::mutex > const & mutex() const
Protected accessor to mutex.
bool hasNotifierConnected() const
Test if there is at least one notifier connected.
SlotAbstraction(std::shared_ptr< implementor::ImplementorSlot > concreteSlot)
Constructor using a concrete slot implementation.
std::shared_ptr< std::condition_variable > const & slotConditionVariable() const
Protected accessor to condition variable.
Base core node abstraction.
virtual std::string id() const
Core's id ('x' + address of abstraction) as string.
NodeAbstraction(std::string name)
Core node constructor using the core's name.
Sink of the graph, only used in an outer graph.
void wakeUp() override
Wake up implementation (notify one node waiting on the condition variable)
behavior::Node * node() const override
Getter to the node counterpart.
void print(Printer *printer)
Gather sink information.
void getOneAvailableResultForAType(bool &outputFound, ResultType_t &res)
Test if there is an available output data for a data.
ResultType_t getBlockingResult()
Get a result from the sink, if none is available wait for it (block the current thread)
~GraphSink() override=default
Default destructor.
GraphSink()
Default constructor.
bool receiversEmpty()
Test if the receivers for all types are empty.
std::vector< std::pair< std::string const, std::string const > > ids() const override
Node ids [nodeId, nodeGroupId] accessor.
std::shared_ptr< std::variant< std::shared_ptr< Outputs >... > > ResultType_t
Accessor to the output types.