File indexing completed on 2025-07-01 08:45:49
0001 #ifndef PODIO_PODIOVERSION_H
0002 #define PODIO_PODIOVERSION_H
0003
0004 #include <cstdint>
0005 #include <ostream>
0006 #include <sstream>
0007 #include <tuple>
0008
0009
0010
0011
0012
0013 #define PODIO_VERSION(major, minor, patch) \
0014 ((UINT64_C(major) << 32) | (UINT64_C(minor) << 16) | UINT64_C(patch))
0015
0016 #define PODIO_MAJOR_VERSION(v) (((v) & (-1UL >> 16)) >> 32)
0017
0018 #define PODIO_MINOR_VERSION(v) (((v) & (-1UL >> 32)) >> 16)
0019
0020 #define PODIO_PATCH_VERSION(v) ((v) & (-1UL >> 48))
0021
0022
0023 #define podio_VERSION_MAJOR 1
0024 #define podio_VERSION_MINOR 2
0025 #define podio_VERSION_PATCH 0
0026 #define podio_VERSION PODIO_VERSION(podio_VERSION_MAJOR, podio_VERSION_MINOR, podio_VERSION_PATCH)
0027
0028
0029 #define PODIO_BUILD_VERSION PODIO_VERSION(podio_VERSION_MAJOR, podio_VERSION_MINOR, podio_VERSION_PATCH)
0030
0031 namespace podio::version {
0032
0033
0034
0035
0036 struct Version {
0037 uint16_t major{0};
0038 uint16_t minor{0};
0039 uint16_t patch{0};
0040
0041
0042
0043
0044 #define DEFINE_COMP_OPERATOR(OP) \
0045 constexpr bool operator OP(const Version& o) const noexcept { \
0046 return std::tie(major, minor, patch) OP std::tie(o.major, o.minor, o.patch); \
0047 }
0048
0049 DEFINE_COMP_OPERATOR(<)
0050 DEFINE_COMP_OPERATOR(<=)
0051 DEFINE_COMP_OPERATOR(>)
0052 DEFINE_COMP_OPERATOR(>=)
0053 DEFINE_COMP_OPERATOR(==)
0054 DEFINE_COMP_OPERATOR(!=)
0055
0056 #undef DEFINE_COMP_OPERATOR
0057
0058 explicit operator std::string() const {
0059 std::stringstream ss;
0060 ss << *this;
0061 return ss.str();
0062 }
0063
0064 friend std::ostream& operator<<(std::ostream&, const Version& v);
0065 };
0066
0067 inline std::ostream& operator<<(std::ostream& os, const Version& v) {
0068 return os << v.major << "." << v.minor << "." << v.patch;
0069 }
0070
0071
0072 static constexpr Version build_version{podio_VERSION_MAJOR, podio_VERSION_MINOR, podio_VERSION_PATCH};
0073
0074
0075 static constexpr Version decode_version(unsigned long version) noexcept {
0076 return Version{static_cast<uint16_t>(PODIO_MAJOR_VERSION(version)),
0077 static_cast<uint16_t>(PODIO_MINOR_VERSION(version)),
0078 static_cast<uint16_t>(PODIO_PATCH_VERSION(version))};
0079 }
0080 }
0081
0082 #endif