IDS peak genericC++  v1.7.1
peak_version.hpp
Go to the documentation of this file.
1 
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 
22 namespace peak
23 {
24 namespace core
25 {
26 
33 class Version final
34 {
35 public:
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 
78 private:
79  uint32_t m_major;
80  uint32_t m_minor;
81  uint32_t m_subminor;
82 };
83 
84 bool operator<(const Version& lhs, const Version& rhs);
85 bool operator>(const Version& lhs, const Version& rhs);
86 bool operator==(const Version& lhs, const Version& rhs);
87 bool operator!=(const Version& lhs, const Version& rhs);
88 
89 } /* namespace core */
90 } /* namespace peak */
91 
92 /* Implementation */
93 namespace peak
94 {
95 namespace core
96 {
97 
98 inline 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 
104 inline std::string Version::ToString() const
105 {
106  std::stringstream strStream;
107 
108  strStream << Major() << '.' << Minor() << '.' << Subminor();
109 
110  return strStream.str();
111 }
112 
113 inline uint32_t Version::Major() const
114 {
115  return m_major;
116 }
117 
118 inline uint32_t Version::Minor() const
119 {
120  return m_minor;
121 }
122 
123 inline uint32_t Version::Subminor() const
124 {
125  return m_subminor;
126 }
127 
128 inline 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 
146 inline bool operator>(const Version& lhs, const Version& rhs)
147 {
148  return rhs < lhs;
149 }
150 
151 inline bool operator==(const Version& lhs, const Version& rhs)
152 {
153  return !(lhs < rhs) && !(lhs > rhs);
154 }
155 
156 inline 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:33
bool operator==(const Version &lhs, const Version &rhs)
Definition: peak_version.hpp:151
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
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition: peak_dynamic_loader.h:32
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
Version & operator=(const 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
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
std::string ToString() const
Returns the version as string.
Definition: peak_version.hpp:104