torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DottedVersion.hpp
Go to the documentation of this file.
1 // Torc - Copyright 2011-2013 University of Southern California. All Rights Reserved.
2 // $HeadURL$
3 // $Id$
4 
5 // This program is free software: you can redistribute it and/or modify it under the terms of the
6 // GNU General Public License as published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
11 // the GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License along with this program. If
14 // not, see <http://www.gnu.org/licenses/>.
15 
16 /// \file
17 /// \brief Header for the DottedVersion class.
18 
19 #ifndef TORC_COMMON_DOTTEDVERSION_HPP
20 #define TORC_COMMON_DOTTEDVERSION_HPP
21 
22 #include <boost/cstdint.hpp>
23 
24 namespace torc {
25 namespace common {
26 
27  /// \brief Encapsulation of dotted decimal DottedVersion numbers.
28  struct DottedVersion {
29  typedef boost::uint8_t uint8_t;
34  // constructors
35  DottedVersion(uint8_t inMajor = 0, uint8_t inMinor = 0, uint8_t inRevision = 0,
36  uint8_t inReserved = 0) : mMajor(inMajor), mMinor(inMinor), mRevision(inRevision),
37  mReserved(inReserved) {}
38  // operators
39  bool operator ==(const DottedVersion& rhs) const {
40  return mMajor == rhs.mMajor && mMinor == rhs.mMinor && mRevision == rhs.mRevision;
41  }
42  bool operator >(const DottedVersion& rhs) const {
43  if(mMajor > rhs.mMajor) return true;
44  if(mMajor < rhs.mMajor) return false;
45  if(mMinor > rhs.mMinor) return true;
46  if(mMinor < rhs.mMinor) return false;
47  if(mRevision > rhs.mRevision) return true;
48  return false;
49  }
50  bool operator >=(const DottedVersion& rhs) const {
51  if(mMajor < rhs.mMajor) return false;
52  if(mMajor > rhs.mMajor) return true;
53  if(mMinor < rhs.mMinor) return false;
54  if(mMinor > rhs.mMinor) return true;
55  if(mRevision < rhs.mRevision) return false;
56  return true;
57  }
58  bool operator <(const DottedVersion& rhs) const {
59  if(mMajor < rhs.mMajor) return true;
60  if(mMajor > rhs.mMajor) return false;
61  if(mMinor < rhs.mMinor) return true;
62  if(mMinor > rhs.mMinor) return false;
63  if(mRevision < rhs.mRevision) return true;
64  return false;
65  }
66  bool operator <=(const DottedVersion& rhs) const {
67  if(mMajor > rhs.mMajor) return false;
68  if(mMajor < rhs.mMajor) return true;
69  if(mMinor > rhs.mMinor) return false;
70  if(mMinor > rhs.mMinor) return true;
71  if(mRevision > rhs.mRevision) return false;
72  return true;
73  }
74  };
75 
76 } // namespace common
77 } // namespace torc
78 
79 #endif // TORC_COMMON_DOTTEDVERSION_HPP
bool operator==(const DottedVersion &rhs) const
bool operator>(const DottedVersion &rhs) const
bool operator<(const DottedVersion &rhs) const
bool operator<=(const DottedVersion &rhs) const
Encapsulation of dotted decimal DottedVersion numbers.
bool operator>=(const DottedVersion &rhs) const
DottedVersion(uint8_t inMajor=0, uint8_t inMinor=0, uint8_t inRevision=0, uint8_t inReserved=0)