16#include <imgui_node_editor.h>
18#include <nlohmann/json.hpp>
19using json = nlohmann::json;
28#include <condition_variable>
63 constexpr Type() =
default;
110 explicit operator Value()
const {
return value; }
112 explicit operator bool() =
delete;
132 explicit operator std::string()
const
185 explicit Kind(
const std::string& kindString)
187 if (kindString ==
"Input")
191 else if (kindString ==
"Output")
198 explicit operator Value()
const {
return value; }
200 explicit operator bool() =
delete;
220 explicit operator std::string()
const
297 ax::NodeEditor::PinId
id;
333 static constexpr int m_PinIconSize = 24;
356 :
Pin(std::move(other)),
357 links(std::move(other.links)),
369 links = std::move(other.links);
373 Pin::operator=(std::move(other));
482 void connect(
InputPin& endPin, ax::NodeEditor::LinkId linkId = 0);
509 :
Pin(std::move(other)),
534 queue = std::move(other.queue);
535 Pin::operator=(std::move(other));
591 :
v(
v), outputPin(outputPin)
594 if (!dataChangeNotification)
598 dataChangeNotification =
false;
619 :
v(other.
v), outputPin(other.outputPin)
626 :
v(std::move(other.v)), outputPin(std::move(other.outputPin)) {}
633 outputPin = other.outputPin;
644 v = std::move(other.v);
645 outputPin = std::move(other.outputPin);
662 [[nodiscard]] std::optional<ValueWrapper<T>>
getValue()
const
668 auto outgoingLink = std::find_if(connectedPin->links.begin(), connectedPin->links.end(), [&](
const OutputPin::OutgoingLink&
link) {
669 return link.linkId == linkId;
673 if constexpr (std::is_same_v<T, bool>
674 || std::is_same_v<T, int>
675 || std::is_same_v<T, float>
676 || std::is_same_v<T, double>
677 || std::is_same_v<T, std::string>)
679 if (
const auto* pVal = std::get_if<const T*>(&(connectedPin->data));
682 return ValueWrapper<T>(*pVal, connectedPin, outgoingLink->dataChangeNotification);
687 if (
const auto* pVal = std::get_if<const void*>(&(connectedPin->data));
690 return ValueWrapper<T>(
static_cast<const T*
>(*pVal), connectedPin, outgoingLink->dataChangeNotification);
745 using FlowFirableWatcherCallbackFunc = std::function<void(
const Node*,
const NodeDataQueue&,
size_t)>;
749 using DataChangedWatcherNotifyFunc = std::function<void(
const Node*,
const InsTime&,
size_t)>;
752 using WatcherCallback = std::variant<FlowFirableWatcherCallbackFunc,
753 DataChangedWatcherNotifyFunc>;
756 std::vector<WatcherCallback> watcherCallbacks;
766 void connect(
OutputPin& startPin, ax::NodeEditor::LinkId linkId = 0);
nlohmann::json json
json namespace
Definition FlowManager.hpp:21
The class is responsible for all time-related tasks.
void from_json(const json &j, ImColor &color)
Converts the provided json object into a color.
void to_json(json &j, const ImColor &color)
Converts the provided color into a json object.
Utility class for logging to console and file.
The class is responsible for all time-related tasks.
Definition InsTime.hpp:667
Abstract parent class for all nodes.
Definition Node.hpp:86
Output pins of nodes.
Definition Pin.hpp:338
OutputPin(ax::NodeEditor::PinId id, const char *name, Type type, Node *parentNode)
Constructor.
Definition Pin.hpp:345
bool recreateLink(InputPin &endPin)
Destroys and recreates a link from this pin to another.
std::mutex dataAccessMutex
Mutex to interact with the data object and also the dataAccessCounter variable.
Definition Pin.hpp:461
bool createLink(InputPin &endPin, ax::NodeEditor::LinkId linkId=0)
Creates a link from this pin to another, calling all node specific callbacks.
void deleteLink(InputPin &endPin)
Disconnects the link.
void deleteLinks()
Disconnects all links.
OutputPin(const OutputPin &)=delete
Copy constructor.
std::shared_ptr< const NAV::NodeData >(Node::*)(size_t, bool) PeekPollDataFunc
FileReader/Simulator peekPollData function type for nodes with more than one polling pin.
Definition Pin.hpp:442
OutputPin & operator=(const OutputPin &)=delete
Copy assignment operator.
std::condition_variable dataAccessConditionVariable
Condition variable to signal that the data was read by connected nodes (used for non-flow pins)
Definition Pin.hpp:467
size_t dataAccessCounter
Counter for data accessing.
Definition Pin.hpp:464
std::variant< const void *, const bool *, const int *, const float *, const double *, const std::string *, PeekPollDataFunc, PollDataFunc > PinData
Possible Types represented by an output pin.
Definition Pin.hpp:448
OutputPin()=default
Default constructor (for serialization)
OutputPin & operator=(OutputPin &&other) noexcept
Move assignment operator.
Definition Pin.hpp:365
PinData data
Pointer to data (owned by this node) which is transferred over this pin.
Definition Pin.hpp:458
OutputPin(OutputPin &&other) noexcept
Move constructor.
Definition Pin.hpp:355
bool isPinLinked() const
Checks if the pin is linked.
std::vector< OutgoingLink > links
Info to identify the linked pins.
Definition Pin.hpp:433
bool isPinLinked(const InputPin &endPin) const
Checks if the pin is linked to the other pin.
std::shared_ptr< const NAV::NodeData >(Node::*)() PollDataFunc
FileReader/Simulator pollData function type for nodes with a single poll pin.
Definition Pin.hpp:445
std::atomic< bool > blocksConnectedNodeFromFinishing
Flag, whether connected nodes can finish with this pin not being finished yet (needed to make a loop ...
Definition Pin.hpp:473
std::atomic< bool > noMoreDataAvailable
Flag set, when no more data is available on this pin.
Definition Pin.hpp:470
bool canCreateLink(const InputPin &other) const
Checks if this pin can connect to the provided pin.
~OutputPin()=default
Destructor.
Pins in the GUI for information exchange.
Definition Pin.hpp:43
static bool canCreateLink(const OutputPin &startPin, const InputPin &endPin)
Checks if pins can connect.
Node * parentNode
Reference to the parent node.
Definition Pin.hpp:307
std::string name
Name of the Pin.
Definition Pin.hpp:299
void drawPinIcon(bool connected, int alpha) const
Draw the Pin Icon.
ax::NodeEditor::PinId id
Unique Id of the Pin.
Definition Pin.hpp:297
std::vector< std::string > dataIdentifier
One or multiple Data Identifiers (Unique name which is used for data flows)
Definition Pin.hpp:305
Type type
Type of the Pin.
Definition Pin.hpp:301
static bool createLink(OutputPin &startPin, InputPin &endPin, ax::NodeEditor::LinkId linkId=0)
Create a Link between the two given pins.
static void deleteLink(OutputPin &startPin, InputPin &endPin)
Disconnects the link.
Pin(ax::NodeEditor::PinId id, const char *name, Type type, Kind kind, Node *parentNode)
Constructor.
Definition Pin.hpp:272
static bool dataIdentifierHaveCommon(const std::vector< std::string > &a, const std::vector< std::string > &b)
Checks if the first list of data identifiers has a common entry with the second.
Kind kind
Kind of the Pin (Input/Output)
Definition Pin.hpp:303
ImColor getIconColor() const
Get the Icon Color object.
static bool recreateLink(OutputPin &startPin, InputPin &endPin)
Destroys and recreates a link from this pin to another.
Pin()=default
Default constructor.
bool operator==(const ImVec4 &lhs, const ImVec4 &rhs)
Equal comparison operator.
bool operator!=(const ImVec4 &lhs, const ImVec4 &rhs)
Unequal comparison operator.
Collection of information about the connected node and pin.
Definition Pin.hpp:412
InputPin * getConnectedPin() const
Returns a pointer to the pin which is connected to this one.
OutgoingLink()=default
Default Constructor.
bool dataChangeNotification
Flag to signal the connected node, that the data was changed.
Definition Pin.hpp:429
OutgoingLink(ax::NodeEditor::LinkId linkId, Node *connectedNode, ax::NodeEditor::PinId connectedPinId)
Constructor.
Definition Pin.hpp:420
Kind of the Pin (Input/Output)
Definition Pin.hpp:165
Kind & operator=(Value v)
Assignment operator from Value type.
Definition Pin.hpp:204
constexpr Kind(Value kind)
Implicit Constructor from Value type.
Definition Pin.hpp:179
Value
Kind of the Pin (Input/Output)
Definition Pin.hpp:168
@ Input
Input Pin.
Definition Pin.hpp:171
@ Output
Output Pin.
Definition Pin.hpp:170
@ None
None.
Definition Pin.hpp:169
friend constexpr bool operator!=(const Pin::Kind &lhs, const Pin::Kind &rhs)
Inequal compares Pin::Kind values.
Definition Pin.hpp:781
friend constexpr bool operator==(const Pin::Kind &lhs, const Pin::Kind &rhs)
Equal compares Pin::Kind values.
Definition Pin.hpp:776
Kind()=default
Default Constructor.
Kind(const std::string &kindString)
Constructor from std::string.
Definition Pin.hpp:185
Link between two pins.
Definition Pin.hpp:240
Link()=default
Default Constructor.
Link(ax::NodeEditor::LinkId linkId, Node *connectedNode, ax::NodeEditor::PinId connectedPinId)
Constructor.
Definition Pin.hpp:253
ax::NodeEditor::LinkId linkId
Unique id of the link.
Definition Pin.hpp:241
Node * connectedNode
Pointer to the node, which is connected to this pin.
Definition Pin.hpp:242
ax::NodeEditor::PinId connectedPinId
Id of the pin, which is connected to this pin.
Definition Pin.hpp:243
Type of the data on the Pin.
Definition Pin.hpp:47
Value
Type of the data on the Pin.
Definition Pin.hpp:50
@ Delegate
Reference to the Node object.
Definition Pin.hpp:59
@ None
Not initialized.
Definition Pin.hpp:51
@ Matrix
Matrix Object.
Definition Pin.hpp:58
@ Int
Integer Number.
Definition Pin.hpp:54
@ Float
Floating Point Number.
Definition Pin.hpp:55
@ String
std::string
Definition Pin.hpp:56
@ Flow
NodeData Trigger.
Definition Pin.hpp:52
@ Bool
Boolean.
Definition Pin.hpp:53
@ Object
Generic Object.
Definition Pin.hpp:57
constexpr Type(Value type)
Implicit Constructor from Value type.
Definition Pin.hpp:67
friend constexpr bool operator!=(const Pin::Type &lhs, const Pin::Type &rhs)
Inequal compares Pin::Type values.
Definition Pin.hpp:813
Type(const std::string &typeString)
Constructor from std::string.
Definition Pin.hpp:73
friend constexpr bool operator==(const Pin::Type &lhs, const Pin::Type &rhs)
Equal compares Pin::Type values.
Definition Pin.hpp:808
Type & operator=(Value v)
Assignment operator from Value type.
Definition Pin.hpp:116
constexpr Type()=default
Default Constructor.