Project
Loading...
Searching...
No Matches
ANSHeader.h
Go to the documentation of this file.
1// Copyright 2019-2023 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
15
16#ifndef _ALICEO2_ANSHEADER_H_
17#define _ALICEO2_ANSHEADER_H_
18
19#include <cstdint>
20#include <string>
21#include <Rtypes.h>
22#include <fmt/format.h>
23
24namespace o2::ctf
25{
26
27struct ANSHeader {
28 uint8_t majorVersion;
29 uint8_t minorVersion;
30
32 inline constexpr operator uint16_t() const noexcept
33 {
34 uint16_t major = majorVersion;
35 uint16_t minor = minorVersion;
36 return (major << 8) | minor;
37 };
38
39 inline operator std::string() const
40 {
41 return fmt::format("{}.{}", majorVersion, minorVersion);
42 };
43 inline constexpr uint32_t version() const noexcept { return static_cast<uint16_t>(*this); };
44 inline constexpr bool operator==(const ANSHeader& other) const noexcept { return static_cast<uint16_t>(*this) == static_cast<uint16_t>(other); };
45 inline constexpr bool operator!=(const ANSHeader& other) const noexcept { return static_cast<uint16_t>(*this) != static_cast<uint16_t>(other); };
46 inline constexpr bool operator<(const ANSHeader& other) const noexcept { return static_cast<uint16_t>(*this) < static_cast<uint16_t>(other); };
47 inline constexpr bool operator>(const ANSHeader& other) const noexcept { return static_cast<uint16_t>(*this) > static_cast<uint16_t>(other); };
48 inline constexpr bool operator>=(const ANSHeader& other) const noexcept { return static_cast<uint16_t>(*this) >= static_cast<uint16_t>(other); };
49 inline constexpr bool operator<=(const ANSHeader& other) const noexcept { return static_cast<uint16_t>(*this) <= static_cast<uint16_t>(other); };
51};
52
53inline constexpr ANSHeader ANSVersionUnspecified{0, 0};
54inline constexpr ANSHeader ANSVersionCompat{0, 1};
55inline constexpr ANSHeader ANSVersion1{1, 0};
56
57inline ANSHeader ansVersionFromString(const std::string& ansVersionString)
58{
59 if (ansVersionString == "0.1" || ansVersionString == "compat") {
61 } else if (ansVersionString == "1.0") {
62 return ctf::ANSVersion1;
63 } else {
65 }
66}
67
68} // namespace o2::ctf
69
70#endif /* _ALICEO2_ANSHEADER_H_ */
uint32_t minor
Definition RawData.h:6
uint32_t major
Definition RawData.h:7
pair of input and output size
Definition ANSHeader.h:25
ANSHeader ansVersionFromString(const std::string &ansVersionString)
Definition ANSHeader.h:57
constexpr ANSHeader ANSVersionCompat
Definition ANSHeader.h:54
constexpr ANSHeader ANSVersion1
Definition ANSHeader.h:55
constexpr ANSHeader ANSVersionUnspecified
Definition ANSHeader.h:53
ClassDefNV(ANSHeader, 2)
constexpr bool operator!=(const ANSHeader &other) const noexcept
Definition ANSHeader.h:45
constexpr bool operator<(const ANSHeader &other) const noexcept
Definition ANSHeader.h:46
constexpr uint32_t version() const noexcept
Definition ANSHeader.h:43
constexpr bool operator<=(const ANSHeader &other) const noexcept
Definition ANSHeader.h:49
uint8_t majorVersion
Definition ANSHeader.h:28
constexpr bool operator>=(const ANSHeader &other) const noexcept
Definition ANSHeader.h:48
uint8_t minorVersion
Definition ANSHeader.h:29
constexpr bool operator>(const ANSHeader &other) const noexcept
Definition ANSHeader.h:47
constexpr bool operator==(const ANSHeader &other) const noexcept
Definition ANSHeader.h:44
VectorOfTObjectPtrs other