55#include <commons/color.hpp>
56#include <commons/icon.hpp>
57#include <commons/icons.hpp>
61#define DIMVAL_DETAIL_CAT2(a, b) a##b
62#define DIMVAL_DETAIL_CAT(a, b) DIMVAL_DETAIL_CAT2(a, b)
72#define DIMVAL_DEFINE_UNIT(Tag, Id, Symbol, ShortName, LongName, Kind, Factor, Icon, Color, ...) \
74 struct Tag : ::dimval::UnitBase<Tag> { \
75 static constexpr ::std::string_view id = Id; \
76 static constexpr ::std::string_view symbol = Symbol; \
77 static constexpr ::std::string_view short_name = ShortName; \
78 static constexpr ::std::string_view long_name = LongName; \
79 static constexpr ::std::string_view kind = Kind; \
80 static constexpr double factor = Factor; \
81 static constexpr ::dimval::detail::icon_field_t icon = Icon; \
82 static constexpr ::dimval::detail::color_field_t color = Color; \
85 using DIMVAL_DETAIL_CAT(Tag, Value) = ::dimval::UnitValue<Tag>; \
86 using DIMVAL_DETAIL_CAT(Tag, ValueUnique) = ::std::unique_ptr<DIMVAL_DETAIL_CAT(Tag, Value)>; \
87 using DIMVAL_DETAIL_CAT(Tag, ValueShared) = ::std::shared_ptr<DIMVAL_DETAIL_CAT(Tag, Value)>; \
88 using DIMVAL_DETAIL_CAT(Tag, RangeValue) = ::dimval::UnitRangeValue<Tag>; \
90 namespace dimval::detail { \
91 [[maybe_unused]] inline const int DIMVAL_DETAIL_CAT(_dimval_unit_reg_, Tag) = \
92 ::dimval::detail::register_unit_tag<::dimval::Tag>(); \
102#define DIMVAL_DEFINE_MEASURE(Tag, BaseUnit, Id, Name, Icon, Color, ...) \
104 struct Tag : ::dimval::MeasureBase<Tag, BaseUnit> { \
105 static constexpr ::std::string_view id = Id; \
106 static constexpr ::std::string_view name = Name; \
107 static constexpr ::dimval::detail::icon_field_t icon = Icon; \
108 static constexpr ::dimval::detail::color_field_t color = Color; \
111 using DIMVAL_DETAIL_CAT(Tag, Value) = ::dimval::MeasureValue<Tag>; \
112 using DIMVAL_DETAIL_CAT(Tag, ValueUnique) = ::std::unique_ptr<DIMVAL_DETAIL_CAT(Tag, Value)>; \
113 using DIMVAL_DETAIL_CAT(Tag, ValueShared) = ::std::shared_ptr<DIMVAL_DETAIL_CAT(Tag, Value)>; \
114 using DIMVAL_DETAIL_CAT(Tag, RangeValue) = ::dimval::MeasureRangeValue<Tag>; \
116 namespace dimval::detail { \
117 [[maybe_unused]] inline const int DIMVAL_DETAIL_CAT(_dimval_measure_reg_, Tag) = \
118 ::dimval::detail::register_measure_tag<::dimval::Tag>(); \
CRTP bases that turn unit/measure tag structs into self-describing types.
MeasureValue<M,T>: a UnitValue tagged with an additional semantic measure.
Thread-safe runtime registries of unit and measure descriptors.
UnitValue<U,T>: a strongly-typed value carrying a compile-time unit tag.