Class Graph#
Defined in File graph.h
Nested Relationships#
Nested Types#
Class Documentation#
-
class Graph#
Public Types
-
using input_sockets_t = std::map<socket_uuid_t, InputSocket>#
-
using output_sockets_t = std::map<socket_uuid_t, OutputSocket>#
-
using interface_t = std::map<socket_uuid_t, InterfaceProperties>#
Public Functions
-
Graph(std::string name = "", nodes_t nodes = {}, links_t links = {}, input_sockets_t input_sockets = {}, output_sockets_t output_sockets = {}, interface_t parameters = {}, interface_t results = {})#
-
inline void set_name(const std::string &name)#
-
inline void set_qualifier(const qualifier_t &q)#
-
inline const std::string &get_name() const#
-
inline const std::optional<qualifier_t> &get_qualifier() const#
-
inline const input_sockets_t &get_input_sockets() const#
-
inline const output_sockets_t &get_output_sockets() const#
-
inline const interface_t &get_parameters() const#
-
inline const interface_t &get_results() const#
-
node_id_t add_node(const qualifier_t &node_qualifier)#
- Returns:
The ID of the new node, or null_node if the node type is not registered.
-
bool remove_node(const node_id_t &node_id)#
Removes the node, its links, its sockets and their exposure in the interface.
- Returns:
false if the node doesn’t exist.
-
void disconnect_node(const node_id_t &node_id, LinkBreakReason reason = LinkBreakReason::Manual)#
Breaks all the links going to or coming from the node.
-
void rename_node(const node_id_t &node_id, const std::string &name)#
- Throws:
std::out_of_range – if the node doesn’t exist.
-
const InputSocket &get_input_socket(const socket_uuid_t &suuid) const#
- Throws:
std::out_of_range – if the socket doesn’t exist.
-
const OutputSocket &get_output_socket(const socket_uuid_t &suuid) const#
-
Status set_socket_value(const socket_uuid_t &suuid, const std::string &value)#
Sets the value of an input socket, after checking the validators and the allowed values. The callbacks of the socket are triggered only if the value is accepted.
-
const std::string &get_socket_value(const socket_uuid_t &suuid) const#
- Throws:
std::out_of_range – if the input socket doesn’t exist.
-
Status add_link(const socket_uuid_t &from, const socket_uuid_t &to)#
Links an output socket to an input socket. If the input socket is already linked, the previous link is replaced. If the input socket is exposed as a parameter, it stops being exposed. Adding a link that already exists is a no-op returning Status::Ok.
-
links_t::const_iterator find_link_by_input_socket(const socket_uuid_t &target) const#
- Returns:
An iterator to the link targeting this input socket, or get_links().end().
-
inline bool is_linked(const socket_uuid_t &input) const#
-
links_t get_input_links(const node_id_t &node_id) const#
- Returns:
All the links whose destination is a socket of this node.
-
links_t get_output_links(const node_id_t &node_id) const#
- Returns:
All the links whose source is a socket of this node.
-
Status expose_parameter(const socket_uuid_t &suuid, const socket_id_t &alias, std::string show_as = "")#
Exposes an input socket as a parameter of the graph, so it becomes an input of the proxy nodes. Any link targeting this socket is broken.
- Parameters:
suuid – The socket to expose.
alias – The ID of the socket on the proxy nodes, must be unique among parameters.
show_as – The name of the socket on the proxy nodes. Defaults to the socket’s name.
-
bool remove_parameter(const socket_uuid_t &suuid)#
-
Status expose_result(const socket_uuid_t &suuid, const socket_id_t &alias, std::string show_as = "")#
Same as expose_parameter, for output sockets.
-
bool remove_result(const socket_uuid_t &suuid)#
-
node_id_t add_proxy_node(const qualifier_t &graph_qualifier)#
Adds a node representing another graph, loaded from the disk through the GraphManager. Its inputs are the parameters of that graph and its outputs are its results.
- Throws:
std::runtime_error – if the graph can’t be found.
- Returns:
The ID of the new node, or null_node if the graph tries to contain itself.
-
std::set<node_id_t> get_source_nodes() const#
- Returns:
The nodes that are not the destination of any link.
-
DepthProperties get_depth_properties() const#
-
DepthProperties get_depth_properties(const links_t &links) const#
-
struct DepthProperties#
Public Members
-
SmallMap<node_id_t, std::size_t> depth#
Length of the longest path from a source node to each node. Only meaningful for nodes that are not in (or downstream of) a cycle.
-
std::size_t max_depth = 0#
Largest value in depth.
-
bool has_cycle = false#
Whether the links form at least one cycle.
-
SmallMap<node_id_t, std::size_t> depth#
-
struct InterfaceProperties#
How a socket is exposed in the interface (parameters or results) of a graph.
Public Members
-
std::string show_as#
Name displayed for the socket of the proxy node.
-
socket_id_t socket_id#
ID of the socket of the proxy node.
-
std::string show_as#
-
using input_sockets_t = std::map<socket_uuid_t, InputSocket>#