Rerun C++ SDK
Loading...
Searching...
No Matches
graph_edges.hpp
1// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs
2// Based on "crates/store/re_types/definitions/rerun/archetypes/graph_edges.fbs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../component_batch.hpp"
8#include "../component_column.hpp"
9#include "../components/graph_edge.hpp"
10#include "../components/graph_type.hpp"
11#include "../result.hpp"
12
13#include <cstdint>
14#include <optional>
15#include <utility>
16#include <vector>
17
18namespace rerun::archetypes {
19 /// **Archetype**: A list of edges in a graph.
20 ///
21 /// By default, edges are undirected.
22 ///
23 /// ## Example
24 ///
25 /// ### Simple directed graph
26 /// ![image](https://static.rerun.io/graph_directed/ca29a37b65e1e0b6482251dce401982a0bc568fa/full.png)
27 ///
28 /// ```cpp
29 /// #include <rerun.hpp>
30 ///
31 /// int main() {
32 /// const auto rec = rerun::RecordingStream("rerun_example_graph_directed");
33 /// rec.spawn().exit_on_failure();
34 ///
35 /// rec.log(
36 /// "simple",
37 /// rerun::GraphNodes({"a", "b", "c"})
38 /// .with_positions({{0.0, 100.0}, {-100.0, 0.0}, {100.0, 0.0}})
39 /// .with_labels({"A", "B", "C"}),
40 /// rerun::GraphEdges({{"a", "b"}, {"b", "c"}, {"c", "a"}})
41 /// // Graphs are undirected by default.
42 /// .with_graph_type(rerun::components::GraphType::Directed)
43 /// );
44 /// }
45 /// ```
46 struct GraphEdges {
47 /// A list of node tuples.
48 std::optional<ComponentBatch> edges;
49
50 /// Specifies if the graph is directed or undirected.
51 ///
52 /// If no `components::GraphType` is provided, the graph is assumed to be undirected.
53 std::optional<ComponentBatch> graph_type;
54
55 public:
56 /// The name of the archetype as used in `ComponentDescriptor`s.
57 static constexpr const char ArchetypeName[] = "rerun.archetypes.GraphEdges";
58
59 /// `ComponentDescriptor` for the `edges` field.
60 static constexpr auto Descriptor_edges = ComponentDescriptor(
62 );
63 /// `ComponentDescriptor` for the `graph_type` field.
65 ArchetypeName, "GraphEdges:graph_type",
67 );
68
69 public:
70 GraphEdges() = default;
71 GraphEdges(GraphEdges&& other) = default;
72 GraphEdges(const GraphEdges& other) = default;
73 GraphEdges& operator=(const GraphEdges& other) = default;
74 GraphEdges& operator=(GraphEdges&& other) = default;
75
77 : edges(ComponentBatch::from_loggable(std::move(_edges), Descriptor_edges)
78 .value_or_throw()) {}
79
80 /// Update only some specific fields of a `GraphEdges`.
82 return GraphEdges();
83 }
84
85 /// Clear all the fields of a `GraphEdges`.
87
88 /// A list of node tuples.
90 edges = ComponentBatch::from_loggable(_edges, Descriptor_edges).value_or_throw();
91 return std::move(*this);
92 }
93
94 /// Specifies if the graph is directed or undirected.
95 ///
96 /// If no `components::GraphType` is provided, the graph is assumed to be undirected.
99 ComponentBatch::from_loggable(_graph_type, Descriptor_graph_type).value_or_throw();
100 return std::move(*this);
101 }
102
103 /// This method makes it possible to pack multiple `graph_type` in a single component batch.
104 ///
105 /// This only makes sense when used in conjunction with `columns`. `with_graph_type` should
106 /// be used when logging a single row's worth of data.
108 ) && {
109 graph_type =
110 ComponentBatch::from_loggable(_graph_type, Descriptor_graph_type).value_or_throw();
111 return std::move(*this);
112 }
113
114 /// Partitions the component data into multiple sub-batches.
115 ///
116 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
117 /// instead, via `ComponentBatch::partitioned`.
118 ///
119 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
120 ///
121 /// The specified `lengths` must sum to the total length of the component batch.
123
124 /// Partitions the component data into unit-length sub-batches.
125 ///
126 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
127 /// where `n` is automatically guessed.
129 };
130
131} // namespace rerun::archetypes
132
133namespace rerun {
134 /// \private
135 template <typename T>
136 struct AsComponents;
137
138 /// \private
139 template <>
140 struct AsComponents<archetypes::GraphEdges> {
141 /// Serialize all set component batches.
142 static Result<Collection<ComponentBatch>> as_batches(const archetypes::GraphEdges& archetype
143 );
144 };
145} // namespace rerun
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:49
A class for representing either a usable value, or an error.
Definition result.hpp:14
All built-in archetypes. See Types in the Rerun manual.
Definition rerun.hpp:76
GraphType
Component: Specifies if a graph has directed or undirected edges.
Definition graph_type.hpp:24
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
Arrow-encoded data of a single batch of components together with a component descriptor.
Definition component_batch.hpp:28
static Result< ComponentBatch > from_loggable(const rerun::Collection< T > &components, const ComponentDescriptor &descriptor)
Creates a new component batch from a collection of component instances.
Definition component_batch.hpp:46
A ComponentDescriptor fully describes the semantics of a column of data.
Definition component_descriptor.hpp:16
The Loggable trait is used by all built-in implementation of rerun::AsComponents to serialize a colle...
Definition loggable.hpp:11
Archetype: A list of edges in a graph.
Definition graph_edges.hpp:46
GraphEdges with_many_graph_type(const Collection< rerun::components::GraphType > &_graph_type) &&
This method makes it possible to pack multiple graph_type in a single component batch.
Definition graph_edges.hpp:107
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
std::optional< ComponentBatch > graph_type
Specifies if the graph is directed or undirected.
Definition graph_edges.hpp:53
std::optional< ComponentBatch > edges
A list of node tuples.
Definition graph_edges.hpp:48
static GraphEdges clear_fields()
Clear all the fields of a GraphEdges.
static GraphEdges update_fields()
Update only some specific fields of a GraphEdges.
Definition graph_edges.hpp:81
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
static constexpr auto Descriptor_graph_type
ComponentDescriptor for the graph_type field.
Definition graph_edges.hpp:64
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition graph_edges.hpp:57
GraphEdges with_graph_type(const rerun::components::GraphType &_graph_type) &&
Specifies if the graph is directed or undirected.
Definition graph_edges.hpp:97
GraphEdges with_edges(const Collection< rerun::components::GraphEdge > &_edges) &&
A list of node tuples.
Definition graph_edges.hpp:89
static constexpr auto Descriptor_edges
ComponentDescriptor for the edges field.
Definition graph_edges.hpp:60