Skip to content

iceoryx_posh/version/version_info.hpp🔗

Source code🔗

// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0
#ifndef IOX_POSH_VERSION_VERSION_INFO_HPP
#define IOX_POSH_VERSION_VERSION_INFO_HPP

#include "iceoryx_hoofs/cxx/helplets.hpp"
#include "iceoryx_hoofs/cxx/serialization.hpp"
#include "iceoryx_hoofs/cxx/string.hpp"
#include "iceoryx_posh/iceoryx_posh_types.hpp"
#include "iceoryx_posh/version/compatibility_check_level.hpp"
#include "iceoryx_versions.hpp"

#include <cstdint>

namespace iox
{
namespace version
{
class VersionInfo
{
  public:
    VersionInfo(const uint16_t versionMajor,
                const uint16_t versionMinor,
                const uint16_t versionPatch,
                const uint16_t versionTweak,
                const BuildDateString_t& buildDateString,
                const CommitIdString_t& commitIdString) noexcept;

    VersionInfo(const cxx::Serialization& serial) noexcept;

    operator cxx::Serialization() const noexcept;

    bool operator==(const VersionInfo& rhs) const noexcept;

    bool operator!=(const VersionInfo& rhs) const noexcept;

    bool checkCompatibility(const VersionInfo& other,
                            const CompatibilityCheckLevel compatibilityCheckLevel) const noexcept;

    bool isValid() noexcept;

    static VersionInfo getCurrentVersion() noexcept;

  protected:
    static const uint64_t SERIALIZATION_STRING_SIZE = 100u;
    using SerializationString_t = cxx::string<SERIALIZATION_STRING_SIZE>;

    static_assert(COMMIT_ID_STRING_SIZE <= SERIALIZATION_STRING_SIZE, "CommitId needs to transfered completely.");
    static_assert(COMMIT_ID_STRING_SIZE <= BUILD_DATE_STRING_SIZE, "BuildDate needs to transfered completely.");
    static_assert(cxx::strlen2(ICEORYX_BUILDDATE) < BUILD_DATE_STRING_SIZE,
                  "COMMIT_BUILD_DATE_STRING_SIZE needs to be bigger.");

  protected:
    bool m_valid{true};
    uint16_t m_versionMajor{0u};
    uint16_t m_versionMinor{0u};
    uint16_t m_versionPatch{0u};
    uint16_t m_versionTweak{0u};
    BuildDateString_t m_buildDateString;
    CommitIdString_t m_commitIdString;
};

} // namespace version
} // namespace iox
#endif // IOX_POSH_VERSION_VERSION_INFO_HPP

Updated on 2 April 2022 at 16:37:47 CEST