opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
data_point_type.h
Go to the documentation of this file.
1#pragma once
2
5
6#include <array>
7#include <cstddef>
8
9namespace opyn
10{
11 // Describes the type of data held by [1..N] columns in the source data.
12 enum class DataPointType {
13 Point,
17 Unknown,
19 };
20
21 // A compile-time typelist of all possible `DataPointType`s.
28 >;
29
30 // Compile-time traits associated with a `DataPointType`.
31 template<DataPointType>
33
34 template<>
36 static constexpr osc::CStringView label = "Point";
37 static constexpr size_t num_elements = 3;
38 };
39
40 template<>
42 static constexpr osc::CStringView label = "ForcePoint";
43 static constexpr size_t num_elements = 6;
44 };
45
46 template<>
48 static constexpr osc::CStringView label = "BodyForce";
49 static constexpr size_t num_elements = 3;
50 };
51
52 template<>
54 static constexpr osc::CStringView label = "Orientation";
55 static constexpr size_t num_elements = 4;
56 };
57
58 template<>
60 static constexpr osc::CStringView label = "Unknown";
61 static constexpr size_t num_elements = 1;
62 };
63
64 // Returns the number of elements in a given `DataPointType`.
65 constexpr size_t numElementsIn(DataPointType t)
66 {
67 constexpr auto lut = []<DataPointType... Types>(osc::OptionList<DataPointType, Types...>)
68 {
69 return std::to_array({ ColumnDataTypeTraits<Types>::num_elements... });
71
72 return lut.at(osc::to_index(t));
73 }
74
75 // Returns a human-readable label for a given `DataPointType`.
77 {
78 constexpr auto lut = []<DataPointType... Types>(osc::OptionList<DataPointType, Types...>)
79 {
80 return std::to_array({ ColumnDataTypeTraits<Types>::label... });
82
83 return lut.at(osc::to_index(t));
84 }
85}
Definition c_string_view.h:12
Definition component_registry.h:14
constexpr size_t numElementsIn(DataPointType t)
Definition data_point_type.h:65
constexpr osc::CStringView labelFor(DataPointType t)
Definition data_point_type.h:76
DataPointType
Definition data_point_type.h:12
constexpr size_t to_index(TEnum v)
Definition enum_helpers.h:40
Definition data_point_type.h:32
Definition open_sim_helpers.h:784
Definition enum_helpers.h:33