| 1 | // |
| 2 | // fg_init.hxx -- Flight Gear top level initialization routines |
| 3 | // |
| 4 | // Written by Curtis Olson, started August 1997. |
| 5 | // |
| 6 | // Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt |
| 7 | // |
| 8 | // This program is free software; you can redistribute it and/or |
| 9 | // modify it under the terms of the GNU General Public License as |
| 10 | // published by the Free Software Foundation; either version 2 of the |
| 11 | // License, or (at your option) any later version. |
| 12 | // |
| 13 | // This program is distributed in the hope that it will be useful, but |
| 14 | // WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | // General Public License for more details. |
| 17 | // |
| 18 | // You should have received a copy of the GNU General Public License |
| 19 | // along with this program; if not, write to the Free Software |
| 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 21 | // |
| 22 | // $Id$ |
| 23 | |
| 24 | |
| 25 | #ifndef _FG_INIT_HXX |
| 26 | #define _FG_INIT_HXX |
| 27 | |
| 28 | #include <string> |
| 29 | #include <optional> |
| 30 | |
| 31 | #include <simgear/misc/sg_path.hxx> |
| 32 | |
| 33 | // forward decls |
| 34 | class SGPropertyNode; |
| 35 | class SGPath; |
| 36 | |
| 37 | // Return the current base package version |
| 38 | std::string fgBasePackageVersion(const SGPath& path); |
| 39 | |
| 40 | /** |
| 41 | * @brief structure holding parsed info from <base-package>/base_package.json |
| 42 | * |
| 43 | */ |
| 44 | struct FGBasePackageInfo { |
| 45 | std::string version; |
| 46 | std::string suffix; |
| 47 | std::string buildDate; |
| 48 | std::string gitRevision; |
| 49 | }; |
| 50 | |
| 51 | /** |
| 52 | * @brief Parse the base package info JSON |
| 53 | * |
| 54 | * @param path |
| 55 | * @return std::optional<FGBasePackageInfo> |
| 56 | */ |
| 57 | std::optional<FGBasePackageInfo> |
| 58 | fgBasePackageInfo(const SGPath& path); |
| 59 | |
| 60 | SGPath fgHomePath(); |
| 61 | |
| 62 | enum InitHomeResult |
| 63 | { |
| 64 | InitHomeOkay, |
| 65 | InitHomeReadOnly, |
| 66 | InitHomeExplicitReadOnly, |
| 67 | InitHomeAbort |
| 68 | }; |
| 69 | |
| 70 | InitHomeResult fgInitHome(int argc, char** argv); |
| 71 | void fgShutdownHome(); |
| 72 | void fgDeleteLockFile(); |
| 73 | |
| 74 | void fgInitLogging(const std::string& pri); |
| 75 | |
| 76 | // Read in configuration (file and command line) |
| 77 | int fgInitConfig ( int argc, char **argv, bool reinit ); |
| 78 | |
| 79 | void fgInitAircraftPaths(bool reinit); |
| 80 | |
| 81 | /** |
| 82 | * @brief |
| 83 | * |
| 84 | * @param reinit : is this a second(+) call of the function, i.e after reset |
| 85 | * @param didUseLauncher : allow adjusting UI feedback if we used the launcher or not |
| 86 | * @return int : an Options result to indicate if we should continue, quit, etc |
| 87 | */ |
| 88 | int fgInitAircraft(bool reinit, bool didUseLauncher); |
| 89 | |
| 90 | // log various settings / configuration state |
| 91 | void fgOutputSettings(); |
| 92 | |
| 93 | // Initialize the localization |
| 94 | SGPropertyNode *fgInitLocale(const char *language); |
| 95 | |
| 96 | // Init navaids and waypoints |
| 97 | bool fgInitNav (); |
| 98 | |
| 99 | |
| 100 | // General house keeping initializations |
| 101 | bool fgInitGeneral (); |
| 102 | |
| 103 | |
| 104 | // Create all the subsystems needed by the sim |
| 105 | void fgCreateSubsystems(bool duringReset); |
| 106 | |
| 107 | // called after the subsystems have been bound and initialised, |
| 108 | // to peform final init |
| 109 | void fgPostInitSubsystems(); |
| 110 | |
| 111 | // Re-position: when only location is changing, we can do considerably |
| 112 | // less work than a full re-init. |
| 113 | void fgStartReposition(); |
| 114 | |
| 115 | void fgStartNewReset(); |
| 116 | |
| 117 | // setup the package system including the global root |
| 118 | void fgInitPackageRoot(); |
| 119 | |
| 120 | // wipe FG_HOME. (The removing of the program data is assumed to be done |
| 121 | // by the real installer). |
| 122 | int fgUninstall(); |
| 123 | |
| 124 | #endif // _FG_INIT_HXX |
| 125 | |
| 126 | |
| 127 |