Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-04 09:22:23

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
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   // this is filled by the Core shared library
0026   // while the constants below depend on the include
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 }  // namespace Acts