| 1 | #ifdef HAVE_CONFIG_H |
| 2 | # include "config.h" |
| 3 | #endif |
| 4 | |
| 5 | #include "Version.hpp" |
| 6 | #include <simgear/debug/logstream.hxx> |
| 7 | #include <iostream> |
| 8 | |
| 9 | namespace yasim { |
| 10 | |
| 11 | static const std::vector<std::string> VersionStrings = { |
| 12 | "YASIM_VERSION_ORIGINAL", |
| 13 | "YASIM_VERSION_32", |
| 14 | "2017.2", |
| 15 | "2018.1", |
| 16 | "YASIM_VERSION_CURRENT", |
| 17 | }; |
| 18 | |
| 19 | Version::YASIM_VERSION Version::getByName(const std::string& name) |
| 20 | { |
| 21 | auto it = std::find(VersionStrings.begin(), VersionStrings.end(), name); |
| 22 | if (it == VersionStrings.end()) { |
| 23 | SG_LOG(SG_FLIGHT,SG_ALERT,"Unknown yasim version '" << name << "' ignored, using YASIM_VERSION_ORIGINAL"); |
| 24 | return YASIM_VERSION_ORIGINAL; |
| 25 | } |
| 26 | YASIM_VERSION v = static_cast<YASIM_VERSION>(std::distance(VersionStrings.begin(), it)); |
| 27 | if (v > YASIM_VERSION_CURRENT) return YASIM_VERSION_CURRENT; |
| 28 | else return v; |
| 29 | } |
| 30 | |
| 31 | std::string Version::getName(YASIM_VERSION v) |
| 32 | { |
| 33 | return VersionStrings.at(static_cast<int>(v)); |
| 34 | } |
| 35 | |
| 36 | void Version::setVersion( const char * version ) |
| 37 | { |
| 38 | const std::string v(version); |
| 39 | _version = getByName(v); |
| 40 | SG_LOG(SG_FLIGHT,SG_ALERT, "This aircraft uses yasim version '" << v << "' (" << _version << ")\n"); |
| 41 | } |
| 42 | |
| 43 | } // namespace yasim |