Sen API
Sen Libraries
Loading...
Searching...
No Matches
gen.h
Go to the documentation of this file.
1// === gen.h ===========================================================================================================
2// Sen Infrastructure
3// Released under the Apache License v2.0 (SPDX-License-Identifier Apache-2.0).
4// See the LICENSE.txt file for more information.
5// © Airbus SAS, Airbus Helicopters, and Airbus Defence and Space SAU/GmbH/SAS.
6// =====================================================================================================================
7
8#ifndef SEN_CORE_OBJ_DETAIL_GEN_H
9#define SEN_CORE_OBJ_DETAIL_GEN_H
10
11// sen
16#include "sen/core/base/span.h"
18#include "sen/core/io/util.h"
19#include "sen/core/lang/vm.h"
40
41// std
42#include <initializer_list> // NOLINT(misc-include-cleaner): used by not visible due to macros
43#include <iterator> // NOLINT(misc-include-cleaner): used by not visible due to macros
44#include <optional>
45#include <type_traits>
46#include <utility>
47
48#define SEN_IMPL_GEN_NATIVE_MEMBERS \
49protected: \
50 [[nodiscard]] inline ::sen::Var senImplGetPropertyImpl(::sen::MemberHash propertyId) const override; \
51 inline void senImplSetNextPropertyUntyped(::sen::MemberHash propertyId, const ::sen::Var& value) override; \
52 [[nodiscard]] inline ::sen::Var senImplGetNextPropertyUntyped(::sen::MemberHash propertyId) const override; \
53 [[nodiscard]] inline uint32_t senImplComputeMaxReliableSerializedPropertySizeImpl() const override; \
54 inline void senImplStreamCall(::sen::MemberHash methodId, ::sen::InputStream& in, ::sen::StreamCallForwarder&& func) \
55 override; \
56 inline void senImplVariantCall( \
57 ::sen::MemberHash methodId, const ::sen::VarList& args, ::sen::VariantCallForwarder&& func) override; \
58 inline void senImplCommitImpl(::sen::TimeStamp time) override; \
59 inline void senImplWriteChangedPropertiesToStream( \
60 ::sen::OutputStream& confirmed, ::sen::impl::BufferProvider uni, ::sen::impl::BufferProvider multi) override; \
61 inline void senImplWriteAllPropertiesToStream(::sen::OutputStream& out) const override; \
62 inline void senImplWriteStaticPropertiesToStream(::sen::OutputStream& out) const override; \
63 inline void senImplWriteDynamicPropertiesToStream(::sen::OutputStream& out) const override; \
64 inline void senImplRemoveTypedConnection(::sen::ConnId id) override; \
65 [[nodiscard]] inline ::sen::impl::FieldValueGetter senImplGetFieldValueGetter( \
66 ::sen::MemberHash propertyId, ::sen::Span<uint16_t> fields) const override; \
67 inline void invokeAllPropertyCallbacks() override;
68
70#define SEN_IMPL_GEN_BASE_CLASS(classname) \
71 SEN_IMPL_GEN_NATIVE_MEMBERS \
72 \
73private: \
74 bool somePropertyIsDirty_ = false; \
75 \
76public: \
77 inline classname(std::string name, const ::sen::VarMap& args); \
78 ~classname() override = default; \
79 [[nodiscard]] inline ::sen::ConstTypeHandle<::sen::ClassType> getClass() const noexcept override; \
80 [[nodiscard]] static inline ::sen::ConstTypeHandle<::sen::ClassType> meta() noexcept; \
81 \
82private:
83
85#define SEN_IMPL_GEN_REMOTE_CLASS(classname) \
86public: \
87 explicit classname(::sen::impl::RemoteObjectInfo&& info); \
88 ~classname() override = default; \
89 \
90protected: \
91 void senImplRemoveTypedConnection(::sen::ConnId id) override; \
92 void senImplWriteAllPropertiesToStream(::sen::OutputStream& out) const override; \
93 void senImplWriteStaticPropertiesToStream(::sen::OutputStream& out) const override; \
94 void senImplWriteDynamicPropertiesToStream(::sen::OutputStream& out) const override; \
95 [[nodiscard]] ::sen::Var senImplGetPropertyImpl(::sen::MemberHash propertyId) const override; \
96 [[nodiscard]] bool readPropertyFromStream(::sen::MemberHash id, ::sen::InputStream& in, bool initialState) override; \
97 [[nodiscard]] ::sen::Var deserializeMethodReturnValueAsVariant(::sen::MemberHash methodId, ::sen::InputStream& in) \
98 const override; \
99 void serializeMethodArgumentsFromVariants( \
100 ::sen::MemberHash methodId, const ::sen::VarList& args, ::sen::OutputStream& out) const override; \
101 void drainInputs() override; \
102 void eventReceived(::sen::MemberHash eventId, ::sen::TimeStamp creationTime, const ::sen::Span<const uint8_t>& args) \
103 override; \
104 void invokeAllPropertyCallbacks() override; \
105 \
106private:
107
109#define SEN_IMPL_GEN_LOCAL_PROXY_CLASS(classname) \
110public: \
111 explicit classname(::sen::NativeObject* owner, const std::string& localPrefix); \
112 ~classname() override = default; \
113 \
114protected: \
115 void senImplWriteAllPropertiesToStream(::sen::OutputStream& out) const override; \
116 void senImplWriteStaticPropertiesToStream(::sen::OutputStream& out) const override; \
117 void senImplWriteDynamicPropertiesToStream(::sen::OutputStream& out) const override; \
118 void senImplRemoveTypedConnection(::sen::ConnId id) override; \
119 [[nodiscard]] ::sen::Var senImplGetPropertyImpl(::sen::MemberHash propertyId) const override; \
120 void drainInputsImpl(::sen::TimeStamp lastCommitTime) override; \
121 \
122private:
123
125#define SEN_IMPL_GEN_UNBOUNDED_SEQUENCE(classname, elementtype) \
126 class classname final: private std::vector<elementtype> \
127 { \
128 using Parent = std::vector<elementtype>; \
129 \
130 public: \
131 using Parent::value_type; \
132 using Parent::size_type; \
133 \
134 using Parent::iterator; \
135 using Parent::const_iterator; \
136 using Parent::reverse_iterator; \
137 using Parent::const_reverse_iterator; \
138 \
139 using Parent::reference; \
140 using Parent::const_reference; \
141 using Parent::pointer; \
142 using Parent::const_pointer; \
143 \
144 using Parent::Parent; \
145 using Parent::operator=; \
146 using Parent::assign; \
147 \
148 using Parent::at; \
149 using Parent::operator[]; \
150 using Parent::front; \
151 using Parent::back; \
152 /* std::vector<bool> declares no data(), and libc++ and the MSVC STL do not \
153 declare it at all, so a using-declaration is ill-formed there. A member \
154 template is instantiated only when called: a bool sequence has no data(). */ \
155 template <typename E = elementtype> \
156 auto data() \
157 { \
158 return static_cast<std::vector<E>&>(*this).data(); \
159 } \
160 template <typename E = elementtype> \
161 auto data() const \
162 { \
163 return static_cast<const std::vector<E>&>(*this).data(); \
164 } \
165 \
166 using Parent::begin; \
167 using Parent::cbegin; \
168 using Parent::rbegin; \
169 using Parent::crbegin; \
170 using Parent::end; \
171 using Parent::cend; \
172 using Parent::rend; \
173 using Parent::crend; \
174 \
175 using Parent::empty; \
176 using Parent::size; \
177 using Parent::max_size; \
178 using Parent::reserve; \
179 using Parent::capacity; \
180 using Parent::shrink_to_fit; \
181 \
182 using Parent::clear; \
183 using Parent::insert; \
184 using Parent::emplace; \
185 using Parent::erase; \
186 using Parent::push_back; \
187 using Parent::emplace_back; \
188 using Parent::pop_back; \
189 using Parent::resize; \
190 using Parent::swap; \
191 \
192 constexpr const Parent& asVector() const& noexcept { return *this; } \
193 Parent asVector() && noexcept(std::is_nothrow_move_constructible_v<Parent>) { return std::move(*this); } \
194 \
195 friend bool operator==(const classname& lhs, const classname& rhs) { return lhs.asVector() == rhs.asVector(); } \
196 friend bool operator!=(const classname& lhs, const classname& rhs) { return !(lhs == rhs); } \
197 \
198 template <typename P = Parent> \
199 std::enable_if_t<sen::HasOperator<P>::lt, bool> operator<(const classname& other) const \
200 { \
201 return static_cast<const P&>(*this) < static_cast<const P&>(other); \
202 } \
203 \
204 template <typename P = Parent> \
205 std::enable_if_t<sen::HasOperator<P>::lt, bool> operator>(const classname& other) const \
206 { \
207 return static_cast<const P&>(other) < static_cast<const P&>(*this); \
208 } \
209 };
212#define SEN_IMPL_GEN_BOUNDED_SEQUENCE(classname, element, maxSize) \
213 struct classname final: public ::sen::StaticVector<element, maxSize> \
214 { \
215 using Parent = ::sen::StaticVector<element, maxSize>; \
216 using Parent::Parent; \
217 using Parent::operator=; \
218 \
219 template <typename P = Parent> \
220 std::enable_if_t<sen::HasOperator<P>::lt, bool> operator<(const classname& other) const \
221 { \
222 return static_cast<const P&>(*this) < static_cast<const P&>(other); \
223 } \
224 \
225 template <typename P = Parent> \
226 std::enable_if_t<sen::HasOperator<P>::lt, bool> operator>(const classname& other) const \
227 { \
228 return static_cast<const P&>(other) < static_cast<const P&>(*this); \
229 } \
230 };
233#define SEN_IMPL_GEN_FIXED_SEQUENCE(classname, element, num_elements) \
234 class classname final: private std::array<element, num_elements> \
235 { \
236 using Parent = std::array<element, num_elements>; \
237 \
238 public: \
239 using Parent::value_type; \
240 using Parent::reference; \
241 using Parent::const_reference; \
242 using Parent::pointer; \
243 using Parent::const_pointer; \
244 using Parent::iterator; \
245 using Parent::const_iterator; \
246 using Parent::reverse_iterator; \
247 using Parent::const_reverse_iterator; \
248 \
249 using Parent::Parent; \
250 using Parent::operator=; \
251 \
252 using Parent::at; \
253 using Parent::operator[]; \
254 using Parent::front; \
255 using Parent::back; \
256 using Parent::data; \
257 \
258 using Parent::begin; \
259 using Parent::cbegin; \
260 using Parent::rbegin; \
261 using Parent::crbegin; \
262 using Parent::end; \
263 using Parent::cend; \
264 using Parent::rend; \
265 using Parent::crend; \
266 \
267 using Parent::empty; \
268 using Parent::size; \
269 using Parent::max_size; \
270 \
271 using Parent::fill; \
272 using Parent::swap; \
273 \
274 template <typename Y, typename = std::enable_if_t<std::is_convertible_v<Y, element>, int>> \
275 constexpr classname(std::initializer_list<Y> elems): Parent() \
276 { \
277 using DifferenceType = \
278 typename std::iterator_traits<typename std::initializer_list<Y>::iterator>::difference_type; \
279 SEN_ASSERT(std::distance(std::begin(elems), std::end(elems)) <= static_cast<DifferenceType>(num_elements)); \
280 std::move(std::begin(elems), \
281 std::next(std::begin(elems), \
282 std::min(std::distance(std::begin(elems), std::end(elems)), \
283 static_cast<DifferenceType>(num_elements))), \
284 std::begin(*this)); \
285 } \
286 \
287 constexpr const Parent& asArray() const& noexcept { return *this; } \
288 Parent asArray() && noexcept(std::is_nothrow_move_constructible_v<element>) { return std::move(*this); } \
289 \
290 friend bool operator==(const classname& lhs, const classname& rhs) { return lhs.asArray() == rhs.asArray(); } \
291 friend bool operator!=(const classname& lhs, const classname& rhs) { return !(lhs == rhs); } \
292 \
293 template <typename P = Parent> \
294 std::enable_if_t<sen::HasOperator<P>::lt, bool> operator<(const classname& other) const \
295 { \
296 return static_cast<const P&>(*this) < static_cast<const P&>(other); \
297 } \
298 \
299 template <typename P = Parent> \
300 std::enable_if_t<sen::HasOperator<P>::lt, bool> operator>(const classname& other) const \
301 { \
302 return static_cast<const P&>(other) < static_cast<const P&>(*this); \
303 } \
304 };
307#define SEN_IMPL_GEN_STRUCT_OPERATORS(classname, doExport) \
308 SEN_MAYBE_EXPORT(doExport) std::ostream& operator<<(std::ostream& out, const classname& val); \
309 SEN_MAYBE_EXPORT(doExport) bool operator==(const classname& lhs, const classname& rhs); \
310 SEN_MAYBE_EXPORT(doExport) bool operator!=(const classname& lhs, const classname& rhs);
313#define SEN_IMPL_GEN_OPTIONAL(classname, elementtype) \
314 class classname final: private std::optional<elementtype> \
315 { \
316 using Parent = std::optional<elementtype>; \
317 \
318 public: \
319 using Parent::value_type; \
320 \
321 using Parent::Parent; \
322 using Parent::operator=; \
323 \
324 using Parent::operator->; \
325 using Parent::operator*; \
326 using Parent::operator bool; \
327 using Parent::has_value; \
328 using Parent::value; \
329 using Parent::value_or; \
330 \
331 using Parent::reset; \
332 using Parent::swap; \
333 using Parent::emplace; \
334 \
335 classname& operator=(const elementtype& value) \
336 { \
337 Parent::operator=(value); \
338 return *this; \
339 } \
340 \
341 classname& operator=(elementtype&& value) \
342 { \
343 Parent::operator=(std::move(value)); \
344 return *this; \
345 } \
346 \
347 constexpr const Parent& asOptional() const& noexcept { return *this; } \
348 Parent asOptional() && noexcept(std::is_nothrow_move_constructible_v<Parent>) { return std::move(*this); } \
349 \
350 friend constexpr bool operator==(const classname& lhs, const classname& rhs) \
351 { \
352 return lhs.asOptional() == rhs.asOptional(); \
353 } \
354 friend constexpr bool operator!=(const classname& lhs, const classname& rhs) { return !(lhs == rhs); } \
355 };
358#define SEN_IMPL_GEN_OPTIONAL_TRAITS(classname, doExport) \
359 template <> \
360 struct MetaTypeTrait<classname> \
361 { \
362 [[nodiscard]] SEN_MAYBE_EXPORT(doExport) static ConstTypeHandle<OptionalType> meta(); \
363 }; \
364 template <> \
365 struct VariantTraits<classname>: private OptionalTraitsBase<classname> \
366 { \
367 using OptionalTraitsBase<classname>::valueToVariant; \
368 using OptionalTraitsBase<classname>::variantToValue; \
369 }; \
370 template <> \
371 struct SerializationTraits<classname>: private OptionalTraitsBase<classname> \
372 { \
373 using OptionalTraitsBase<classname>::write; \
374 using OptionalTraitsBase<classname>::read; \
375 using OptionalTraitsBase<classname>::serializedSize; \
376 using OptionalTraitsBase<classname>::toJsonString; \
377 using OptionalTraitsBase<classname>::fromJsonString; \
378 };
381#define SEN_IMPL_GEN_ENUM_TRAITS(classname, doExport) \
382 template <> \
383 struct MetaTypeTrait<classname> \
384 { \
385 [[nodiscard]] SEN_MAYBE_EXPORT(doExport) static ConstTypeHandle<EnumType> meta(); \
386 }; \
387 template <> \
388 struct SEN_MAYBE_EXPORT(doExport) VariantTraits<classname>: private EnumTraitsBase<classname> \
389 { \
390 using EnumTraitsBase<classname>::valueToVariant; \
391 using EnumTraitsBase<classname>::variantToValue; \
392 }; \
393 template <> \
394 struct SEN_MAYBE_EXPORT(doExport) SerializationTraits<classname>: private EnumTraitsBase<classname> \
395 { \
396 using EnumTraitsBase<classname>::write; \
397 using EnumTraitsBase<classname>::read; \
398 using EnumTraitsBase<classname>::serializedSize; \
399 using EnumTraitsBase<classname>::toJsonString; \
400 using EnumTraitsBase<classname>::fromJsonString; \
401 }; \
402 template <> \
403 struct SEN_MAYBE_EXPORT(doExport) StringConversionTraits<classname> \
404 { \
405 [[nodiscard]] static std::string_view toString(classname val); \
406 [[nodiscard]] static classname fromString(std::string_view val); \
407 }; \
408 \
409 [[nodiscard]] SEN_MAYBE_EXPORT(doExport) std::string_view toString(classname value);
412#define SEN_IMPL_GEN_SEQUENCE_TRAITS(classname, doExport) \
413 template <> \
414 struct MetaTypeTrait<classname> \
415 { \
416 [[nodiscard]] SEN_MAYBE_EXPORT(doExport) static sen::ConstTypeHandle<SequenceType> meta(); \
417 }; \
418 template <> \
419 struct SEN_MAYBE_EXPORT(doExport) VariantTraits<classname>: private SequenceTraitsBase<classname> \
420 { \
421 using SequenceTraitsBase<classname>::valueToVariant; \
422 using SequenceTraitsBase<classname>::variantToValue; \
423 }; \
424 template <> \
425 struct SEN_MAYBE_EXPORT(doExport) SerializationTraits<classname>: private SequenceTraitsBase<classname> \
426 { \
427 using SequenceTraitsBase<classname>::write; \
428 using SequenceTraitsBase<classname>::read; \
429 using SequenceTraitsBase<classname>::serializedSize; \
430 using SequenceTraitsBase<classname>::toJsonString; \
431 using SequenceTraitsBase<classname>::fromJsonString; \
432 };
435#define SEN_IMPL_GEN_ARRAY_TRAITS(classname, doExport) \
436 template <> \
437 struct MetaTypeTrait<classname> \
438 { \
439 [[nodiscard]] SEN_MAYBE_EXPORT(doExport) static ConstTypeHandle<SequenceType> meta(); \
440 }; \
441 template <> \
442 struct SEN_MAYBE_EXPORT(doExport) VariantTraits<classname>: private ArrayTraitsBase<classname> \
443 { \
444 using ArrayTraitsBase<classname>::valueToVariant; \
445 using ArrayTraitsBase<classname>::variantToValue; \
446 }; \
447 template <> \
448 struct SEN_MAYBE_EXPORT(doExport) SerializationTraits<classname>: private ArrayTraitsBase<classname> \
449 { \
450 using ArrayTraitsBase<classname>::write; \
451 using ArrayTraitsBase<classname>::read; \
452 using ArrayTraitsBase<classname>::serializedSize; \
453 using ArrayTraitsBase<classname>::toJsonString; \
454 using ArrayTraitsBase<classname>::fromJsonString; \
455 };
458#define SEN_IMPL_GEN_STRUCT_TRAITS(classname, doExport) \
459 template <> \
460 struct MetaTypeTrait<classname> \
461 { \
462 [[nodiscard]] SEN_MAYBE_EXPORT(doExport) static ConstTypeHandle<StructType> meta(); \
463 }; \
464 template <> \
465 struct SEN_MAYBE_EXPORT(doExport) VariantTraits<classname>: protected StructTraitsBase \
466 { \
467 static void valueToVariant(const classname& val, Var& var); \
468 static void variantToValue(const Var& var, classname& val); \
469 static std::function<lang::Value(const void*)> getFieldValueGetterFunction(Span<uint16_t> fields); \
470 }; \
471 template <> \
472 struct SEN_MAYBE_EXPORT(doExport) SerializationTraits<classname>: protected StructTraitsBase \
473 { \
474 static void write(OutputStream& out, const classname& val); \
475 static void read(InputStream& in, classname& val); \
476 [[nodiscard]] static uint32_t serializedSize(const classname& val) noexcept; \
477 static std::string toJsonString(const classname& val); \
478 static void fromJsonString(const std::string& str, classname& val); \
479 };
482#define SEN_IMPL_GEN_VARIANT_TRAITS(classname, doExport) \
483 template <> \
484 struct SEN_MAYBE_EXPORT(doExport) MetaTypeTrait<classname> \
485 { \
486 [[nodiscard]] static ConstTypeHandle<VariantType> meta(); \
487 }; \
488 template <> \
489 struct SEN_MAYBE_EXPORT(doExport) VariantTraits<classname>: protected VariantTraitsBase<classname> \
490 { \
491 static void valueToVariant(const classname& val, Var& var); \
492 static void variantToValue(const Var& var, classname& val); \
493 static std::function<lang::Value(const void*)> getFieldValueGetterFunction(Span<uint16_t> fields); \
494 using VariantTraitsBase<classname>::tryPrintField; \
495 }; \
496 template <> \
497 struct SEN_MAYBE_EXPORT(doExport) SerializationTraits<classname>: protected VariantTraitsBase<classname> \
498 { \
499 static void write(OutputStream& out, const classname& val); \
500 static void read(InputStream& in, classname& val); \
501 [[nodiscard]] static uint32_t serializedSize(const classname& val) noexcept; \
502 static std::string toJsonString(const classname& val); \
503 static void fromJsonString(const std::string& str, classname& val); \
504 };
507#define SEN_IMPL_GEN_CLASS_META_TRAITS(classname, doExport) \
508 template <> \
509 struct MetaTypeTrait<classname> \
510 { \
511 [[nodiscard]] SEN_MAYBE_EXPORT(doExport) static ConstTypeHandle<ClassType> meta(); \
512 };
515#define SEN_IMPL_GEN_CLASS_TRAITS_TEMPLATE(interfaceName, remoteProxy, localProxy, baseName) \
516 template <> \
517 struct SenClassRelation<interfaceName> \
518 { \
519 using InterfaceType = interfaceName; \
520 template <typename T> \
521 using BaseType = baseName<T>; \
522 static constexpr bool isBaseTypeTemplate = true; \
523 using RemoteProxyType = remoteProxy; \
524 using LocalProxyType = localProxy; \
525 }; \
526 template <> \
527 struct SenClassRelation<remoteProxy> \
528 { \
529 using InterfaceType = interfaceName; \
530 template <typename T> \
531 using BaseType = baseName<T>; \
532 static constexpr bool isBaseTypeTemplate = true; \
533 using RemoteProxyType = remoteProxy; \
534 using LocalProxyType = localProxy; \
535 }; \
536 template <> \
537 struct SenClassRelation<localProxy> \
538 { \
539 using InterfaceType = interfaceName; \
540 template <typename T> \
541 using BaseType = baseName<T>; \
542 static constexpr bool isBaseTypeTemplate = true; \
543 using RemoteProxyType = remoteProxy; \
544 using LocalProxyType = localProxy; \
545 }; \
546 template <typename T> \
547 struct SenClassRelation<baseName<T>> \
548 { \
549 using InterfaceType = interfaceName; \
550 template <typename U> \
551 using BaseType = baseName<U>; \
552 static constexpr bool isBaseTypeTemplate = true; \
553 using RemoteProxyType = remoteProxy; \
554 using LocalProxyType = localProxy; \
555 };
558#define SEN_IMPL_GEN_CLASS_TRAITS_NORMAL(interfaceName, remoteProxy, localProxy, baseName) \
559 template <> \
560 struct SenClassRelation<interfaceName> \
561 { \
562 using InterfaceType = interfaceName; \
563 using BaseType = baseName; \
564 static constexpr bool isBaseTypeTemplate = false; \
565 using RemoteProxyType = remoteProxy; \
566 using LocalProxyType = localProxy; \
567 }; \
568 template <> \
569 struct SenClassRelation<remoteProxy> \
570 { \
571 using InterfaceType = interfaceName; \
572 using BaseType = baseName; \
573 static constexpr bool isBaseTypeTemplate = false; \
574 using RemoteProxyType = remoteProxy; \
575 using LocalProxyType = localProxy; \
576 }; \
577 template <> \
578 struct SenClassRelation<localProxy> \
579 { \
580 using InterfaceType = interfaceName; \
581 using BaseType = baseName; \
582 static constexpr bool isBaseTypeTemplate = false; \
583 using RemoteProxyType = remoteProxy; \
584 using LocalProxyType = localProxy; \
585 }; \
586 template <> \
587 struct SenClassRelation<baseName> \
588 { \
589 using InterfaceType = interfaceName; \
590 using BaseType = baseName; \
591 static constexpr bool isBaseTypeTemplate = false; \
592 using RemoteProxyType = remoteProxy; \
593 using LocalProxyType = localProxy; \
594 };
597#define SEN_IMPL_GEN_QUANTITY_TRAITS(classname, maxVal, minVal, doExport) \
598 template <> \
599 struct MetaTypeTrait<classname> \
600 { \
601 [[nodiscard]] SEN_MAYBE_EXPORT(doExport) static ConstTypeHandle<QuantityType> meta(); \
602 }; \
603 template <> \
604 struct SEN_MAYBE_EXPORT(doExport) VariantTraits<classname>: private QuantityTraitsBase<classname> \
605 { \
606 using QuantityTraitsBase<classname>::valueToVariant; \
607 using QuantityTraitsBase<classname>::variantToValue; \
608 }; \
609 template <> \
610 struct SEN_MAYBE_EXPORT(doExport) SerializationTraits<classname>: private QuantityTraitsBase<classname> \
611 { \
612 using QuantityTraitsBase<classname>::write; \
613 using QuantityTraitsBase<classname>::read; \
614 using QuantityTraitsBase<classname>::serializedSize; \
615 using QuantityTraitsBase<classname>::toJsonString; \
616 using QuantityTraitsBase<classname>::fromJsonString; \
617 }; \
618 template <> \
619 struct SEN_MAYBE_EXPORT(doExport) QuantityTraits<classname> \
620 { \
621 using ValueType = typename classname::ValueType; \
622 \
623 static constexpr ValueType max = maxVal; \
624 static constexpr ValueType min = minVal; \
625 \
626 [[nodiscard]] static ::std::optional<const sen::Unit*> unit() noexcept; \
627 [[nodiscard]] static const sen::Unit& unit(sen::Unit::EnsureTag); \
628 };
629
630#endif // SEN_CORE_OBJ_DETAIL_GEN_H
The following macros implement a replacement of assert that is connected to the overall fault handlin...