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 "../indicator_component.hpp"
12#include "../result.hpp"
13
14#include <cstdint>
15#include <optional>
16#include <utility>
17#include <vector>
18
19namespace rerun::archetypes {
20 /// **Archetype**: A list of edges in a graph.
21 ///
22 /// By default, edges are undirected.
23 ///
24 /// ## Example
25 ///
26 /// ### Simple directed graph
27 /// ![image](https://static.rerun.io/graph_directed/ca29a37b65e1e0b6482251dce401982a0bc568fa/full.png)
28 ///
29 /// ```cpp
30 /// #include <rerun.hpp>
31 ///
32 /// int main() {
33 /// const auto rec = rerun::RecordingStream("rerun_example_graph_directed");
34 /// rec.spawn().exit_on_failure();
35 ///
36 /// rec.log(
37 /// "simple",
38 /// rerun::GraphNodes({"a", "b", "c"})
39 /// .with_positions({{0.0, 100.0}, {-100.0, 0.0}, {100.0, 0.0}})
40 /// .with_labels({"A", "B", "C"}),
41 /// rerun::GraphEdges({{"a", "b"}, {"b", "c"}, {"c", "a"}})
42 /// // Graphs are undirected by default.
43 /// .with_graph_type(rerun::components::GraphType::Directed)
44 /// );
45 /// }
46 /// ```
47 struct GraphEdges {
48 /// A list of node tuples.
49 std::optional<ComponentBatch> edges;
50
51 /// Specifies if the graph is directed or undirected.
52 ///
53 /// If no `components::GraphType` is provided, the graph is assumed to be undirected.
54 std::optional<ComponentBatch> graph_type;
55
56 public:
57 static constexpr const char IndicatorComponentName[] =
58 "rerun.components.GraphEdgesIndicator";
59
60 /// Indicator component, used to identify the archetype when converting to a list of components.
62 /// The name of the archetype as used in `ComponentDescriptor`s.
63 static constexpr const char ArchetypeName[] = "rerun.archetypes.GraphEdges";
64
65 /// `ComponentDescriptor` for the `edges` field.
66 static constexpr auto Descriptor_edges = ComponentDescriptor(
67 ArchetypeName, "edges",
69 );
70 /// `ComponentDescriptor` for the `graph_type` field.
72 ArchetypeName, "graph_type",
74 );
75
76 public:
77 GraphEdges() = default;
78 GraphEdges(GraphEdges&& other) = default;
79 GraphEdges(const GraphEdges& other) = default;
80 GraphEdges& operator=(const GraphEdges& other) = default;
81 GraphEdges& operator=(GraphEdges&& other) = default;
82
84 : edges(ComponentBatch::from_loggable(std::move(_edges), Descriptor_edges)
85 .value_or_throw()) {}
86
87 /// Update only some specific fields of a `GraphEdges`.
89 return GraphEdges();
90 }
91
92 /// Clear all the fields of a `GraphEdges`.
94
95 /// A list of node tuples.
97 edges = ComponentBatch::from_loggable(_edges, Descriptor_edges).value_or_throw();
98 return std::move(*this);
99 }
100
101 /// Specifies if the graph is directed or undirected.
102 ///
103 /// If no `components::GraphType` is provided, the graph is assumed to be undirected.
105 graph_type =
106 ComponentBatch::from_loggable(_graph_type, Descriptor_graph_type).value_or_throw();
107 return std::move(*this);
108 }
109
110 /// This method makes it possible to pack multiple `graph_type` in a single component batch.
111 ///
112 /// This only makes sense when used in conjunction with `columns`. `with_graph_type` should
113 /// be used when logging a single row's worth of data.
115 ) && {
116 graph_type =
117 ComponentBatch::from_loggable(_graph_type, Descriptor_graph_type).value_or_throw();
118 return std::move(*this);
119 }
120
121 /// Partitions the component data into multiple sub-batches.
122 ///
123 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
124 /// instead, via `ComponentBatch::partitioned`.
125 ///
126 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
127 ///
128 /// The specified `lengths` must sum to the total length of the component batch.
130
131 /// Partitions the component data into unit-length sub-batches.
132 ///
133 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
134 /// where `n` is automatically guessed.
136 };
137
138} // namespace rerun::archetypes
139
140namespace rerun {
141 /// \private
142 template <typename T>
143 struct AsComponents;
144
145 /// \private
146 template <>
147 struct AsComponents<archetypes::GraphEdges> {
148 /// Serialize all set component batches.
149 static Result<Collection<ComponentBatch>> as_batches(const archetypes::GraphEdges& archetype
150 );
151 };
152} // 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:25
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=rerun::Loggable< T >::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:14
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:47
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:114
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:54
std::optional< ComponentBatch > edges
A list of node tuples.
Definition graph_edges.hpp:49
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:88
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:71
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition graph_edges.hpp:63
GraphEdges with_graph_type(const rerun::components::GraphType &_graph_type) &&
Specifies if the graph is directed or undirected.
Definition graph_edges.hpp:104
GraphEdges with_edges(const Collection< rerun::components::GraphEdge > &_edges) &&
A list of node tuples.
Definition graph_edges.hpp:96
static constexpr auto Descriptor_edges
ComponentDescriptor for the edges field.
Definition graph_edges.hpp:66
Indicator component used by archetypes when converting them to component lists.
Definition indicator_component.hpp:32