File indexing completed on 2025-09-17 09:07:51
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include "corecel/math/Algorithms.hh"
0010 #include "orange/OrangeTypes.hh"
0011
0012 namespace celeritas
0013 {
0014
0015 struct SimpleUnitRecord;
0016 class SimpleUnitTracker;
0017 class RectArrayTracker;
0018
0019
0020
0021
0022
0023 template<UniverseType U>
0024 struct UniverseTypeTraits;
0025
0026 #define ORANGE_UNIV_TRAITS(ENUM_VALUE, CLS) \
0027 template<> \
0028 struct UniverseTypeTraits<UniverseType::ENUM_VALUE> \
0029 { \
0030 using record_type = CLS##Record; \
0031 using tracker_type = CLS##Tracker; \
0032 }
0033
0034 ORANGE_UNIV_TRAITS(simple, SimpleUnit);
0035 ORANGE_UNIV_TRAITS(rect_array, RectArray);
0036
0037 #undef ORANGE_UNIV_TRAITS
0038
0039
0040
0041
0042
0043
0044
0045
0046 template<class F>
0047 CELER_CONSTEXPR_FUNCTION decltype(auto)
0048 visit_universe_type(F&& func, UniverseType ut)
0049 {
0050 #define ORANGE_UT_VISIT_CASE(TYPE) \
0051 case UniverseType::TYPE: \
0052 return celeritas::forward<F>(func)( \
0053 UniverseTypeTraits<UniverseType::TYPE>{})
0054
0055 switch (ut)
0056 {
0057 ORANGE_UT_VISIT_CASE(simple);
0058 ORANGE_UT_VISIT_CASE(rect_array);
0059 default:
0060 CELER_ASSERT_UNREACHABLE();
0061 }
0062 #undef ORANGE_UT_VISIT_CASE
0063 }
0064
0065
0066 }