Files
aare/src/defs.cpp
T
Erik Fröjdh 2041c7310a
Build on RHEL8 / build (push) Successful in 3m5s
Build on RHEL9 / build (push) Successful in 3m4s
Run tests using data on local RHEL8 / build (push) Successful in 3m57s
Build on local RHEL8 / build (push) Successful in 2m41s
Fixed usage of fmt::format and fmt::print for C++20 (#323)
With C++20 `fmt::print(s)` expects a compile time format string and
otherwise fails complaining about consteval. To get runtime formatting
use `fmt::print(fmt::runtime(s))`
2026-06-11 08:01:03 +02:00

70 lines
1.9 KiB
C++

// SPDX-License-Identifier: MPL-2.0
#include "aare/defs.hpp"
#include <stdexcept>
#include <string>
#include <fmt/core.h>
namespace aare {
void assert_failed(const std::string &msg) {
fmt::print("{}", msg);
exit(1);
}
// /**
// * @brief Convert a DetectorType to a string
// * @param type DetectorType
// * @return string representation of the DetectorType
// */
// template <> std::string ToString(DetectorType arg) {
// switch (arg) {
// case DetectorType::Generic:
// return "Generic";
// case DetectorType::Eiger:
// return "Eiger";
// case DetectorType::Gotthard:
// return "Gotthard";
// case DetectorType::Jungfrau:
// return "Jungfrau";
// case DetectorType::ChipTestBoard:
// return "ChipTestBoard";
// case DetectorType::Moench:
// return "Moench";
// case DetectorType::Mythen3:
// return "Mythen3";
// case DetectorType::Gotthard2:
// return "Gotthard2";
// case DetectorType::Xilinx_ChipTestBoard:
// return "Xilinx_ChipTestBoard";
// // Custom ones
// case DetectorType::Moench03:
// return "Moench03";
// case DetectorType::Moench03_old:
// return "Moench03_old";
// case DetectorType::Unknown:
// return "Unknown";
// // no default case to trigger compiler warning if not all
// // enum values are handled
// }
// throw std::runtime_error("Could not decode detector to string");
// }
BitOffset::BitOffset(uint32_t offset) {
if (offset > 7)
throw std::runtime_error(fmt::format(
"{} BitOffset needs to be <8: Called with {}", LOCATION, offset));
m_offset = static_cast<uint8_t>(offset);
}
bool BitOffset::operator==(const BitOffset &other) const {
return m_offset == other.m_offset;
}
bool BitOffset::operator<(const BitOffset &other) const {
return m_offset < other.m_offset;
}
} // namespace aare