include/corelib/ncbiapp.hpp

Go to the documentation of this file.
00001 #ifndef CORELIB___NCBIAPP__HPP
00002 #define CORELIB___NCBIAPP__HPP
00003 
00004 /*  $Id: ncbiapp.hpp 175750 2009-11-10 15:23:04Z ivanov $
00005  * ===========================================================================
00006  *
00007  *                            PUBLIC DOMAIN NOTICE
00008  *               National Center for Biotechnology Information
00009  *
00010  *  This software/database is a "United States Government Work" under the
00011  *  terms of the United States Copyright Act.  It was written as part of
00012  *  the author's official duties as a United States Government employee and
00013  *  thus cannot be copyrighted.  This software/database is freely available
00014  *  to the public for use. The National Library of Medicine and the U.S.
00015  *  Government have not placed any restriction on its use or reproduction.
00016  *
00017  *  Although all reasonable efforts have been taken to ensure the accuracy
00018  *  and reliability of the software and data, the NLM and the U.S.
00019  *  Government do not and cannot warrant the performance or results that
00020  *  may be obtained by using this software or data. The NLM and the U.S.
00021  *  Government disclaim all warranties, express or implied, including
00022  *  warranties of performance, merchantability or fitness for any particular
00023  *  purpose.
00024  *
00025  *  Please cite the author in any work or product based on this material.
00026  *
00027  * ===========================================================================
00028  *
00029  * Authors:  Denis Vakatov, Vsevolod Sandomirskiy
00030  *
00031  *
00032  */
00033 
00034 /// @file ncbiapp.hpp
00035 /// Defines the CNcbiApplication and CAppException classes for creating
00036 /// NCBI applications.
00037 ///
00038 /// The CNcbiApplication class defines the application framework and the high
00039 /// high level behavior of an application, and the CAppException class is used
00040 /// for the exceptions generated by CNcbiApplication.
00041 
00042 
00043 #include <corelib/ncbiargs.hpp>
00044 #include <corelib/ncbienv.hpp>
00045 #include <corelib/metareg.hpp>
00046 #include <corelib/version.hpp>
00047 
00048 
00049 /// Avoid preprocessor name clash with the NCBI C Toolkit.
00050 #if !defined(NCBI_OS_UNIX)  ||  defined(HAVE_NCBI_C)
00051 #  if defined(GetArgs)
00052 #    undef GetArgs
00053 #  endif
00054 #  define GetArgs GetArgs
00055 #endif
00056 
00057 
00058 /** @addtogroup AppFramework
00059  *
00060  * @{
00061  */
00062 
00063 
00064 BEGIN_NCBI_SCOPE
00065 
00066 
00067 /////////////////////////////////////////////////////////////////////////////
00068 ///
00069 /// CAppException --
00070 ///
00071 /// Define exceptions generated by CNcbiApplication.
00072 ///
00073 /// CAppException inherits its basic functionality from CCoreException
00074 /// and defines additional error codes for applications.
00075 
00076 class  CAppException : public CCoreException
00077 {
00078 public:
00079     /// Error types that an application can generate.
00080     ///
00081     /// These error conditions are checked for and caught inside AppMain().
00082     enum EErrCode {
00083         eUnsetArgs,     ///< Command-line argument description not found
00084         eSetupDiag,     ///< Application diagnostic stream setup failed
00085         eLoadConfig,    ///< Registry data failed to load from config file
00086         eSecond,        ///< Second instance of CNcbiApplication is prohibited
00087         eNoRegistry     ///< Registry file cannot be opened
00088     };
00089 
00090     /// Translate from the error code value to its string representation.
00091     virtual const char* GetErrCodeString(void) const;
00092 
00093     // Standard exception boilerplate code.
00094     NCBI_EXCEPTION_DEFAULT(CAppException, CCoreException);
00095 };
00096 
00097 
00098 
00099 ///////////////////////////////////////////////////////
00100 // CNcbiApplication
00101 //
00102 
00103 
00104 /////////////////////////////////////////////////////////////////////////////
00105 ///
00106 /// CNcbiApplication --
00107 ///
00108 /// Basic (abstract) NCBI application class.
00109 ///
00110 /// Defines the high level behavior of an NCBI application.
00111 /// A new application is written by deriving a class from the CNcbiApplication
00112 /// and writing an implementation of the Run() and maybe some other (like
00113 /// Init(), Exit(), etc.) methods.
00114 
00115 class  CNcbiApplication
00116 {
00117 public:
00118     /// Singleton method.
00119     ///
00120     /// Track the instance of CNcbiApplication, and throw an exception
00121     /// if an attempt is made to create another instance of the application.
00122     /// @return
00123     ///   Current application instance.
00124     static CNcbiApplication* Instance(void);
00125 
00126     /// Constructor.
00127     ///
00128     /// Register the application instance, and reset important
00129     /// application-specific settings to empty values that will
00130     /// be set later.
00131     CNcbiApplication(void);
00132 
00133     /// Destructor.
00134     ///
00135     /// Clean up the application settings, flush the diagnostic stream.
00136     virtual ~CNcbiApplication(void);
00137 
00138     /// Main function (entry point) for the NCBI application.
00139     ///
00140     /// You can specify where to write the diagnostics to (EAppDiagStream),
00141     /// and where to get the configuration file (LoadConfig()) to load
00142     /// to the application registry (accessible via GetConfig()).
00143     ///
00144     /// Throw exception if:
00145     ///  - not-only instance
00146     ///  - cannot load explicitly specified config.file
00147     ///  - SetupDiag() throws an exception
00148     ///
00149     /// If application name is not specified a default of "ncbi" is used.
00150     /// Certain flags such as -logfile, -conffile and -version are special so
00151     /// AppMain() processes them separately.
00152     /// @return
00153     ///   Exit code from Run(). Can also return non-zero value if application
00154     ///   threw an exception.
00155     /// @sa
00156     ///   LoadConfig(), Init(), Run(), Exit()
00157     int AppMain
00158     (int                argc,     ///< argc in a regular main(argc, argv, envp)
00159      const char* const* argv,     ///< argv in a regular main(argc, argv, envp)
00160      const char* const* envp = 0, ///< envp in a regular main(argc, argv, envp)
00161      EAppDiagStream     diag = eDS_Default,     ///< Specify diagnostic stream
00162      const char*        conf = NcbiEmptyCStr,   ///< Specify registry to load
00163      const string&      name = NcbiEmptyString  ///< Specify application name
00164      );
00165 
00166     /// Initialize the application.
00167     ///
00168     /// The default behavior of this is "do nothing". If you have special
00169     /// initialization logic that needs to be peformed, then you must override
00170     /// this method with your own logic.
00171     virtual void Init(void);
00172 
00173     /// Run the application.
00174     ///
00175     /// It is defined as a pure virtual method -- so you must(!) supply the
00176     /// Run() method to implement the application-specific logic.
00177     /// @return
00178     ///   Exit code.
00179     virtual int Run(void) = 0;
00180 
00181     /// Test run the application.
00182     ///
00183     /// It is only supposed to test if the Run() is possible,
00184     /// or makes sense: that is, test all preconditions etc.
00185     /// @return
00186     ///   Exit code.
00187     virtual int DryRun(void);
00188 
00189     /// Cleanup on application exit.
00190     ///
00191     /// Perform cleanup before exiting. The default behavior of this is
00192     /// "do nothing". If you have special cleanup logic that needs to be
00193     /// performed, then you must override this method with your own logic.
00194     virtual void Exit(void);
00195 
00196     /// Get the application's cached unprocessed command-line arguments.
00197     const CNcbiArguments& GetArguments(void) const;
00198 
00199     /// Get parsed command line arguments.
00200     ///
00201     /// Get command line arguments parsed according to the arg descriptions
00202     /// set by SetupArgDescriptions(). Throw exception if no descriptions
00203     /// have been set.
00204     /// @return
00205     ///   The CArgs object containing parsed cmd.-line arguments.
00206     /// @sa
00207     ///   SetupArgDescriptions().
00208     virtual const CArgs& GetArgs(void) const;
00209 
00210     /// Get the application's cached environment.
00211     const CNcbiEnvironment& GetEnvironment(void) const;
00212 
00213     /// Get a non-const copy of the application's cached environment.
00214     CNcbiEnvironment& SetEnvironment(void);
00215 
00216     /// Set a specified environment variable by name
00217     void SetEnvironment(const string& name, const string& value);
00218 
00219     /// Check if the config file has been loaded
00220     bool HasLoadedConfig(void) const;
00221 
00222     /// Get the application's cached configuration parameters.
00223     const CNcbiRegistry& GetConfig(void) const;
00224     CNcbiRegistry& GetConfig(void);
00225 
00226     /// Get the full path to the configuration file (if any) we ended
00227     /// up using.
00228     const string& GetConfigPath(void) const;
00229 
00230     /// Reload the configuration file.  By default, does nothing if
00231     /// the file has the same size and date as before.
00232     ///
00233     /// Note that this may lose other data stored in the registry!
00234     ///
00235     /// @param flags
00236     ///   Controls how aggressively to reload.
00237     /// @param reg_flags
00238     ///   Flags to use when parsing the registry; ignored if the registry
00239     ///   was already cached (as it should normally have been).
00240     /// @return
00241     ///   TRUE if a reload actually occurred.
00242     bool ReloadConfig(CMetaRegistry::TFlags flags
00243                       = CMetaRegistry::fReloadIfChanged,
00244                       IRegistry::TFlags reg_flags = IRegistry::fWithNcbirc);
00245 
00246     /// Flush the in-memory diagnostic stream (for "eDS_ToMemory" case only).
00247     ///
00248     /// In case of "eDS_ToMemory", the diagnostics is stored in
00249     /// the internal application memory buffer ("m_DiagStream").
00250     /// Call this function to dump all the diagnostics to stream "os" and
00251     /// purge the buffer.
00252     /// @param  os
00253     ///   Output stream to dump diagnostics to. If it is NULL, then
00254     ///   nothing will be written to it (but the buffer will still be purged).
00255     /// @param  close_diag
00256     ///   If "close_diag" is TRUE, then also destroy "m_DiagStream".
00257     /// @return
00258     ///   Total number of bytes actually written to "os".
00259     SIZE_TYPE FlushDiag(CNcbiOstream* os, bool close_diag = false);
00260 
00261     /// Get the application's "display" name.
00262     ///
00263     /// Get name of this application, suitable for displaying
00264     /// or for using as the base name for other files.
00265     /// Will be the 'name' argument of AppMain if given.
00266     /// Otherwise will be taken from the actual name of the application file
00267     /// or argv[0].
00268     const string& GetProgramDisplayName(void) const;
00269 
00270     /// Get the application's executable path.
00271     ///
00272     /// The path to executable file of this application. 
00273     /// Return empty string if not possible to determine this path.
00274     const string& GetProgramExecutablePath(EFollowLinks follow_links
00275                                            = eIgnoreLinks)
00276         const;
00277 
00278     /// Get the program version information.
00279     ///
00280     /// @sa SetVersion, SetFullVersion
00281     CVersionInfo GetVersion(void) const;
00282 
00283     /// Get the program version information.
00284     const CVersion& GetFullVersion(void) const;
00285     
00286     /// Check if it is a test run.
00287     bool IsDryRun(void) const;
00288 
00289     /// Setup application specific diagnostic stream.
00290     ///
00291     /// Called from SetupDiag when it is passed the eDS_AppSpecific parameter.
00292     /// Currently, this calls SetupDiag(eDS_ToStderr) to setup diagonistic
00293     /// stream to the std error channel.
00294     /// @return
00295     ///   TRUE if successful, FALSE otherwise.
00296     /// @deprecated
00297     NCBI_DEPRECATED virtual bool SetupDiag_AppSpecific(void);
00298 
00299 protected:
00300     /// Result of PreparseArgs()
00301     enum EPreparseArgs {
00302         ePreparse_Continue,  ///< Continue application execution
00303         ePreparse_Exit       ///< Exit the application with zero exit code
00304     };
00305 
00306     /// Check the command line arguments before parsing them.
00307     /// @sa EPreparseArgs
00308     virtual EPreparseArgs PreparseArgs(int                argc,
00309                                        const char* const* argv);
00310 
00311     /// Disable argument descriptions.
00312     ///
00313     /// Call with a bit flag set if you do not want std AND user
00314     /// cmd.line args to be parsed.
00315     /// Note that by default the parsing of cmd.line args are enabled.
00316     enum EDisableArgDesc {
00317         fDisableStdArgs     = 0x01   ///<  (-logfile, -conffile, -version etc)
00318     };
00319     typedef int TDisableArgDesc;  ///< Binary OR of "EDisableArgDesc"
00320     void DisableArgDescriptions(TDisableArgDesc disable = fDisableStdArgs);
00321 
00322     /// Which standard flag's descriptions should not be displayed in
00323     /// the usage message.
00324     ///
00325     /// Do not display descriptions of the standard flags such as the
00326     ///    -h, -logfile, -conffile, -version
00327     /// flags in the usage message. Note that you still can pass them in
00328     /// the command line.
00329     enum EHideStdArgs {
00330         fHideLogfile     = 0x01,  ///< Hide log file description
00331         fHideConffile    = 0x02,  ///< Hide configuration file description
00332         fHideVersion     = 0x04,  ///< Hide version description
00333         fHideFullVersion = 0x08,  ///< Hide full version description
00334         fHideDryRun      = 0x10,  ///< Hide dryrun description
00335         fHideHelp        = 0x20,  ///< Hide help description
00336         fHideFullHelp    = 0x40,  ///< Hide full help description
00337         fHideXmlHelp     = 0x80,  ///< Hide XML help description
00338         fHideAll         = 0xFF   ///< Hide all standard argument descriptions
00339     };
00340     typedef int THideStdArgs;  ///< Binary OR of "EHideStdArgs"
00341 
00342     /// Set the hide mask for the Hide Std Flags.
00343     void HideStdArgs(THideStdArgs hide_mask);
00344 
00345     /// Flags to adjust standard I/O streams' behaviour.
00346     enum EStdioSetup {
00347         fDefault_SyncWithStdio  = 0x01,
00348         ///< Use compiler-specific default as pertains to the synchronizing
00349         ///< of "C++" Cin/Cout/Cerr streams with their "C" counterparts.
00350 
00351         fDefault_CinBufferSize  = 0x02,
00352         ///< Use compiler-specific default of Cin buffer size.
00353         fBinaryCin   = 0x04,  ///< treat standard  input as binary
00354         fBinaryCout  = 0x08   ///< treat standard output as binary
00355     };
00356     typedef int TStdioSetupFlags;  ///< Binary OR of "EStdioSetup"
00357 
00358     /// Adjust the behavior of standard I/O streams.
00359     ///
00360     /// Unless this function is called, the behaviour of "C++" Cin/Cout/Cerr
00361     /// streams will be the same regardless of the compiler used.
00362     ///
00363     /// IMPLEMENTATION NOTE: Do not call this function more than once
00364     /// and from places other than App's constructor.
00365     void SetStdioFlags(TStdioSetupFlags stdio_flags);
00366 
00367     /// Set the version number for the program.
00368     ///
00369     /// If not set, a default of 0.0.0 (unknown) is used.
00370     /// @note
00371     ///   This function should be used from constructor of CNcbiApplication
00372     ///   derived class, otherwise command-like arguments "-version" and 
00373     ///   "-version-full" will not work as expected.
00374     /// @sa GetVersion
00375     void SetVersion(const CVersionInfo& version);
00376 
00377     /// Set version data for the program.
00378     ///
00379     /// @note
00380     ///   This function should be used from constructor of CNcbiApplication
00381     ///   derived class, otherwise command-like arguments "-version" and 
00382     ///   "-version-full" will not work as expected.
00383     /// @sa GetVersion
00384     void SetFullVersion( CRef<CVersion> version);
00385 
00386     /// Setup the command line argument descriptions.
00387     ///
00388     /// Call from the Init() method. The passed "arg_desc" will be owned
00389     /// by this class, and it will be deleted by ~CNcbiApplication(),
00390     /// or if SetupArgDescriptions() is called again.
00391     virtual void SetupArgDescriptions(CArgDescriptions* arg_desc);
00392 
00393     /// Get argument descriptions (set by SetupArgDescriptions)
00394     const CArgDescriptions* GetArgDescriptions(void) const;
00395 
00396     /// Setup the application diagnostic stream.
00397     /// @return
00398     ///   TRUE if successful,  FALSE otherwise.
00399     /// @deprecated
00400     NCBI_DEPRECATED bool SetupDiag(EAppDiagStream diag);
00401 
00402     /// Load settings from the configuration file to the registry.
00403     ///
00404     /// This method is called from inside AppMain() to load (add) registry
00405     /// settings from the configuration file specified as the "conf" arg
00406     /// passed to AppMain(). The "conf" argument has the following special
00407     /// meanings:
00408     ///  - NULL      -- dont even try to load registry from any file at all;
00409     ///  - non-empty -- if "conf" contains a path, then try to load from the
00410     ///                 conf.file of name "conf" (only!). Else - see NOTE.
00411     ///                 TIP: if the path is not fully qualified then:
00412     ///                      if it starts from "../" or "./" -- look starting
00413     ///                      from the current working dir.
00414     ///  - empty     -- compose conf.file name from the application name
00415     ///                 plus ".ini". If it does not match an existing
00416     ///                 file, then try to strip file extensions, e.g. for
00417     ///                 "my_app.cgi.exe" -- try subsequently:
00418     ///                   "my_app.cgi.exe.ini", "my_app.cgi.ini", "my_app.ini".
00419     ///
00420     /// NOTE:
00421     /// If "conf" arg is empty or non-empty, but without path, then
00422     /// the Toolkit will try to look for it in several potentially
00423     /// relevant directories, as described in <corelib/metareg.hpp>.
00424     ///
00425     /// Throw an exception if "conf" is non-empty, and cannot open file.
00426     /// Throw an exception if file exists, but contains invalid entries.
00427     /// @param reg
00428     ///   The loaded registry is returned via the reg parameter.
00429     /// @param conf
00430     ///   The configuration file to loaded the registry entries from.
00431     /// @param reg_flags
00432     ///   Flags for loading the registry
00433     /// @return
00434     ///   TRUE only if the file was non-NULL, found and successfully read.
00435     /// @sa
00436     ///   CMetaRegistry::GetDefaultSearchPath
00437     virtual bool LoadConfig(CNcbiRegistry& reg, const string* conf,
00438                             CNcbiRegistry::TFlags reg_flags);
00439 
00440     /// Load settings from the configuration file to the registry.
00441     ///
00442     /// CNcbiApplication::LoadConfig(reg, conf) just calls
00443     /// LoadConfig(reg, conf, IRegistry::fWithNcbirc).
00444     virtual bool LoadConfig(CNcbiRegistry& reg, const string* conf);
00445 
00446     /// Set program's display name.
00447     ///
00448     /// Set up application name suitable for display or as a basename for
00449     /// other files. It can also be set by the user when calling AppMain().
00450     void SetProgramDisplayName(const string& app_name);
00451 
00452     /// Find the application's executable file.
00453     ///
00454     /// Find the path and name of the executable file that this application is
00455     /// running from. Will be accessible by GetArguments().GetProgramName().
00456     /// @param argc
00457     ///   Standard argument count "argc".
00458     /// @param argv
00459     ///   Standard argument vector "argv".
00460     /// @param real_path
00461     ///   If non-NULL, will get the fully resolved path to the executable.
00462     /// @return
00463     ///   Name of application's executable file (may involve symlinks).
00464     string FindProgramExecutablePath(int argc, const char* const* argv,
00465                                      string* real_path = 0);
00466 
00467     /// Method to be called before application start.
00468     /// Can be used to set DiagContext properties to be printed
00469     /// in the application start message (e.g. host|host_ip_addr,
00470     /// client_ip and session_id for CGI applications).
00471     virtual void AppStart(void);
00472 
00473     /// Method to be called before application exit.
00474     /// Can be used to set DiagContext properties to be printed
00475     /// in the application stop message (exit_status, exit_signal,
00476     /// exit_code).
00477     virtual void AppStop(int exit_code);
00478 
00479     /// When to return a user-set exit code
00480     enum EExitMode {
00481         eNoExits,          ///< never (stick to existing logic)
00482         eExceptionalExits, ///< when an (uncaught) exception occurs
00483         eAllExits          ///< always (ignoring Run's return value)
00484     };
00485     /// Force the program to return a specific exit code later, either
00486     /// when it exits due to an exception or unconditionally.  In the
00487     /// latter case, Run's return value will be ignored.
00488     void SetExitCode(int exit_code, EExitMode when = eExceptionalExits);
00489 
00490 private:
00491     /// Read standard NCBI application configuration settings.
00492     ///
00493     /// [NCBI]:   HeapSizeLimit, CpuTimeLimit
00494     /// [DEBUG]:  ABORT_ON_THROW, DIAG_POST_LEVEL, MessageFile
00495     /// @param reg
00496     ///   Registry to read from. If NULL, use the current registry setting.
00497     void x_HonorStandardSettings(IRegistry* reg = 0);
00498 
00499     /// Setup C++ standard I/O streams' behaviour.
00500     ///
00501     /// Called from AppMain() to do compiler-specific optimization
00502     /// for C++ I/O streams. For example, since SUN WorkShop STL stream
00503     /// library has significant performance loss when sync_with_stdio is
00504     /// TRUE (default), so we turn it off. Another, for GCC version greater
00505     /// than 3.00 we forcibly set cin stream buffer size to 4096 bytes -- which
00506     /// boosts the performance dramatically.
00507     void x_SetupStdio(void);
00508     
00509     void x_AddDefaultArgs(void);
00510 
00511     // Wrappers for parts of AppMain() called with or without try/catch
00512     // depending on settings.
00513     void x_TryInit(EAppDiagStream diag, const char* conf);
00514     void x_TryMain(EAppDiagStream diag,
00515                    const char*    conf,
00516                    int*           exit_code,
00517                    bool*          got_exception);
00518 
00519     static CNcbiApplication*   m_Instance;   ///< Current app. instance
00520     CRef<CVersion>             m_Version;    ///< Program version
00521     auto_ptr<CNcbiEnvironment> m_Environ;    ///< Cached application env.
00522     CRef<CNcbiRegistry>        m_Config;     ///< Guaranteed to be non-NULL
00523     auto_ptr<CNcbiOstream>     m_DiagStream; ///< Opt., aux., see eDS_ToMemory
00524     auto_ptr<CNcbiArguments>   m_Arguments;  ///< Command-line arguments
00525     auto_ptr<CArgDescriptions> m_ArgDesc;    ///< Cmd.-line arg descriptions
00526     auto_ptr<CArgs>            m_Args;       ///< Parsed cmd.-line args
00527     TDisableArgDesc            m_DisableArgDesc;  ///< Arg desc. disabled
00528     THideStdArgs               m_HideArgs;   ///< Std cmd.-line flags to hide
00529     TStdioSetupFlags           m_StdioFlags; ///< Std C++ I/O adjustments
00530     char*                      m_CinBuffer;  ///< Cin buffer if changed
00531     string                     m_ProgramDisplayName;  ///< Display name of app
00532     string                     m_ExePath;    ///< Program executable path
00533     string                     m_RealExePath; ///< Symlink-free executable path
00534     mutable string             m_LogFileName; ///< Log file name
00535     string                     m_ConfigPath;  ///< Path to .ini file used
00536     int                        m_ExitCode;    ///< Exit code to force
00537     EExitMode                  m_ExitCodeCond; ///< When to force it (if ever)
00538     bool                       m_DryRun;       ///< Dry run
00539     string                     m_DefaultConfig; ///< conf parameter to AppMain
00540 };
00541 
00542 
00543 /// Interface for application idler.
00544 class  INcbiIdler {
00545 public:
00546     virtual ~INcbiIdler(void) {}
00547 
00548     // Perform any actions. Called by RunIdle().
00549     virtual void Idle(void) = 0;
00550 };
00551 
00552 
00553 /// Default idler.
00554 class  CDefaultIdler : public INcbiIdler
00555 {
00556 public:
00557     CDefaultIdler(void) {}
00558     virtual ~CDefaultIdler(void) {}
00559 
00560     virtual void Idle(void);
00561 };
00562 
00563 
00564 /// Return currently installed idler or NULL. Update idler ownership
00565 /// according to the flag.
00566  INcbiIdler* GetIdler(EOwnership ownership = eNoOwnership);
00567 
00568 /// Set new idler and ownership.
00569  void SetIdler(INcbiIdler* idler,
00570                                 EOwnership ownership = eTakeOwnership);
00571 
00572 /// Execute currently installed idler if any.
00573  void RunIdler(void);
00574 
00575 
00576 /* @} */
00577 
00578 
00579 
00580 /////////////////////////////////////////////////////////////////////////////
00581 //  IMPLEMENTATION of INLINE functions
00582 /////////////////////////////////////////////////////////////////////////////
00583 
00584 
00585 inline const CNcbiArguments& CNcbiApplication::GetArguments(void) const
00586 {
00587     return *m_Arguments;
00588 }
00589 
00590 inline const CNcbiEnvironment& CNcbiApplication::GetEnvironment(void) const
00591 {
00592     return *m_Environ;
00593 }
00594 
00595 inline CNcbiEnvironment& CNcbiApplication::SetEnvironment(void)
00596 {
00597     return *m_Environ;
00598 }
00599 
00600 inline const CNcbiRegistry& CNcbiApplication::GetConfig(void) const
00601 {
00602     return *m_Config;
00603 }
00604 
00605 inline CNcbiRegistry& CNcbiApplication::GetConfig(void)
00606 {
00607     return *m_Config;
00608 }
00609 
00610 inline const string& CNcbiApplication::GetConfigPath(void) const
00611 {
00612     return m_ConfigPath;
00613 }
00614 
00615 inline bool CNcbiApplication::HasLoadedConfig(void) const
00616 {
00617     return !m_ConfigPath.empty();
00618 }
00619 
00620 inline bool CNcbiApplication::ReloadConfig(CMetaRegistry::TFlags flags,
00621                                            IRegistry::TFlags reg_flags)
00622 {
00623     return CMetaRegistry::Reload(GetConfigPath(), GetConfig(), flags,
00624                                  reg_flags);
00625 }
00626 
00627 inline const string& CNcbiApplication::GetProgramDisplayName(void) const
00628 {
00629     return m_ProgramDisplayName;
00630 }
00631 
00632 inline const string&
00633 CNcbiApplication::GetProgramExecutablePath(EFollowLinks follow_links) const
00634 {
00635     return follow_links == eFollowLinks ? m_RealExePath : m_ExePath;
00636 }
00637 
00638 
00639 inline const CArgDescriptions* CNcbiApplication::GetArgDescriptions(void) const
00640 {
00641     return m_ArgDesc.get();
00642 }
00643 
00644 
00645 inline bool CNcbiApplication::IsDryRun(void) const
00646 {
00647     return m_DryRun;
00648 }
00649 
00650 
00651 END_NCBI_SCOPE
00652 
00653 #endif  /* CORELIB___NCBIAPP__HPP */
00654 
00655 

Generated on Sun Dec 6 21:58:46 2009 for NCBI C++ ToolKit by  doxygen 1.4.6
Modified on Mon Dec 07 16:20:35 2009 by modify_doxy.py rev. 173732