IDS peak genericC++  v1.4.3
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;
57  uint32_t Major() const;
65  uint32_t Minor() const;
73  uint32_t Subminor() const;
74 
75 private:
76  uint32_t m_major;
77  uint32_t m_minor;
78  uint32_t m_subminor;
79 };
80 
81 bool operator<(const Version& lhs, const Version& rhs);
82 bool operator>(const Version& lhs, const Version& rhs);
83 bool operator==(const Version& lhs, const Version& rhs);
84 bool operator!=(const Version& lhs, const Version& rhs);
85 
86 } /* namespace core */
87 } /* namespace peak */
88 
89 /* Implementation */
90 namespace peak
91 {
92 namespace core
93 {
94 
95 inline Version::Version(uint32_t major, uint32_t minor, uint32_t subminor)
96  : m_major(major)
97  , m_minor(minor)
98  , m_subminor(subminor)
99 {}
100 
101 inline std::string Version::ToString() const
102 {
103  std::stringstream strStream;
104 
105  strStream << Major() << '.' << Minor() << '.' << Subminor();
106 
107  return strStream.str();
108 }
109 
110 inline uint32_t Version::Major() const
111 {
112  return m_major;
113 }
114 
115 inline uint32_t Version::Minor() const
116 {
117  return m_minor;
118 }
119 
120 inline uint32_t Version::Subminor() const
121 {
122  return m_subminor;
123 }
124 
125 inline bool operator<(const Version& lhs, const Version& rhs)
126 {
127  if (lhs.Major() < rhs.Major())
128  {
129  return true;
130  }
131  else if (lhs.Minor() < rhs.Minor())
132  {
133  return true;
134  }
135  else if (lhs.Subminor() < rhs.Subminor())
136  {
137  return true;
138  }
139 
140  return false;
141 }
142 
143 inline bool operator>(const Version& lhs, const Version& rhs)
144 {
145  return rhs < lhs;
146 }
147 
148 inline bool operator==(const Version& lhs, const Version& rhs)
149 {
150  return !(lhs < rhs) && !(lhs > rhs);
151 }
152 
153 inline bool operator!=(const Version& lhs, const Version& rhs)
154 {
155  return !(lhs == rhs);
156 }
157 
158 } /* namespace core */
159 } /* namespace peak */
Implements versioning functionality.
Definition: peak_version.hpp:33
bool operator==(const Version &lhs, const Version &rhs)
Definition: peak_version.hpp:148
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:110
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:125
bool operator>(const Version &lhs, const Version &rhs)
Definition: peak_version.hpp:143
bool operator!=(const Version &lhs, const Version &rhs)
Definition: peak_version.hpp:153
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:115
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:120
std::string ToString() const
Returns the version as string.
Definition: peak_version.hpp:101