Rerun C++ SDK
Loading...
Searching...
No Matches
component_type_registry.hpp
1#pragma once
2
3#include <memory>
4#include <shared_mutex>
5#include <unordered_map>
6
7#include "component_descriptor.hpp"
8#include "component_type.hpp"
9#include "result.hpp"
10
11namespace arrow {
12 class Array;
13 class DataType;
14} // namespace arrow
15
16namespace rerun {
17
18 /// Thread-safe registry for component types.
19 ///
20 /// Ensures that each component descriptor is only registered once.
22 public:
23 ComponentTypeRegistry() = default;
24
25 /// Returns the handle to the registered component type for the given descriptor.
26 ///
27 /// Registers the component type when first encountered.
29 const ComponentDescriptor& descriptor,
30 const std::shared_ptr<arrow::DataType>& arrow_datatype
31 );
32
33 private:
34 std::shared_mutex mutex_;
35 std::unordered_map<ComponentDescriptorHash, ComponentTypeHandle> comp_types_per_descr_;
36 };
37
38} // namespace rerun
Thread-safe registry for component types.
Definition component_type_registry.hpp:21
Result< ComponentTypeHandle > get_or_register(const ComponentDescriptor &descriptor, const std::shared_ptr< arrow::DataType > &arrow_datatype)
Returns the handle to the registered component type for the given descriptor.
A class for representing either a usable value, or an error.
Definition result.hpp:14
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
A ComponentDescriptor fully describes the semantics of a column of data.
Definition component_descriptor.hpp:16