46template <
typename T,
typename... Args>
169 template <
typename OutputValType,
typename... OutputArgs>
225 template <
class Obj,
class ObjMemberFn>
226 explicit InputPort(Obj* obj, ObjMemberFn&& fn);
251 void post(T v,
bool immediate =
false);
293template <
typename T,
typename... Args>
330 template <
class Obj,
class ObjMemberFn>
331 explicit OutputPort(Obj* obj, ObjMemberFn&& fn, Args&&... args);
407#include "smgl/PortsImpl.hpp"
void setArgs(Args &&... args)
Set the arguments passed to a function source.
std::unordered_map< Uuid, TypedConnection > connections_
T run_(std::tuple< Args... > &tup, std::index_sequence< Is... >)
bool update() override
Update all active connections with the value of the source.
T operator()()
Get the current value of source.
OutputPort(const OutputPort &)=delete
Metadata serialize() override
Get port metadata.
OutputPort & operator=(const OutputPort &)=delete
std::size_t numConnections() const override
Get the number of active connections.
OutputPort & operator=(const OutputPort &&)=delete
OutputPort(const OutputPort &&)=delete
std::vector< Connection > getConnections() const override
Get a list of active connections.
void deserialize(const Metadata &m) override
Load port metadata.
std::function< T(Args...)> source_
T val()
Get the current value of source.
void notify(State s) override
Notify all active connections of this port's state.
Generic output port interface.
friend void connect(Output &op, Input &ip)
Connect an output port to an input port.
~Output() override=default
virtual void connect(Input *ip)=0
virtual std::vector< Connection > getConnections() const =0
virtual std::size_t numConnections() const =0
virtual void disconnect(Input *ip)=0
friend void disconnect(Output &op, Input &ip)
Disconnect an output port and input port.
virtual void deserialize(const Metadata &m)=0
virtual void notify(State s)=0
virtual Metadata serialize()=0
Base class for objects which are uniquely identifiable.
Project top-level namespace.
void operator<<(Input &ip, Output &op)
Connect an output port to an input port.
void disconnect(Output &op, Input &ip)
Disconnect an output port and input port.
void connect(Output &op, Input &ip)
Connect an output port to an input port.
nlohmann::ordered_json Metadata
Metadata storage class.
@ Error
Error messages and above.
void operator>>(Output &op, Input &ip)
Connect an output port to an input port.
ISO C++ top-level namespace.
Describes untyped connections from an output port.
Connection(Node *s, Output *sp, Node *d, Input *dp)
Describes typed connections from an output port.
Typed update sent over connections.
Exception thrown for port connection failures.
bad_connection(const char *msg)
bad_connection(std::string msg)
const char * what() const noexcept override