#ifndef OT_HEADERDEF_HPP_ #define OT_HEADERDEF_HPP_ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // Clang mis-interprets variant's get as a non-friend of variant and cannot // get compiled correctly. We use the patch: // https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=258854 // to get rid of this. #if defined(__clang__) #if __clang_major__ > 12 #include #else #include #endif #else #include #endif // third-party include #include #include #include #include // Top header declaration. #include namespace ot { using Json = nlohmann::json; // -------------------------------------------------------- using namespace std::chrono_literals; using namespace std::literals::string_literals; enum Split { MIN = 0, MAX = 1 }; enum Tran { RISE = 0, FALL = 1 }; constexpr int MAX_SPLIT = 2; constexpr int MAX_TRAN = 2; // Function: to_string inline auto to_string(Split m) { switch(m) { case MIN: return "min"s; break; case MAX: return "max"s; break; default: return "unknown split"s; break; }; } // Function: to_string inline auto to_string(Tran t) { switch(t) { case RISE: return "rise"s; break; case FALL: return "fall"s; break; default: return "unknown tran"s; break; }; } inline std::ostream& operator << (std::ostream& os, Split t) { switch(t) { case MIN: os << "min"; break; case MAX: os << "max"; break; default: os << "unknown split"; break; }; return os; } inline std::ostream& operator << (std::ostream& os, Tran t) { switch(t) { case RISE: os << "rise"; break; case FALL: os << "fall"; break; default: os << "unknown tran"; break; }; return os; } // Function: to_string inline auto to_string(Tran from, Tran to) { return to_string(from) + "->" + to_string(to); } // ------------------------------------------------------------------------------------------------ constexpr std::initializer_list SPLIT = {MIN, MAX}; constexpr std::initializer_list TRAN = {RISE, FALL}; constexpr std::initializer_list> SPLIT_TRAN = { {MIN, RISE}, {MIN, FALL}, {MAX, RISE}, {MAX, FALL} }; constexpr std::initializer_list> TRANX2 = { {RISE, RISE}, {RISE, FALL}, {FALL, RISE}, {FALL, FALL} }; constexpr std::initializer_list> SPLIT_TRANx2 = { {MIN, RISE, RISE}, {MIN, RISE, FALL}, {MIN, FALL, RISE}, {MIN, FALL, FALL}, {MAX, RISE, RISE}, {MAX, RISE, FALL}, {MAX, FALL, RISE}, {MAX, FALL, FALL} }; // ------------------------------------------------------------------------------------------------ #define FOR_EACH_EL(el) for(auto el : SPLIT) #define FOR_EACH_RF(rf) for(auto rf : TRAN) #define FOR_EACH_RF_RF(irf, orf) for(auto [irf, orf] : TRANX2) #define FOR_EACH_EL_RF(el, rf) for(auto [el, rf] : SPLIT_TRAN) #define FOR_EACH_EL_RF_RF(el, rf1, rf2) for(auto [el, rf1, rf2] : SPLIT_TRANx2) #define FOR_EACH_EL_IF(el, c) for(auto el : SPLIT) if(c) #define FOR_EACH_RF_IF(rf, c) for(auto rf : TRAN) if(c) #define FOR_EACH_RF_RF_IF(irf, orf, c) for(auto [irf, orf] : TRANX2) if(c) #define FOR_EACH_EL_RF_IF(el, rf, c) for(auto [el, rf] : SPLIT_TRAN) if(c) #define FOR_EACH_EL_RF_RF_IF(el, rf1, rf2, c) for(auto [el, rf1, rf2] : SPLIT_TRANx2) if(c) #define FOR_EACH(i, C) for(auto& i : C) #define FOR_EACH_IF(i, C, s) for(auto& i : C) if(s) // ------------------------------------------------------------------------------------------------ // TimingData template struct TimingDataHelper; template struct TimingDataHelper { using type = std::array::type, D0>; }; template struct TimingDataHelper{ using type = T; }; template using TimingData = typename TimingDataHelper::type; }; // End of namespace ot. ----------------------------------------------------------------------- #endif