Skip to main content

NodeRef Struct

Declaration

struct simaai::neat::graph::dsl::NodeRef { ... }

Included Headers

#include <GraphDsl.h>

Public Operators Index

operator NodeId () const
PortRefoperator[] (const std::string &name) const
PortRefoperator[] (const char *name) const

Public Member Functions Index

PortRefout () const
PortRefout (const std::string &name) const
PortRefin () const
PortRefin (const std::string &name) const

Public Member Attributes Index

Graph *g = nullptr
NodeIdid = kInvalidNode

Definition at line 24 of file GraphDsl.h.

Public Operators

operator NodeId()

simaai::neat::graph::dsl::NodeRef::operator NodeId ()
inline

Definition at line 28 of file GraphDsl.h.

28 operator NodeId() const {
29 return id;
30 }

operator[]()

PortRef simaai::neat::graph::dsl::NodeRef::operator[] (const std::string & name)
inline

Definition at line 36 of file GraphDsl.h.

105inline PortRef NodeRef::operator[](const std::string& name) const {
106 const auto& node = get_node(g, id, "operator[]");
107 const auto in_ports = node->input_ports();
108 const auto out_ports = node->output_ports();
109 const bool has_in = has_port(in_ports, name);
110 const bool has_out = has_port(out_ports, name);
111
112 if (has_out && !has_in)
113 return out(name);
114 if (has_in && !has_out)
115 return in(name);
116
117 if (!has_in && !has_out) {
118 throw std::runtime_error("GraphDsl: unknown port: " + name);
119 }
120 throw std::runtime_error("GraphDsl: ambiguous port name (use .in or .out): " + name);
121}

operator[]()

PortRef simaai::neat::graph::dsl::NodeRef::operator[] (const char * name)
inline

Definition at line 37 of file GraphDsl.h.

37 PortRef operator[](const char* name) const {
38 return (*this)[std::string(name)];
39 }

Public Member Functions

in()

PortRef simaai::neat::graph::dsl::NodeRef::in ()
inline

Definition at line 34 of file GraphDsl.h.

87inline PortRef NodeRef::in() const {
88 const auto& node = get_node(g, id, "in()");
89 const auto ports = node->input_ports();
90 if (ports.size() != 1) {
91 throw std::runtime_error("GraphDsl: in() requires exactly one input port");
92 }
93 return in(ports.front().name);
94}

in()

PortRef simaai::neat::graph::dsl::NodeRef::in (const std::string & name)
inline

Definition at line 35 of file GraphDsl.h.

96inline PortRef NodeRef::in(const std::string& name) const {
97 const auto& node = get_node(g, id, "in(name)");
98 const auto ports = node->input_ports();
99 if (!has_port(ports, name)) {
100 throw std::runtime_error("GraphDsl: unknown input port: " + name);
101 }
102 return PortRef{g, id, g->intern_port(name), false};
103}

out()

PortRef simaai::neat::graph::dsl::NodeRef::out ()
inline

Definition at line 32 of file GraphDsl.h.

69inline PortRef NodeRef::out() const {
70 const auto& node = get_node(g, id, "out()");
71 const auto ports = node->output_ports();
72 if (ports.size() != 1) {
73 throw std::runtime_error("GraphDsl: out() requires exactly one output port");
74 }
75 return out(ports.front().name);
76}

out()

PortRef simaai::neat::graph::dsl::NodeRef::out (const std::string & name)
inline

Definition at line 33 of file GraphDsl.h.

78inline PortRef NodeRef::out(const std::string& name) const {
79 const auto& node = get_node(g, id, "out(name)");
80 const auto ports = node->output_ports();
81 if (!has_port(ports, name)) {
82 throw std::runtime_error("GraphDsl: unknown output port: " + name);
83 }
84 return PortRef{g, id, g->intern_port(name), true};
85}

Public Member Attributes

g

Graph* simaai::neat::graph::dsl::NodeRef::g = nullptr

Definition at line 25 of file GraphDsl.h.

25 Graph* g = nullptr;

id

NodeId simaai::neat::graph::dsl::NodeRef::id = kInvalidNode

Definition at line 26 of file GraphDsl.h.

26 NodeId id = kInvalidNode;

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.1.