Falaise  4.0.1
SuperNEMO Software Toolkit
version.h
Go to the documentation of this file.
1 //! \file falaise/version.h
2 //! \brief Describe the Falaise API version
3 //! \details Querying the version of Falaise is needed at both
4 //! compile and runtime by clients so that they may adjust
5 //! their usage.
6 //
7 // Copyright (c) 2013 by Ben Morgan <bmorgan.warwick@gmail.com>
8 // Copyright (c) 2013 by The University of Warwick
9 //
10 // This file is part of Falaise.
11 //
12 // Falaise is free software: you can redistribute it and/or modify
13 // it under the terms of the GNU General Public License as published by
14 // the Free Software Foundation, either version 3 of the License, or
15 // (at your option) any later version.
16 //
17 // Falaise is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with Falaise. If not, see <http://www.gnu.org/licenses/>.
24 
25 #ifndef FALAISE_VERSION_H
26 #define FALAISE_VERSION_H
27 // Standard Library
28 #include <string>
29 
30 // Third Party
31 // - A
32 
33 // This Project
34 
35 // - Make sure clang-format ignores generated code/macros
36 // clang-format off
37 
38 //----------------------------------------------------------------------
39 // - Compile Time API
40 //! Major version number of falaise
41 #define FALAISE_VERSION_MAJOR 4
42 
43 //! Minor version number of falaise
44 #define FALAISE_VERSION_MINOR 0
45 
46 //! Patch version number of falaise
47 #define FALAISE_VERSION_PATCH 1
48 
49 //! Current revision/build number of falaise, 0 for a release
50 //! \deprecated Since 3.1
51 //! \see FALAISE_VERSION_COMMIT
52 #define FALAISE_VERSION_REVISION -1
53 
54 //! First 8 characters of the current Git HEAD hash, empty outside a working
55 // copy.
56 #define FALAISE_VERSION_COMMIT "d63b6200"
57 
58 //! Defined if this build has uncommited changes
59 #define FALAISE_VERSION_IS_DIRTY 0
60 
61 //! Encode falaise to ordered integer available at compile time
62 #define FALAISE_ENCODE_VERSION(major, minor, patch) ( \
63  ((major) * 10000) \
64  + ((minor) * 100) \
65  + ((patch) * 1))
66 
67 //! Integer encoded falaise version available at compile time
68 #define FALAISE_VERSION FALAISE_ENCODE_VERSION( \
69  FALAISE_VERSION_MAJOR, \
70  FALAISE_VERSION_MINOR, \
71  FALAISE_VERSION_PATCH)
72 
73 //! String encoded full version number, e.g. "1.2.3", available at compile time
74 #define FALAISE_LIB_VERSION "4.0.1"
75 
76 //! Check current version >= (major, minor, patch) at compile time
77 #define FALAISE_IS_AT_LEAST(major,minor,patch) ( \
78  FALAISE_VERSION >= \
79  FALAISE_ENCODE_VERSION(major,minor,patch))
80 //clang-format on
81 
82 //----------------------------------------------------------------------
83 // Runtime API
84 namespace falaise {
85 //! \brief Describe the falaise API version and features
86 struct version {
87 //! Return the major version number of falaise, e.g., 1 for '1.2.3'
88 static int get_major();
89 
90 //! Return the minor version number of falaise, e.g., 2 for '1.2.3'
91 static int get_minor();
92 
93 //! Return the patch version number of falaise, e.g., 3 for '1.2.3'
94 static int get_patch();
95 
96 //! Return the current revision number
97 //! \deprecated since 3.1
98 //! \see get_commit()
99 static int get_revision() __attribute__((deprecated));
100 
101 //! Return the first eight characters of the current Git HEAD hash
102 static std::string get_commit();
103 
104 //! Return true when a build from Git used modified, uncommitted changes
105 static bool is_dirty();
106 
107 //! Return the full version number of falaise as a string, e.g., '1.2.3'
108 static std::string get_version();
109 
110 //! Return true if the current falaise version >= (major, minor, patch)
111 static bool is_at_least(int major, int minor, int patch);
112 
113 //! Return true if the named feature is available in falaise
114 static bool has_feature(const std::string& feature);
115 };
116 } // namespace falaise
117 
118 #endif // FALAISE_VERSION_H
119 
Describe the falaise API version and features.
Definition: version.h:86
static std::string get_version()
Return the full version number of falaise as a string, e.g., '1.2.3'.
Definition: metadata_utils.h:35
static int get_patch()
Return the patch version number of falaise, e.g., 3 for '1.2.3'.
static std::string get_commit()
Return the first eight characters of the current Git HEAD hash.
static int get_minor()
Return the minor version number of falaise, e.g., 2 for '1.2.3'.
static bool has_feature(const std::string &feature)
Return true if the named feature is available in falaise.
static bool is_dirty()
Return true when a build from Git used modified, uncommitted changes.
static bool is_at_least(int major, int minor, int patch)
Return true if the current falaise version >= (major, minor, patch)
static int get_major()
Return the major version number of falaise, e.g., 1 for '1.2.3'.
static int get_revision() __attribute__((deprecated))