Skip to main content

dsl Namespace

Definition

namespace simaai::neat::graph::dsl { ... }

Classes Index

structPortRef
structNodeRef

Operators Index

NodeRefoperator>> (const NodeRef &from, const NodeRef &to)
NodeRefoperator>> (const PortRef &from, const NodeRef &to)
NodeRefoperator>> (const NodeRef &from, const PortRef &to)
NodeRefoperator>> (const PortRef &from, const PortRef &to)

Functions Index

NodeRefref (Graph &g, NodeId id)
NodeRefadd (Graph &g, Graph::NodePtr node)
boolhas_port (const std::vector< PortDesc > &ports, const std::string &name)
voidensure_graph (const Graph *g, const char *what)
const std::shared_ptr< Node > &get_node (const Graph *g, NodeId id, const char *what)
voidconnect_ports (const PortRef &from, const PortRef &to)

Operators

operator>>()

NodeRef simaai::neat::graph::dsl::operator>> (const NodeRef & from, const NodeRef & to)
inline

Definition at line 138 of file GraphDsl.h.

138inline NodeRef operator>>(const NodeRef& from, const NodeRef& to) {
139 connect_ports(from.out(), to.in());
140 return to;
141}

operator>>()

NodeRef simaai::neat::graph::dsl::operator>> (const PortRef & from, const NodeRef & to)
inline

Definition at line 143 of file GraphDsl.h.

143inline NodeRef operator>>(const PortRef& from, const NodeRef& to) {
144 connect_ports(from, to.in());
145 return to;
146}

operator>>()

NodeRef simaai::neat::graph::dsl::operator>> (const NodeRef & from, const PortRef & to)
inline

Definition at line 148 of file GraphDsl.h.

148inline NodeRef operator>>(const NodeRef& from, const PortRef& to) {
149 connect_ports(from.out(), to);
150 return NodeRef{to.g, to.node};
151}

operator>>()

NodeRef simaai::neat::graph::dsl::operator>> (const PortRef & from, const PortRef & to)
inline

Definition at line 153 of file GraphDsl.h.

153inline NodeRef operator>>(const PortRef& from, const PortRef& to) {
154 connect_ports(from, to);
155 return NodeRef{to.g, to.node};
156}

Functions

add()

NodeRef simaai::neat::graph::dsl::add (Graph & g, Graph::NodePtr node)
inline

Definition at line 46 of file GraphDsl.h.

46inline NodeRef add(Graph& g, Graph::NodePtr node) {
47 return NodeRef{&g, g.add(std::move(node))};
48}

connect_ports()

void simaai::neat::graph::dsl::connect_ports (const PortRef & from, const PortRef & to)
inline

Definition at line 123 of file GraphDsl.h.

123inline void connect_ports(const PortRef& from, const PortRef& to) {
124 ensure_graph(from.g, "connect_ports(from)");
125 ensure_graph(to.g, "connect_ports(to)");
126 if (from.g != to.g) {
127 throw std::runtime_error("GraphDsl: cannot connect ports from different graphs");
128 }
129 if (!from.is_output) {
130 throw std::runtime_error("GraphDsl: left side is not an output port");
131 }
132 if (to.is_output) {
133 throw std::runtime_error("GraphDsl: right side is not an input port");
134 }
135 from.g->connect(from.node, to.node, from.g->port_name(from.port), to.g->port_name(to.port));
136}

ensure_graph()

void simaai::neat::graph::dsl::ensure_graph (const Graph * g, const char * what)
inline

Definition at line 58 of file GraphDsl.h.

58inline void ensure_graph(const Graph* g, const char* what) {
59 if (!g)
60 throw std::runtime_error(std::string("GraphDsl: null graph in ") + what);
61}

get_node()

const std::shared_ptr<Node>& simaai::neat::graph::dsl::get_node (const Graph * g, NodeId id, const char * what)
inline

Definition at line 63 of file GraphDsl.h.

63inline const std::shared_ptr<Node>& get_node(const Graph* g, NodeId id, const char* what) {
64 if (!g)
65 throw std::runtime_error(std::string("GraphDsl: null graph in ") + what);
66 return g->node(id);
67}

has_port()

bool simaai::neat::graph::dsl::has_port (const std::vector< PortDesc > & ports, const std::string & name)
inline

Definition at line 50 of file GraphDsl.h.

50inline bool has_port(const std::vector<PortDesc>& ports, const std::string& name) {
51 for (const auto& p : ports) {
52 if (p.name == name)
53 return true;
54 }
55 return false;
56}

ref()

NodeRef simaai::neat::graph::dsl::ref (Graph & g, NodeId id)
inline

Definition at line 42 of file GraphDsl.h.

42inline NodeRef ref(Graph& g, NodeId id) {
43 return NodeRef{&g, id};
44}

The documentation for this namespace was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.1.