IDS peak genericC++ v1.11.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
33class Version final
34{
35public:
36 Version() = delete;
37 Version(uint32_t major, uint32_t minor, uint32_t subminor);
38 ~Version() = default;
39 Version(const Version& other) = default;
40 Version& operator=(const Version& other) = default;
41 Version(Version&& other) = default;
42 Version& operator=(Version&& other) = default;
43
49 std::string ToString() const;
50
58 uint32_t Major() const;
59
67 uint32_t Minor() const;
68
76 uint32_t Subminor() const;
77
78private:
79 uint32_t m_major;
80 uint32_t m_minor;
81 uint32_t m_subminor;
82};
83
84bool operator<(const Version& lhs, const Version& rhs);
85bool operator>(const Version& lhs, const Version& rhs);
86bool operator==(const Version& lhs, const Version& rhs);
87bool operator!=(const Version& lhs, const Version& rhs);
88
89} /* namespace core */
90} /* namespace peak */
91
92/* Implementation */
93namespace peak
94{
95namespace core
96{
97
98inline Version::Version(uint32_t major, uint32_t minor, uint32_t subminor)
99 : m_major(major)
100 , m_minor(minor)
101 , m_subminor(subminor)
102{}
103
104inline std::string Version::ToString() const
105{
106 std::stringstream strStream;
107
108 strStream << Major() << '.' << Minor() << '.' << Subminor();
109
110 return strStream.str();
111}
112
113inline uint32_t Version::Major() const
114{
115 return m_major;
116}
117
118inline uint32_t Version::Minor() const
119{
120 return m_minor;
121}
122
123inline uint32_t Version::Subminor() const
124{
125 return m_subminor;
126}
127
128inline bool operator<(const Version& lhs, const Version& rhs)
129{
130 if (lhs.Major() < rhs.Major())
131 {
132 return true;
133 }
134 else if (lhs.Minor() < rhs.Minor())
135 {
136 return true;
137 }
138 else if (lhs.Subminor() < rhs.Subminor())
139 {
140 return true;
141 }
142
143 return false;
144}
145
146inline bool operator>(const Version& lhs, const Version& rhs)
147{
148 return rhs < lhs;
149}
150
151inline bool operator==(const Version& lhs, const Version& rhs)
152{
153 return !(lhs < rhs) && !(lhs > rhs);
154}
155
156inline bool operator!=(const Version& lhs, const Version& rhs)
157{
158 return !(lhs == rhs);
159}
160
161} /* namespace core */
162} /* namespace peak */
Implements versioning functionality.
Definition peak_version.hpp:34
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:113
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:123
Version & operator=(Version &&other)=default
std::string ToString() const
Returns the version as string.
Definition peak_version.hpp:104
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:118
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:31
bool operator<(const Version &lhs, const Version &rhs)
Definition peak_version.hpp:128
bool operator>(const Version &lhs, const Version &rhs)
Definition peak_version.hpp:146
bool operator!=(const Version &lhs, const Version &rhs)
Definition peak_version.hpp:156
bool operator==(const Version &lhs, const Version &rhs)
Definition peak_version.hpp:151
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition peak_dynamic_loader.h:33