Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
version.h
Go to the documentation of this file.
1 /*
2  This file is part of Mitsuba, a physically based rendering system.
3 
4  Copyright (c) 2007-2014 by Wenzel Jakob and others.
5 
6  Mitsuba is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License Version 3
8  as published by the Free Software Foundation.
9 
10  Mitsuba is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #pragma once
20 #if !defined(__MITSUBA_CORE_VERSION_H_)
21 #define __MITSUBA_CORE_VERSION_H_
22 
24 
25 /**
26  * \brief Current release of Mitsuba
27  * \ingroup libcore
28  */
29 #define MTS_VERSION "0.5.0"
30 
31 /**
32  * \brief Year of the current release
33  * \ingroup libcore
34  */
35 #define MTS_YEAR "2014"
36 
37 /**
38  * \brief A simple data structure for representing and
39  * comparing Mitsuba version strings
40  *
41  * \ingroup libcore
42  */
44 public:
45  /// Default constructor: initialize to an invalid version (0.0.0)
46  inline Version() : m_major(0), m_minor(0), m_release(0) { }
47 
48  /// Initialize with the specified version number
49  inline Version(int major, int minor, int release)
50  : m_major(major), m_minor(minor), m_release(release) { }
51 
52  /**
53  * \brief Parse a version string of the form "major.minor.release"
54  * and turn it into a \ref Version structure
55  */
56  Version(const std::string &versionString);
57 
58  /// Check if this program version is \a older than \c other
59  inline bool operator<(const Version &other) const {
60  if (m_major < other.m_major)
61  return true;
62  else if (m_major > other.m_major)
63  return false;
64  else if (m_minor < other.m_minor)
65  return true;
66  else if (m_minor > other.m_minor)
67  return false;
68  else if (m_release < other.m_release)
69  return true;
70  else
71  return false;
72  }
73 
74  /// Check if this program version is \a older than or equal to \c other
75  inline bool operator<=(const Version &other) const {
76  return *this < other || *this == other;
77  }
78 
79  /// Check if two program versions match
80  inline bool operator==(const Version &other) const {
81  return m_major == other.m_major
82  && m_minor == other.m_minor
83  && m_release == other.m_release;
84  }
85 
86  /// Is this a valid version number?
87  inline bool isValid() {
88  return m_major != 0 || m_minor != 0 || m_release != 0;
89  }
90 
91  /// Are the following two versions compatible?
92  inline bool isCompatible(const Version &other) const {
93  return m_major == other.m_major &&
94  m_minor == other.m_minor;
95  }
96 
97  /// Turn into a string of the form "major.minor.release"
98  std::string toString() const;
99 
100  /// Turn into a string of the form "major.minor.release (Architecture)"
101  std::string toStringComplete() const;
102 
103  /// Return the major version
104  inline int getMajorVersion() const { return m_major; }
105 
106  /// Return the minor version
107  inline int getMinorVersion() const { return m_minor; }
108 
109  /// Return the release
110  inline int getRelease() const { return m_release; }
111 private:
112  int m_major;
113  int m_minor;
114  int m_release;
115 };
116 
118 
119 #endif /* __MITSUBA_CORE_VERSION_H_ */
bool operator<(const Version &other) const
Check if this program version is older than other.
Definition: version.h:59
bool isCompatible(const Version &other) const
Are the following two versions compatible?
Definition: version.h:92
int getRelease() const
Return the release.
Definition: version.h:110
#define MTS_EXPORT_CORE
Definition: getopt.h:29
#define MTS_NAMESPACE_BEGIN
Definition: platform.h:137
Version(int major, int minor, int release)
Initialize with the specified version number.
Definition: version.h:49
int getMinorVersion() const
Return the minor version.
Definition: version.h:107
bool isValid()
Is this a valid version number?
Definition: version.h:87
bool operator<=(const Version &other) const
Check if this program version is older than or equal to other.
Definition: version.h:75
int getMajorVersion() const
Return the major version.
Definition: version.h:104
Version()
Default constructor: initialize to an invalid version (0.0.0)
Definition: version.h:46
#define MTS_NAMESPACE_END
Definition: platform.h:138
A simple data structure for representing and comparing Mitsuba version strings.
Definition: version.h:43
bool operator==(const Version &other) const
Check if two program versions match.
Definition: version.h:80