Program Listing for File io.cc#
↰ Return to documentation for file (src/io.cc)
#include "nodes-graph/io.h"
#include "nodes-graph/node.h"
#include "nodes-graph/graph.h"
namespace ng::io {
std::ostream& operator<<(std::ostream& os, const qualifier_t& q) {
return os << as_string(q);
}
std::ostream& operator<<(std::ostream& os, const node_id_t& id) {
return os << "[" << id.data() << "]";
}
std::ostream& operator<<(std::ostream& os, const socket_id_t& id) {
return os << "[" << id.data() << "]";
}
std::ostream& operator<<(std::ostream& os, const socket_uuid_t& suuid) {
return os << suuid.first << "." << suuid.second;
}
std::ostream& operator<<(std::ostream& os, const link_t& link) {
return os << "<(" << link.second << ") -> (" << link.first << ")>";
}
std::ostream& operator<<(std::ostream& os, Status status) {
return os << as_string(status);
}
std::ostream& operator<<(std::ostream& os, const Node& node) {
os << "[\n"
<< " name=" << node.get_name() << "\n"
<< " id=" << node.get_id() << "\n"
<< " type=" << node.get_qualifier() << "\n";
if (node.is_proxy()) {
os << " proxy\n";
}
for (const socket_id_t& input_id : node.get_input_sockets()) {
os << " input=" << input_id << "\n";
}
for (const socket_id_t& output_id : node.get_output_sockets()) {
os << " output=" << output_id << "\n";
}
return os << "]\n";
}
std::ostream& operator<<(std::ostream& os, const Graph& graph) {
os << "===================================================================\n";
os << "Name: " << graph.get_name() << "\n";
if (graph.get_qualifier().has_value()) {
os << "Qualifier: " << graph.get_qualifier().value() << "\n";
}
os << "\n";
os << "----------------------- Nodes -----------------------\n";
for (const auto& [node_id, node] : graph.get_nodes()) {
os << "node: " << node_id << " > " << node << "\n";
}
os << "----------------------- Input Sockets -----------------------\n";
for (const auto& [suuid, socket] : graph.get_input_sockets()) {
os << "input: " << suuid << " = \"" << socket.get_value() << "\"\n";
}
os << "\n";
os << "----------------------- Output Sockets -----------------------\n";
for (const auto& [suuid, _] : graph.get_output_sockets()) {
os << "output: " << suuid << "\n";
}
os << "\n";
os << "----------------------- Links -----------------------\n";
for (const link_t& link : graph.get_links()) {
os << "link: " << link << "\n";
}
os << "----------------------- Interface -----------------------\n";
for (const auto& [suuid, ppts] : graph.get_parameters()) {
os << "parameter: " << suuid << " as " << ppts.socket_id << " \"" << ppts.show_as << "\"\n";
}
for (const auto& [suuid, ppts] : graph.get_results()) {
os << "result: " << suuid << " as " << ppts.socket_id << " \"" << ppts.show_as << "\"\n";
}
return os;
}
} // namespace ng::io