Changeset 5836 for code/branches/core5/src/libraries/core/PathConfig.h
- Timestamp:
- Sep 30, 2009, 12:00:16 AM (15 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core5/src/libraries/core/PathConfig.h
r5832 r5836 21 21 * 22 22 * Author: 23 * Fabian 'x3n' Landau24 23 * Reto Grieder 25 24 * Co-authors: … … 28 27 */ 29 28 30 /** 31 @file 32 @brief 33 Declaration of the Core class. 34 @details 35 The Core class is a singleton, only used to configure some variables 36 in the core through the config-file. 37 */ 38 39 #ifndef _Core_H__ 40 #define _Core_H__ 29 #ifndef _PathConfig_H__ 30 #define _PathConfig_H__ 41 31 42 32 #include "CorePrereqs.h" 43 33 44 #include <cassert> 45 #include <boost/scoped_ptr.hpp> 46 #include "util/OutputHandler.h" 47 #include "util/ScopeGuard.h" 34 #include <string> 48 35 #include "util/Singleton.h" 49 36 50 37 namespace orxonox 51 38 { 52 class CoreConfiguration;53 54 39 /** 55 40 @brief 56 The Core class is a singleton used to configure the program basics.41 The PathConfig class is a singleton used to configure different paths. 57 42 @details 58 The class provides information about the data, config and log path. 43 The class provides information about the data, config, log, executable, 44 root and module path. 59 45 It determines those by the use of platform specific functions. 60 @remark 61 You should only create this singleton once because it destroys the identifiers! 46 @remarks 47 Not all paths are always available: 48 - root only when installed copyable 49 - externalData only for development builds in the build tree 62 50 */ 63 class _CoreExport Core : public Singleton<Core>51 class _CoreExport PathConfig : public Singleton<PathConfig> 64 52 { 65 typedef Loki::ScopeGuardImpl0<void (*)()> SimpleScopeGuard; 66 friend class Singleton<Core>; 67 friend class Game; 53 friend class Singleton<PathConfig>; 54 friend class Core; 68 55 69 56 public: 70 57 /** 71 58 @brief 72 Determines the executable path, checks for build directory runs, creates 73 the output directories and sets up the other core library singletons. 74 @throws 59 Retrievs the executable path and sets all hard coded fixed paths (currently only the module path) 60 Also checks for "orxonox_dev_build.keep_me" in the executable diretory. 61 If found it means that this is not an installed run, hence we 62 don't write the logs and config files to ~/.orxonox 63 @throw 75 64 GeneralException 76 65 */ 77 Core(const std::string& cmdLine);78 ~ Core();66 PathConfig(); 67 ~PathConfig(); 79 68 80 void setConfigValues(); 69 //! Returns the path to the root folder as boost::filesystem::path 70 static const boost::filesystem::path& getRootPath() 71 { return getInstance().rootPath_; } 72 //! Returns the path to the executable folder as boost::filesystem::path 73 static const boost::filesystem::path& getExecutablePath() 74 { return getInstance().executablePath_; } 75 //! Returns the path to the data files as boost::filesystem::path 76 static const boost::filesystem::path& getDataPath() 77 { return getInstance().dataPath_; } 78 //! Returns the path to the external data files as boost::filesystem::path 79 static const boost::filesystem::path& getExternalDataPath() 80 { return getInstance().externalDataPath_; } 81 //! Returns the path to the config files as boost::filesystem::path 82 static const boost::filesystem::path& getConfigPath() 83 { return getInstance().configPath_; } 84 //! Returns the path to the log files as boost::filesystem::path 85 static const boost::filesystem::path& getLogPath() 86 { return getInstance().logPath_; } 87 //! Returns the path to the modules as boost::filesystem::path 88 static const boost::filesystem::path& getModulePath() 89 { return getInstance().modulePath_; } 81 90 82 static int getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All); 83 static void setSoftDebugLevel(OutputHandler::OutputDevice device, int level); 84 static const std::string& getLanguage(); 85 static void resetLanguage(); 86 87 static void tsetExternalDataPath(const std::string& path); 88 //! Returns the path to the data files as boost::filesystem::path 89 static const boost::filesystem::path& getDataPath(); 90 //! Returns the path to the external data files as boost::filesystem::path 91 static const boost::filesystem::path& getExternalDataPath(); 92 //! Returns the path to the config files as boost::filesystem::path 93 static const boost::filesystem::path& getConfigPath(); 94 //! Returns the path to the log files as boost::filesystem::path 95 static const boost::filesystem::path& getLogPath(); 96 //! Returns the path to the root folder as boost::filesystem::path 97 static const boost::filesystem::path& getRootPath(); 91 //! Returns the path to the root folder as std::string 92 static std::string getRootPathString(); 93 //! Returns the path to the executable folder as std::string 94 static std::string getExecutablePathString(); 98 95 //! Returns the path to the data files as std::string 99 96 static std::string getDataPathString(); … … 104 101 //! Returns the path to the log files as std::string 105 102 static std::string getLogPathString(); 106 //! Returns the path to the root folderas std::string107 static std::string get RootPathString();103 //! Returns the path to the modules as std::string 104 static std::string getModulePathString(); 108 105 106 //! Return trrue for runs in the build directory (not installed) 109 107 static bool isDevelopmentRun() { return getInstance().bDevRun_; } 110 108 111 109 private: 112 Core(const Core&); //!< Don't use (undefined symbol)110 PathConfig(const PathConfig&); //!< Don't use (undefined symbol) 113 111 114 void preUpdate(const Clock& time); 115 void postUpdate(const Clock& time); 112 /** 113 @brief 114 Sets config, log and media path and creates the folders if necessary. 115 @throws 116 GeneralException 117 */ 118 void setConfigurablePaths(); 119 //! Returns a list with all modules declared by a *.module file in the module folder. 120 std::vector<std::string> getModulePaths(); 116 121 117 void loadGraphics(); 118 void unloadGraphics(); 122 //! Path to the parent directory of the ones above if program was installed with relativ paths 123 boost::filesystem::path& rootPath_; 124 boost::filesystem::path& executablePath_; //!< Path to the executable 125 boost::filesystem::path& modulePath_; //!< Path to the modules 126 boost::filesystem::path& dataPath_; //!< Path to the data files folder 127 boost::filesystem::path& externalDataPath_; //!< Path to the external data files folder 128 boost::filesystem::path& configPath_; //!< Path to the config files folder 129 boost::filesystem::path& logPath_; //!< Path to the log files folder 119 130 120 void setFixedPaths(); 121 void setConfigurablePaths(); 122 void setThreadAffinity(int limitToCPU); 123 124 // Mind the order for the destruction! 125 scoped_ptr<DynLibManager> dynLibManager_; 126 scoped_ptr<SignalHandler> signalHandler_; 127 SimpleScopeGuard identifierDestroyer_; 128 SimpleScopeGuard consoleCommandDestroyer_; 129 scoped_ptr<ConfigFileManager> configFileManager_; 130 scoped_ptr<Language> languageInstance_; 131 scoped_ptr<CoreConfiguration> configuration_; 132 scoped_ptr<TclBind> tclBind_; 133 scoped_ptr<TclThreadManager> tclThreadManager_; 134 scoped_ptr<Shell> shell_; 135 // graphical 136 scoped_ptr<GraphicsManager> graphicsManager_; //!< Interface to OGRE 137 scoped_ptr<InputManager> inputManager_; //!< Interface to OIS 138 scoped_ptr<GUIManager> guiManager_; //!< Interface to GUI 139 140 bool bDevRun_; //!< True for runs in the build directory (not installed) 141 bool bGraphicsLoaded_; 142 143 static Core* singletonPtr_s; 131 bool bDevRun_; //!< True for runs in the build directory (not installed) 132 static PathConfig* singletonPtr_s; 144 133 }; 145 134 } 146 135 147 #endif /* _ Core_H__ */136 #endif /* _PathConfig_H__ */
Note: See TracChangeset
for help on using the changeset viewer.