19#ifndef HEDGEHOG_NOTIFIER_ABSTRACTION_H
20#define HEDGEHOG_NOTIFIER_ABSTRACTION_H
27#include "../../../implementors/implementor/implementor_notifier.h"
28#include "../clonable_abstraction.h"
35#ifndef DOXYGEN_SHOULD_SKIP_THIS
37namespace implementor {
39class ImplementorNotifier;
44namespace abstraction {
49 std::shared_ptr<implementor::ImplementorNotifier>
101 std::shared_ptr<NodeAbstraction> duplicateSlot;
103 if (!mapping.contains(notifierAsNode)) {
104 throw std::runtime_error(
"A node that we are trying to connect is not mapped yet.");
106 auto mappedNotifier = std::dynamic_pointer_cast<abstraction::NotifierAbstraction>(mapping.at(notifierAsNode));
107 if (mappedNotifier ==
nullptr) {
108 throw std::runtime_error(
"The mapped type of a node is not of the right type: abstraction::NodeAbstraction.");
111 for (
auto ¬ifier : this->
notifiers()) {
112 for (
auto &slot : notifier->connectedSlots()) {
113 for (
auto &s : slot->slots()) {
115 if (mapping.contains(slotAsNode)) {
116 auto mappedSlot = std::dynamic_pointer_cast<abstraction::SlotAbstraction>(mapping.at(slotAsNode));
117 if (mappedSlot ==
nullptr) {
118 throw std::runtime_error(
"The mapped type of a node is not of the right type: SlotAbstraction.");
121 for(
auto mmapedS : mappedSlot->slots()) {
122 for (
auto mmapedN : mappedNotifier->notifiers()) {
123 mmapedN->addSlot(mmapedS);
124 mmapedS->addNotifier(mmapedN);
130 throw std::runtime_error(
"A slot is not a node when duplicating edges.");
Core abstraction to notify slots.
void notifyAllTerminated()
Notifier all slots that this node is terminated.
void addSlot(SlotAbstraction *const slot)
Add a SlotAbstraction to this notifier.
std::shared_ptr< implementor::ImplementorNotifier > concreteNotifier_
Concrete implementation of the notifier used in the node.
std::set< NotifierAbstraction * > & notifiers()
Accessor to notifiers.
void removeSlot(SlotAbstraction *const slot)
Remove SlotAbstraction from this notifier.
virtual ~NotifierAbstraction()=default
Default destructor.
void duplicateEdgeNotifier(std::map< abstraction::NodeAbstraction *, std::shared_ptr< NodeAbstraction > > &mapping)
Duplicate edges of the current notifier to slots to clone in map.
void notify()
Notify a slot to wake up.
NotifierAbstraction(std::shared_ptr< implementor::ImplementorNotifier > notifier)
Constructor utilising a concrete implementation.
std::set< NotifierAbstraction * > const & notifiers() const
Const accessor to notifiers.
std::set< SlotAbstraction * > const & connectedSlots() const
Accessor to the slots attached to this notifier.
Core's abstraction to receive a signal.
Base core node abstraction.