Skip to content

Commit 74dd688

Browse files
committed
finishing touches
1 parent 6465aeb commit 74dd688

File tree

6 files changed

+83
-29
lines changed

6 files changed

+83
-29
lines changed

crates/store/re_chunk/src/chunk.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ impl Chunk {
285285
timelines == rhs_timelines
286286
}
287287
// TODO(cmc): we cannot compare tags yet, need to support Python & C++ first
288-
&& *components == rhs.components // TODO
288+
// && *components == rhs.components
289289
&& {
290290
let lhs_components_no_tags: ChunkComponents = components
291291
.clone()

docs/snippets/all/descriptors/descr_custom_archetype.cpp

+6-12
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,17 @@ struct rerun::AsComponents<CustomPoints3D> {
4141
CustomPoints3D::IndicatorComponent indicator;
4242
batches.push_back(ComponentBatch::from_loggable(indicator).value_or_throw());
4343

44-
// TODO: with_methods would be nice
45-
auto positions_descr = rerun::ComponentDescriptor(
46-
"user.CustomArchetype",
47-
"positions",
48-
Loggable<CustomPosition3D>::Descriptor.component_name
49-
);
44+
auto positions_descr = rerun::Loggable<CustomPosition3D>::Descriptor
45+
.or_with_archetype_name("user.CustomArchetype")
46+
.or_with_archetype_field_name("positions");
5047
batches.push_back(
5148
ComponentBatch::from_loggable(archetype.positions, positions_descr).value_or_throw()
5249
);
5350

5451
if (archetype.colors) {
55-
// TODO: with_methods would be nice
56-
auto colors_descr = rerun::ComponentDescriptor(
57-
"user.CustomArchetype",
58-
"colors",
59-
Loggable<rerun::Color>::Descriptor.component_name
60-
);
52+
auto colors_descr = rerun::Loggable<rerun::Color>::Descriptor
53+
.or_with_archetype_name("user.CustomArchetype")
54+
.or_with_archetype_field_name("colors");
6155
batches.push_back(
6256
ComponentBatch::from_loggable(archetype.colors, colors_descr).value_or_throw()
6357
);

docs/snippets/all/tutorials/custom_data.cpp

+3-6
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,9 @@ struct rerun::AsComponents<CustomPoints3D> {
4949

5050
// Add custom confidence components if present.
5151
if (archetype.confidences) {
52-
// TODO: with_methods would be nice
53-
auto descriptor = rerun::ComponentDescriptor(
54-
"user.CustomPoints3D",
55-
"confidences",
56-
rerun::Loggable<Confidence>::Descriptor.component_name
57-
);
52+
auto descriptor = rerun::Loggable<Confidence>::Descriptor
53+
.or_with_archetype_name("user.CustomPoints3D")
54+
.or_with_archetype_field_name("confidences");
5855
batches.push_back(
5956
ComponentBatch::from_loggable(*archetype.confidences, descriptor).value_or_throw()
6057
);

rerun_cpp/src/rerun/as_components.hpp

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
#include "indicator_component.hpp"
66
#include "loggable.hpp"
77

8-
// TODO: do we need to care about this one? im kinda lost at this point...
9-
108
namespace rerun {
119
/// The AsComponents trait is used to convert a type into a list of serialized component.
1210
///

rerun_cpp/src/rerun/component_descriptor.hpp

+73-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
#include <optional>
44
#include <string_view>
55

6-
// TODO: to_string maybe?
7-
86
namespace rerun {
97
/// A `ComponentDescriptor` fully describes the semantics of a column of data.
108
///
@@ -32,8 +30,6 @@ namespace rerun {
3230
/// Example: `rerun.components.Position3D`.
3331
std::string_view component_name;
3432

35-
// TODO: {entity_path}@{archetype_name}:{component_name}#{archetype_field_name}
36-
3733
constexpr ComponentDescriptor(
3834
std::optional<std::string_view> archetype_name_,
3935
std::optional<std::string_view> archetype_field_name_, std::string_view component_name_
@@ -56,6 +52,78 @@ namespace rerun {
5652
constexpr ComponentDescriptor(const char* component_name_)
5753
: component_name(component_name_) {}
5854

59-
// TODO: override helpers?
55+
/// Unconditionally sets `archetype_name` to the given one.
56+
ComponentDescriptor with_archetype_name(std::optional<std::string_view> archetype_name_
57+
) const {
58+
ComponentDescriptor descriptor = *this;
59+
descriptor.archetype_name = archetype_name_;
60+
return descriptor;
61+
}
62+
63+
/// Unconditionally sets `archetype_name` to the given one.
64+
ComponentDescriptor with_archetype_name(const char* archetype_name_) const {
65+
ComponentDescriptor descriptor = *this;
66+
descriptor.archetype_name = archetype_name_;
67+
return descriptor;
68+
}
69+
70+
/// Unconditionally sets `archetype_field_name` to the given one.
71+
ComponentDescriptor with_archetype_field_name(
72+
std::optional<std::string_view> archetype_field_name_
73+
) const {
74+
ComponentDescriptor descriptor = *this;
75+
descriptor.archetype_field_name = archetype_field_name_;
76+
return descriptor;
77+
}
78+
79+
/// Unconditionally sets `archetype_field_name` to the given one.
80+
ComponentDescriptor with_archetype_field_name(const char* archetype_field_name_) const {
81+
ComponentDescriptor descriptor = *this;
82+
descriptor.archetype_field_name = archetype_field_name_;
83+
return descriptor;
84+
}
85+
86+
/// Sets `archetype_name` to the given one iff it's not already set.
87+
ComponentDescriptor or_with_archetype_name(std::optional<std::string_view> archetype_name_
88+
) const {
89+
if (this->archetype_field_name.has_value()) {
90+
return *this;
91+
}
92+
ComponentDescriptor descriptor = *this;
93+
descriptor.archetype_name = archetype_name_;
94+
return descriptor;
95+
}
96+
97+
/// Sets `archetype_name` to the given one iff it's not already set.
98+
ComponentDescriptor or_with_archetype_name(const char* archetype_name_) const {
99+
if (this->archetype_field_name.has_value()) {
100+
return *this;
101+
}
102+
ComponentDescriptor descriptor = *this;
103+
descriptor.archetype_name = archetype_name_;
104+
return descriptor;
105+
}
106+
107+
/// Sets `archetype_field_name` to the given one iff it's not already set.
108+
ComponentDescriptor or_with_archetype_field_name(
109+
std::optional<std::string_view> archetype_field_name_
110+
) const {
111+
if (this->archetype_field_name.has_value()) {
112+
return *this;
113+
}
114+
ComponentDescriptor descriptor = *this;
115+
descriptor.archetype_field_name = archetype_field_name_;
116+
return descriptor;
117+
}
118+
119+
/// Sets `archetype_field_name` to the given one iff it's not already set.
120+
ComponentDescriptor or_with_archetype_field_name(const char* archetype_field_name_) const {
121+
if (this->archetype_field_name.has_value()) {
122+
return *this;
123+
}
124+
ComponentDescriptor descriptor = *this;
125+
descriptor.archetype_field_name = archetype_field_name_;
126+
return descriptor;
127+
}
60128
};
61129
} // namespace rerun

rerun_cpp/tests/component_type.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77

88
#define TEST_TAG "[component_type]"
99

10-
// TODO: should we keep these tests working by having a special constructor for
11-
// ComponentType with just a ComponentName?
12-
1310
SCENARIO("Component type registration" TEST_TAG) {
1411
GIVEN("A valid component type") {
1512
rerun::ComponentType type("test", arrow::float64());

0 commit comments

Comments
 (0)