File indexing completed on 2025-11-04 09:22:23
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/ActsVersion.hpp"
0010
0011 #include <ostream>
0012 #include <string_view>
0013
0014 namespace Acts {
0015
0016 VersionInfo::VersionInfo(unsigned int majorIn, unsigned int minorIn,
0017 unsigned int patchIn,
0018 std::optional<std::string_view> commitHashIn)
0019 : versionMajor(majorIn),
0020 versionMinor(minorIn),
0021 versionPatch(patchIn),
0022 commitHash(commitHashIn) {}
0023
0024 VersionInfo VersionInfo::fromLibrary() {
0025
0026
0027 return VersionInfo{VersionMajor, VersionMinor, VersionPatch, std::nullopt};
0028 }
0029
0030 bool VersionInfo::operator==(const VersionInfo& other) const {
0031 return versionMajor == other.versionMajor &&
0032 versionMinor == other.versionMinor &&
0033 versionPatch == other.versionPatch && commitHash == other.commitHash;
0034 }
0035
0036 VersionInfo VersionInfo::withoutCommit() const {
0037 auto copy = *this;
0038 copy.commitHash = std::nullopt;
0039 return copy;
0040 }
0041
0042 std::ostream& operator<<(std::ostream& os, const VersionInfo& vi) {
0043 os << vi.versionMajor << "." << vi.versionMinor << "." << vi.versionPatch;
0044 constexpr static std::string_view s_unknown = "UNKNOWN";
0045 if (vi.commitHash) {
0046 os << " (commit " << vi.commitHash.value_or(s_unknown) << ")";
0047 }
0048 return os;
0049 }
0050 }