21#ifndef HEDGEHOG_GRAPH_INPUTS_MANAGEMENT_ABSTRACTION_H 
   22#define HEDGEHOG_GRAPH_INPUTS_MANAGEMENT_ABSTRACTION_H 
   27#include "../../implementors/concrete_implementor/graph/graph_receiver.h" 
   28#include "../../implementors/concrete_implementor/graph/graph_slot.h" 
   30#include "../../parts/graph_source.h" 
   32#include "../base/input_output/slot_abstraction.h" 
   33#include "../base/input_output/sender_abstraction.h" 
   34#include "../base/input_output/notifier_abstraction.h" 
   35#include "../base/input_output/receiver_abstraction.h" 
   37#include "../../../tools/concepts.h" 
   43namespace abstraction {
 
   47template<
class ...Inputs>
 
   60          std::static_pointer_cast<implementor::ImplementorSlot>(
 
   61              std::make_shared<implementor::GraphSlot>()
 
   76    for (
auto slot : this->
slots()) {
 
   84  bool wait() { 
throw std::runtime_error(
"A graph can not wait"); }
 
   97  template<
class InputDataType>
 
  101        "The input type (InputDataType) should be part of the list of input types (Inputs)");
 
  104    assert(inputAsSlot != 
nullptr && inputAsReceiver != 
nullptr);
 
  110      for (
auto sender : sourceAsSender->senders()) {
 
  111        for (
auto receiver : inputAsReceiver->receivers()) {
 
  112          sender->addReceiver(receiver);
 
  113          receiver->addSender(sender);
 
  117      for (
auto slot : inputAsSlot->slots()) {
 
  118        for (
auto notifier : sourceAsNotifier->notifiers()) {
 
  119          slot->addNotifier(notifier);
 
  131      for (
auto notifier : sourceAsNotifier->notifiers()) {
 
  132        for (
auto inputSlot : notifier->connectedSlots()) {
 
  133          for (
auto slot : inputSlot->slots()) {
 
  134            this->
slots().insert(slot);
 
  135            slot->removeNotifier(notifier);
 
  139      (disconnectSourceFromReceiver<Inputs>(), ...);
 
  147  template<
class Input>
 
  163    (duplicateSourceEdge<Inputs>(rhs, mapping), ...);
 
  169  template<
class Input>
 
  172    for (
auto &sender : sourceAsSender->senders()) {
 
  173      for (
auto &inputReceiver : sender->connectedReceivers()) {
 
  174        for (
auto &receiver : inputReceiver->receivers()) {
 
  176          receiver->removeSender(sender);
 
  187  template<
class Input>
 
  194          if (!correspondenceMap.contains(receiverAsNode)) {
 
  195            auto duplicate = receiverAsClonable->clone(correspondenceMap);
 
  197            correspondenceMap.insert({receiverAsNode, duplicate});
 
  200          auto inputNode = correspondenceMap.at(receiverAsNode).get();
 
  205          assert(inputAsSlot != 
nullptr && inputAsReceiver != 
nullptr);
 
  207          for (
auto &inputSlot : inputAsSlot->slots()) {
 
  208            this->
slots().insert(inputSlot);
 
  211          for (
auto &inputReceiver : inputAsReceiver->receivers()) {
 
  216          throw std::runtime_error(
"An input node core is not a NodeAbstraction.");
 
constexpr bool isContainedIn_v
Helper testing if a type T is in variadic Ts.
Printer abstraction to get a snapshot of the metrics of the Hedgehog graph.
Core abstraction for clonable nodes, nodes duplicated by execution pipeline.
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.
std::set< ReceiverAbstraction * > const & receivers() const
Const accessor to receivers.
Core abstraction to send data.
Core's abstraction to receive a signal.
std::set< SlotAbstraction * > const & slots() const
Const accessor to slots.
std::shared_ptr< std::mutex > const & mutex() const
Protected accessor to mutex.
Base graph node abstraction.
Base core node abstraction.
Input management abstraction for the graph.
std::tuple< Inputs... > inputs_t
Accessor to the graph's inputs.
void duplicateSourceEdges(GraphInputsManagementAbstraction< Inputs... > const &rhs, std::map< abstraction::NodeAbstraction *, std::shared_ptr< NodeAbstraction > > &mapping)
Duplicate source edges.
bool wait()
Wait for the graph, should not be called a graph does not wait !
std::unique_ptr< GraphSource< Inputs... > > source_
Graph's source.
GraphInputsManagementAbstraction()
Default constructor.
~GraphInputsManagementAbstraction() override=default
Default destructor.
void wakeUp() override
Graph wake up, wakes up all registered slots of the input node.
void terminateSource()
Terminate a source, notify all input nodes to terminate.
void disconnectSource()
Disconnect the source when the graph is set as inside.
void duplicateSourceEdge(GraphInputsManagementAbstraction< Inputs... > const &rhs, std::map< abstraction::NodeAbstraction *, std::shared_ptr< NodeAbstraction > > &correspondenceMap)
Duplicate source edge for a type.
void addInputNodeToGraph(NodeAbstraction *const inputNode)
Add an input node to a graph.
std::unique_ptr< GraphSource< Inputs... > > const & source() const
Source accessor.
void printSource(Printer *printer)
Gather source information.
void sendInputDataToSource(std::shared_ptr< Input > data)
Send a data to the source.
void disconnectSourceFromReceiver()
Disconnect the source from the input node receivers.
Source of the graph, only used in an outer graph.