IDS peak genericC++ v1.15.0
Loading...
Searching...
No Matches
peak_version.hpp
Go to the documentation of this file.
1
10
11#pragma once
12
13
15#include <peak/dll_interface/peak_dll_interface_util.hpp>
16
17#include <cstdint>
18#include <sstream>
19#include <string>
20
21
22namespace peak
23{
24namespace core
25{
26
34class Version final
35{
36public:
37 Version() = delete;
38 Version(uint32_t major, uint32_t minor, uint32_t subminor);
39 ~Version() = default;
40 Version(const Version& other) = default;
41 Version& operator=(const Version& other) = default;
42 Version(Version&& other) = default;
43 Version& operator=(Version&& other) = default;
44
50 std::string ToString() const;
51
59 uint32_t Major() const;
60
68 uint32_t Minor() const;
69
77 uint32_t Subminor() const;
78
79private:
80 uint32_t m_major;
81 uint32_t m_minor;
82 uint32_t m_subminor;
83};
84
85bool operator<(const Version& lhs, const Version& rhs);
86bool operator>(const Version& lhs, const Version& rhs);
87bool operator==(const Version& lhs, const Version& rhs);
88bool operator!=(const Version& lhs, const Version& rhs);
89
90} /* namespace core */
91} /* namespace peak */
92
93/* Implementation */
94namespace peak
95{
96namespace core
97{
98
99inline Version::Version(uint32_t major, uint32_t minor, uint32_t subminor)
100 : m_major(major)
101 , m_minor(minor)
102 , m_subminor(subminor)
103{}
104
105inline std::string Version::ToString() const
106{
107 std::stringstream strStream;
108
109 strStream << Major() << '.' << Minor() << '.' << Subminor();
110
111 return strStream.str();
112}
113
114inline uint32_t Version::Major() const
115{
116 return m_major;
117}
118
119inline uint32_t Version::Minor() const
120{
121 return m_minor;
122}
123
124inline uint32_t Version::Subminor() const
125{
126 return m_subminor;
127}
128
129inline bool operator<(const Version& lhs, const Version& rhs)
130{
131 if (lhs.Major() < rhs.Major())
132 {
133 return true;
134 }
135 else if (lhs.Minor() < rhs.Minor())
136 {
137 return true;
138 }
139 else if (lhs.Subminor() < rhs.Subminor())
140 {
141 return true;
142 }
143
144 return false;
145}
146
147inline bool operator>(const Version& lhs, const Version& rhs)
148{
149 return rhs < lhs;
150}
151
152inline bool operator==(const Version& lhs, const Version& rhs)
153{
154 return !(lhs < rhs) && !(lhs > rhs);
155}
156
157inline bool operator!=(const Version& lhs, const Version& rhs)
158{
159 return !(lhs == rhs);
160}
161
162} /* namespace core */
163} /* namespace peak */
Implements versioning functionality.
Definition peak_version.hpp:35
uint32_t Major() const
Returns the major part of the version which is the first part of the version scheme separated by dots...
Definition peak_version.hpp:114
uint32_t Subminor() const
Returns the subminor part of the version which is the third part of the version scheme separated by d...
Definition peak_version.hpp:124
Version & operator=(Version &&other)=default
std::string ToString() const
Returns the version as string.
Definition peak_version.hpp:105
Version(Version &&other)=default
uint32_t Minor() const
Returns the minor part of the version which is the second part of the version scheme separated by dot...
Definition peak_version.hpp:119
Version(const Version &other)=default
Version & operator=(const Version &other)=default
The "core" namespace contains the direct GenAPI and GenTL wrapper.
Definition peak_buffer.hpp:34
bool operator<(const Version &lhs, const Version &rhs)
Definition peak_version.hpp:129
bool operator>(const Version &lhs, const Version &rhs)
Definition peak_version.hpp:147
bool operator!=(const Version &lhs, const Version &rhs)
Definition peak_version.hpp:157
bool operator==(const Version &lhs, const Version &rhs)
Definition peak_version.hpp:152
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition peak_dynamic_loader.h:33