iceoryx_posh 2.0.5
Loading...
Searching...
No Matches
version_info.hpp
1// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// SPDX-License-Identifier: Apache-2.0
16#ifndef IOX_POSH_VERSION_VERSION_INFO_HPP
17#define IOX_POSH_VERSION_VERSION_INFO_HPP
18
19#include "iceoryx_hoofs/cxx/helplets.hpp"
20#include "iceoryx_hoofs/cxx/serialization.hpp"
21#include "iceoryx_hoofs/cxx/string.hpp"
22#include "iceoryx_posh/iceoryx_posh_types.hpp"
23#include "iceoryx_posh/version/compatibility_check_level.hpp"
24#include "iceoryx_versions.hpp"
25
26#include <cstdint>
27
28namespace iox
29{
30namespace version
31{
33class VersionInfo
34{
35 public:
44 VersionInfo(const uint16_t versionMajor,
45 const uint16_t versionMinor,
46 const uint16_t versionPatch,
47 const uint16_t versionTweak,
48 const BuildDateString_t& buildDateString,
49 const CommitIdString_t& commitIdString) noexcept;
50
53 VersionInfo(const cxx::Serialization& serial) noexcept;
54
56 operator cxx::Serialization() const noexcept;
57
60 bool operator==(const VersionInfo& rhs) const noexcept;
61
64 bool operator!=(const VersionInfo& rhs) const noexcept;
65
69 bool checkCompatibility(const VersionInfo& other,
70 const CompatibilityCheckLevel compatibilityCheckLevel) const noexcept;
71
74 bool isValid() noexcept;
75
78 static VersionInfo getCurrentVersion() noexcept;
79
80 protected:
81 static const uint64_t SERIALIZATION_STRING_SIZE = 100u;
82 using SerializationString_t = cxx::string<SERIALIZATION_STRING_SIZE>;
83
84 static_assert(COMMIT_ID_STRING_SIZE <= SERIALIZATION_STRING_SIZE, "CommitId needs to transfered completely.");
85 static_assert(COMMIT_ID_STRING_SIZE <= BUILD_DATE_STRING_SIZE, "BuildDate needs to transfered completely.");
86 static_assert(cxx::strlen2(ICEORYX_BUILDDATE) < BUILD_DATE_STRING_SIZE,
87 "COMMIT_BUILD_DATE_STRING_SIZE needs to be bigger.");
88
89 protected:
90 bool m_valid{true};
91 uint16_t m_versionMajor{0u};
92 uint16_t m_versionMinor{0u};
93 uint16_t m_versionPatch{0u};
94 uint16_t m_versionTweak{0u};
95 BuildDateString_t m_buildDateString;
96 CommitIdString_t m_commitIdString;
97};
98
99} // namespace version
100} // namespace iox
101#endif // IOX_POSH_VERSION_VERSION_INFO_HPP