|
| 1 | +/** |
| 2 | + * @file ElementsKernel/Project.h |
| 3 | + * @brief Defines tools to describe the current project |
| 4 | + * @date May 14, 2020 |
| 5 | + * @author Hubert Degaudenzi |
| 6 | + * |
| 7 | + * @copyright 2012-2020 Euclid Science Ground Segment |
| 8 | + * |
| 9 | + * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General |
| 10 | + * Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) |
| 11 | + * any later version. |
| 12 | + * |
| 13 | + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
| 14 | + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
| 15 | + * details. |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to |
| 18 | + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | + * |
| 20 | + */ |
| 21 | + |
| 22 | +/** |
| 23 | + * @addtogroup ElementsKernel ElementsKernel |
| 24 | + * @{ |
| 25 | + */ |
| 26 | + |
| 27 | + |
| 28 | +#ifndef ELEMENTSKERNEL_ELEMENTSKERNEL_PROJECT_H_ |
| 29 | +#define ELEMENTSKERNEL_ELEMENTSKERNEL_PROJECT_H_ |
| 30 | + |
| 31 | +#include <string> // for string |
| 32 | +#include <vector> // for vector |
| 33 | +#include <cstdint> // for uing_least64_t |
| 34 | +#include <iostream> // for ostream |
| 35 | +#include <algorithm> // for for_each |
| 36 | + |
| 37 | +#include "ThisProject.h" // local project constants generated |
| 38 | + // by the build system |
| 39 | + |
| 40 | +namespace Elements { |
| 41 | + |
| 42 | +struct Project { |
| 43 | + static inline std::string name() { |
| 44 | + return THIS_PROJECT_NAME_STRING; |
| 45 | + } |
| 46 | + |
| 47 | + static inline std::string versionString() { |
| 48 | + return THIS_PROJECT_VERSION_STRING; |
| 49 | + } |
| 50 | + static inline std::uint_least64_t version() { |
| 51 | + return THIS_PROJECT_VERSION; |
| 52 | + } |
| 53 | + static inline std::uint_least64_t majorVersion() { |
| 54 | + return THIS_PROJECT_MAJOR_VERSION; |
| 55 | + } |
| 56 | + static inline std::uint_least64_t minorVersion() { |
| 57 | + return THIS_PROJECT_MINOR_VERSION; |
| 58 | + } |
| 59 | + static inline std::uint_least64_t patchVersion() { |
| 60 | + return THIS_PROJECT_PATCH_VERSION; |
| 61 | + } |
| 62 | + static inline std::string originalVersion() { |
| 63 | + return THIS_PROJECT_ORIGINAL_VERSION; |
| 64 | + } |
| 65 | + static inline std::string vcsVersion() { |
| 66 | + return THIS_PROJECT_VCS_VERSION; |
| 67 | + } |
| 68 | + |
| 69 | + static inline std::string installLocation() { |
| 70 | + return THIS_PROJECT_INSTALL_LOCATION_STRING; |
| 71 | + } |
| 72 | + static inline bool useSoVersion() { |
| 73 | + return THIS_PROJECT_USE_SOVERSION; |
| 74 | + } |
| 75 | + static inline std::string installPrefix() { |
| 76 | + return CMAKE_INSTALL_PREFIX_STRING; |
| 77 | + } |
| 78 | + static inline std::vector<std::string> searchDirectories() { |
| 79 | + return THIS_PROJECT_SEARCH_DIRS; |
| 80 | + } |
| 81 | + |
| 82 | + |
| 83 | +}; |
| 84 | + |
| 85 | +inline std::ostream& operator<<(std::ostream& stream, const Project& p) { |
| 86 | + stream << "Name: " << p.name() << std::endl; |
| 87 | + stream << "Version String: " << p.versionString() << std::endl; |
| 88 | + stream << "Version: " << p.version() << std::endl; |
| 89 | + stream << "Major Version: " << p.majorVersion() << std::endl; |
| 90 | + stream << "Minor Version: " << p.minorVersion() << std::endl; |
| 91 | + stream << "Patch Version: " << p.patchVersion() << std::endl; |
| 92 | + stream << "Original Version: " << p.originalVersion() << std::endl; |
| 93 | + stream << "VCS Version: " << p.vcsVersion() << std::endl; |
| 94 | + stream << "Install Location: " << p.installLocation() << std::endl; |
| 95 | + stream << "Use So Version: " << p.useSoVersion() << std::endl; |
| 96 | + stream << "Install Prefix: " << p.installPrefix() << std::endl; |
| 97 | + stream << "Search Directories: "; |
| 98 | + |
| 99 | + for (const auto& d : p.searchDirectories()) { |
| 100 | + stream << d << " "; |
| 101 | + } |
| 102 | + |
| 103 | + return stream; |
| 104 | +} |
| 105 | + |
| 106 | +} // namespace Elements |
| 107 | + |
| 108 | +#endif // ELEMENTSKERNEL_ELEMENTSKERNEL_PROJECT_H_ |
| 109 | + |
| 110 | +/**@}*/ |
0 commit comments