3
3
#include < optional>
4
4
#include < string_view>
5
5
6
- // TODO: to_string maybe?
7
-
8
6
namespace rerun {
9
7
// / A `ComponentDescriptor` fully describes the semantics of a column of data.
10
8
// /
@@ -32,8 +30,6 @@ namespace rerun {
32
30
// / Example: `rerun.components.Position3D`.
33
31
std::string_view component_name;
34
32
35
- // TODO: {entity_path}@{archetype_name}:{component_name}#{archetype_field_name}
36
-
37
33
constexpr ComponentDescriptor (
38
34
std::optional<std::string_view> archetype_name_,
39
35
std::optional<std::string_view> archetype_field_name_, std::string_view component_name_
@@ -56,6 +52,78 @@ namespace rerun {
56
52
constexpr ComponentDescriptor (const char * component_name_)
57
53
: component_name(component_name_) {}
58
54
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
+ }
60
128
};
61
129
} // namespace rerun
0 commit comments