21#ifndef HEDGEHOG_SENDER_ABSTRACTION_H 
   22#define HEDGEHOG_SENDER_ABSTRACTION_H 
   28#include "../../../implementors/implementor/implementor_notifier.h" 
   29#include "../../../implementors/implementor/implementor_sender.h" 
   30#include "../clonable_abstraction.h" 
   38namespace abstraction {
 
   40#ifndef DOXYGEN_SHOULD_SKIP_THIS 
   42class ReceiverAbstraction;
 
   50  std::shared_ptr<implementor::ImplementorSender<Output>>
 
  106    std::shared_ptr<NodeAbstraction> duplicateReceiver;
 
  108    if (!mapping.contains(senderAsNode)) {
 
  109      throw std::runtime_error(
"A node that we are trying to connect is not mapped yet.");
 
  111    auto mappedSender = std::dynamic_pointer_cast<SenderAbstraction < Output>>
 
  112    (mapping.at(senderAsNode));
 
  113    if (mappedSender == 
nullptr) {
 
  114      std::ostringstream oss;
 
  115      oss << 
"The mapped type of a node is not of the right type: Sender<" << hh::tool::typeToStr<Output>() << 
">.";
 
  116      throw std::runtime_error(oss.str());
 
  119    for (
auto &sender : this->
senders()) {
 
  120      for (
auto &receiver : sender->connectedReceivers()) {
 
  121        for (
auto &r : receiver->receivers()) {
 
  123            if (mapping.contains(receiverAsNode)) {
 
  124              auto mappedReceiver = std::dynamic_pointer_cast<ReceiverAbstraction<Output>>(mapping.at(receiverAsNode));
 
  126              if (mappedReceiver == 
nullptr) {
 
  127                std::ostringstream oss;
 
  129                    << 
"The mapped type of a node is not of the right type: ReceiverAbstraction<" 
  130                    << hh::tool::typeToStr<Output>() << 
">.";
 
  131                throw std::runtime_error(oss.str());
 
  134              mappedSender->addReceiver(mappedReceiver.get());
 
  135              mappedReceiver->addSender(mappedSender.get());
 
  138            throw std::runtime_error(
"A receiver is not a node when duplicating edges.");
 
Core's abstraction to receive a piece of data.
Core abstraction to send data.
SenderAbstraction(std::shared_ptr< implementor::ImplementorSender< Output > > concreteSender)
Constructor using the concrete implementation.
std::set< SenderAbstraction< Output > * > const & senders() const
Const accessor to senders.
void duplicateEdgeSender(std::map< abstraction::NodeAbstraction *, std::shared_ptr< NodeAbstraction > > &mapping)
Duplicate edges of the current sender to receiver to clone in map.
void copyInnerStructure(SenderAbstraction< Output > *copyableCore)
Copy inner structure of the sender to this one.
void removeReceiver(ReceiverAbstraction< Output > *const receiver)
Remove a ReceiverAbstraction.
void addReceiver(ReceiverAbstraction< Output > *const receiver)
Add a ReceiverAbstraction.
std::set< ReceiverAbstraction< Output > * > const & connectedReceivers() const
Accessor to the receivers attached to this SenderAbstraction.
std::set< SenderAbstraction< Output > * > & senders()
Accessor to senders.
virtual ~SenderAbstraction()=default
Default destructor.
void send(std::shared_ptr< Output > data)
Send a data as output of the node.
std::shared_ptr< implementor::ImplementorSender< Output > > concreteSender_
Concrete implementation of the sender used in the node.
Base core node abstraction.
Implementor for the SenderAbstraction.