Use proper doxygen tags in modular simulator
[gromacs.git] / api / include / gmxapiversion.h.in
blob797717115449b8090e6fc30afd330c4fad001115
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2018,2020, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
35 #ifndef GMXAPI_VERSION_H
36 #define GMXAPI_VERSION_H
37 /*! \file
38 * \brief Implement versioning API for C++ external GROMACS interface.
40 * Defines a class Version in the gmxapi namespace providing static methods
41 * for use by API client code at compile time and run time.
43 * External interface uses semantic versioning scheme in which the major version
44 * specifies the API compatibility level, and minor version indicates additional
45 * features that may or may not be ABI compatible. Feature availability may be
46 * implied by API level, but the library can be queried for availability of
47 * explicitly named features. This is essential to allow compatibility and
48 * flexibility during development.
50 * \ingroup gmxapi
52 * \internal
53 * The version numbers for gmxapi are encoded in the repository solely in the
54 * `src/api/CMakeLists.txt` file. During CMake configuration, the
55 * `src/api/cpp/include/gmxapi/version.h` file is created so that the built library can report this
56 * version through the `gmxapi::Version` interface. Client code should include the installed `gmxapi/version.h`
57 * header in order to embed the constants `gmxapi::c_majorVersion`, `gmxapi::c_minorVersion`, and
58 * `gmxapi::c_patchVersion` so that compatibility checks can be performed at runtime. Additional
59 * CMake `check` utilities will probably be necessary to allow GROMACS installations to be forward
60 * compatible with client code developed against the GROMACS master branch.
62 * When a new software release is tagged, the next commit on the development branch should increment
63 * the patch level to distinguish development builds from the tagged release. As incompatibilities
64 * are introduced in feature branches, minor or major version number should be incremented as
65 * appropriate. At this time, client code has no indication of whether the version presented in a
66 * development build of gmxapi is an officially specified API revision or is subject to change.
67 * Developers coding against development branches should keep this in mind. If this becomes
68 * problematic, please offer your suggestions or propose a revision to the `gmxapi::Version` API.
73 #include <string>
75 namespace gmxapi
78 /*!
79 * \brief Type alias for version data type.
81 * \ingroup gmxapi
83 using version_t = int;
85 //! Major version number of gmxapi API support.
86 static constexpr const version_t c_majorVersion = @GMXAPI_MAJOR@;
87 //! Minor version number of gmxapi API support.
88 static constexpr const version_t c_minorVersion = @GMXAPI_MINOR@;
89 //! Patch level of gmxapi API support.
90 static constexpr const version_t c_patchVersion = @GMXAPI_PATCH@;
91 //! C string representation of gmxapi release.
92 static const char c_release[] = "@GMXAPI_RELEASE@";
94 /*!
95 * \brief Provide API library version information for client code.
97 * Allow client code to query the currently loaded gmxapi library object to find the built version. Provide helpers
98 * to compare against the features for which the client was written and the headers against which it was compiled.
100 * \ingroup gmxapi
102 class Version
104 public:
106 * \brief Query gmxapi major version.
108 * \returns major version number
110 static version_t majorVersion();
112 /*! \brief Query gmxapi minor version.
114 * \returns minor version number
116 static version_t minorVersion();
118 /*! \brief Query gmxapi patch level.
120 * \returns patch level number
122 static version_t patchVersion();
124 /*! \brief Get formatted release string.
126 * Format is major.minor.patch
127 * \returns release as string
129 static std::string release();
131 /*! \brief Check features availability
133 * Features may be named in the documentation
134 * to improve readability of client code and to simplify development. Prefer
135 * this mechanism when checking for features still under development or to
136 * distinguish between interface levels of a specific feature.
137 * \param featurename Feature name described in the feature's documentation.
138 * \returns `true` if the named feature is available.
140 static bool hasFeature(const std::string& featurename);
142 /*! \brief Check for sufficiently high API version number.
144 * \returns `true` if gmxapi library version is the same or greater than the argument(s).
145 * \param major gmxapi major version number.
146 * \param minor gmxapi minor version number (optional).
147 * \param patch patch level of the api library (optional).
149 static bool isAtLeast(version_t major, version_t minor = 0, version_t patch = 0);
152 } // namespace gmxapi
154 #endif // version.h include guard