diff --git a/src/libs/tgf/application.cpp b/src/libs/tgf/application.cpp index e6701616a..25f026325 100644 --- a/src/libs/tgf/application.cpp +++ b/src/libs/tgf/application.cpp @@ -16,8 +16,8 @@ * * ***************************************************************************/ -/** @file - Application base +/** @file + Application base @version $Id$ @ingroup tgf */ @@ -47,499 +47,499 @@ GfApplication* GfApplication::_pSelf = 0; GfApplication& GfApplication::self() { - if (!_pSelf) - { - GfLogError("GfApplication not yet created ; exiting"); - ::exit(1); - } - - return *_pSelf; + if (!_pSelf) + { + GfLogError("GfApplication not yet created ; exiting"); + ::exit(1); + } + + return *_pSelf; } GfApplication::GfApplication(const char* pszName, const char* pszVersion, const char* pszDesc) : _strName(pszName ? pszName : "GfApplication"), _strDesc(pszDesc ? pszDesc : ""), _strVersion(pszVersion ? pszVersion : ""), _pEventLoop(0) { - // Check that we are the only instance. - if (_pSelf) - { - fprintf(stderr, "More than one GfApplication instance ; exiting\n"); - ::exit(1); - } + // Check that we are the only instance. + if (_pSelf) + { + fprintf(stderr, "More than one GfApplication instance ; exiting\n"); + ::exit(1); + } - // Register oneself as the one. - _pSelf = this; + // Register oneself as the one. + _pSelf = this; } void GfApplication::initialize(bool bLoggingEnabled, int argc, char **argv) { - // Store the command line args. - if (argv) - for (int i = 0; i < argc; i++) - _lstArgs.push_back(argv[i]); + // Store the command line args. + if (argv) + for (int i = 0; i < argc; i++) + _lstArgs.push_back(argv[i]); - // Initialize the gaming framework (beware: only GfLogDefault booted). - GfInit(bLoggingEnabled); + // Initialize the gaming framework (beware: only GfLogDefault booted). + GfInit(bLoggingEnabled); // Trace app. information. - GfLogInfo("%s %s", _strName.c_str(), _strVersion.c_str()); - if (!_strDesc.empty()) - GfLogInfo(" (%s)", _strDesc.c_str()); - GfLogInfo("\n"); + GfLogInfo("%s %s", _strName.c_str(), _strVersion.c_str()); + if (!_strDesc.empty()) + GfLogInfo(" (%s)", _strDesc.c_str()); + GfLogInfo("\n"); // Register the command line options (to be parsed). - registerOption("h", "help", /* nHasValue = */ false); - registerOption("v", "version", /* nHasValue = */ false); - registerOption("lc", "localdir", /* nHasValue = */ true); - registerOption("ld", "libdir", /* nHasValue = */ true); - registerOption("bd", "bindir", /* nHasValue = */ true); - registerOption("dd", "datadir", /* nHasValue = */ true); - registerOption("tl", "tracelevel", /* nHasValue = */ true); - registerOption("ts", "tracestream", /* nHasValue = */ true); - registerOption("nr", "norandom", /* nHasValue = */ false); - - // Help about the command line options. - addOptionsHelpSyntaxLine("[-v|--version]"); - addOptionsHelpSyntaxLine("[-h|--help]"); - addOptionsHelpSyntaxLine("[-lc|--localdir ] [-ld|--libdir ]"); - addOptionsHelpSyntaxLine("[-bd|--bindir ] [-dd|--datadir ]"); + registerOption("h", "help", /* nHasValue = */ false); + registerOption("v", "version", /* nHasValue = */ false); + registerOption("lc", "localdir", /* nHasValue = */ true); + registerOption("ld", "libdir", /* nHasValue = */ true); + registerOption("bd", "bindir", /* nHasValue = */ true); + registerOption("dd", "datadir", /* nHasValue = */ true); + registerOption("tl", "tracelevel", /* nHasValue = */ true); + registerOption("ts", "tracestream", /* nHasValue = */ true); + registerOption("nr", "norandom", /* nHasValue = */ false); + + // Help about the command line options. + addOptionsHelpSyntaxLine("[-v|--version]"); + addOptionsHelpSyntaxLine("[-h|--help]"); + addOptionsHelpSyntaxLine("[-lc|--localdir ] [-ld|--libdir ]"); + addOptionsHelpSyntaxLine("[-bd|--bindir ] [-dd|--datadir ]"); #ifdef TRACE_OUT - addOptionsHelpSyntaxLine("[-tl|--tracelevel ]" - " [-ts|--tracestream stdout|stderr|]"); + addOptionsHelpSyntaxLine("[-tl|--tracelevel ]" + " [-ts|--tracestream stdout|stderr|]"); #endif - addOptionsHelpSyntaxLine("[-nr|--norandom]"); - - addOptionsHelpExplainLine - ("- locadir : Root dir of the tree where user settings files are stored"); - addOptionsHelpExplainLine - (" (default=" SD_LOCALDIR ")"); - addOptionsHelpExplainLine - ("- libdir : Root dir of the tree where loadable modules are installed"); - addOptionsHelpExplainLine - (" (default=" SD_LIBDIR ")"); - addOptionsHelpExplainLine - ("- bindir : Dir where the game exe and DLLs are installed"); - addOptionsHelpExplainLine - (" (default=" SD_BINDIR ")"); - addOptionsHelpExplainLine - ("- datadir : Root dir of the data tree (cars, tracks, ...)"); - addOptionsHelpExplainLine - (" (default=" SD_DATADIR ")"); + addOptionsHelpSyntaxLine("[-nr|--norandom]"); + + addOptionsHelpExplainLine + ("- locadir : Root dir of the tree where user settings files are stored"); + addOptionsHelpExplainLine + (" (default=" SD_LOCALDIR ")"); + addOptionsHelpExplainLine + ("- libdir : Root dir of the tree where loadable modules are installed"); + addOptionsHelpExplainLine + (" (default=" SD_LIBDIR ")"); + addOptionsHelpExplainLine + ("- bindir : Dir where the game exe and DLLs are installed"); + addOptionsHelpExplainLine + (" (default=" SD_BINDIR ")"); + addOptionsHelpExplainLine + ("- datadir : Root dir of the data tree (cars, tracks, ...)"); + addOptionsHelpExplainLine + (" (default=" SD_DATADIR ")"); #ifdef TRACE_OUT - addOptionsHelpExplainLine - ("- tracelevel : Maximum level of displayed traces for the default logger"); - addOptionsHelpExplainLine - (" (0=Fatal, 1=Error, 2=Warning, 3=Info, 4=Trace, 5=Debug, ... ; default=5)"); - addOptionsHelpExplainLine - ("- tracestream : Target output stream for the default logger (default=stderr)"); - addOptionsHelpExplainLine - ("- norandom : Force reproducible random sequences for every game session (default=off)"); + addOptionsHelpExplainLine + ("- tracelevel : Maximum level of displayed traces for the default logger"); + addOptionsHelpExplainLine + (" (0=Fatal, 1=Error, 2=Warning, 3=Info, 4=Trace, 5=Debug, ... ; default=5)"); + addOptionsHelpExplainLine + ("- tracestream : Target output stream for the default logger (default=stderr)"); + addOptionsHelpExplainLine + ("- norandom : Force reproducible random sequences for every game session (default=off)"); #endif } const std::string& GfApplication::name() const { - return _strName; + return _strName; } const std::string& GfApplication::description() const { - return _strDesc; + return _strDesc; } const std::string& GfApplication::version() const { - return _strVersion; + return _strVersion; } void GfApplication::updateUserSettings() { - GfFileSetup(); - - // Complete logging system initialisation - // 1) Reparse the relevant options if present. - int nDefTraceLevel = std::numeric_limits::min(); - std::string strDefTraceStream; + GfFileSetup(); - std::list