OpenMW
components/files/configurationmanager.hpp
Go to the documentation of this file.
00001 #ifndef COMPONENTS_FILES_CONFIGURATIONMANAGER_HPP
00002 #define COMPONENTS_FILES_CONFIGURATIONMANAGER_HPP
00003 
00004 #ifdef _WIN32
00005 #include <boost/tr1/tr1/unordered_map>
00006 #elif defined HAVE_UNORDERED_MAP
00007 #include <unordered_map>
00008 #else
00009 #include <tr1/unordered_map>
00010 #endif
00011 
00012 #include <boost/program_options.hpp>
00013 
00014 #include <components/files/fixedpath.hpp>
00015 #include <components/files/collections.hpp>
00016 
00020 namespace Files
00021 {
00022 
00026 struct ConfigurationManager
00027 {
00028     ConfigurationManager();
00029     virtual ~ConfigurationManager();
00030 
00031     void readConfiguration(boost::program_options::variables_map& variables,
00032         boost::program_options::options_description& description);
00033 
00034     void processPaths(Files::PathContainer& dataDirs, bool create = false);
00036 
00038     const boost::filesystem::path& getGlobalPath() const;
00039     const boost::filesystem::path& getUserConfigPath() const;
00040     const boost::filesystem::path& getLocalPath() const;
00041 
00042     const boost::filesystem::path& getGlobalDataPath() const;
00043     const boost::filesystem::path& getUserDataPath() const;
00044     const boost::filesystem::path& getLocalDataPath() const;
00045     const boost::filesystem::path& getInstallPath() const;
00046 
00047     const boost::filesystem::path& getCachePath() const;
00048 
00049     const boost::filesystem::path& getLogPath() const;
00050 
00051     private:
00052         typedef Files::FixedPath<> FixedPathType;
00053 
00054         typedef const boost::filesystem::path& (FixedPathType::*path_type_f)() const;
00055         #if defined HAVE_UNORDERED_MAP
00056             typedef std::unordered_map<std::string, path_type_f> TokensMappingContainer;
00057         #else
00058             typedef std::tr1::unordered_map<std::string, path_type_f> TokensMappingContainer;
00059         #endif
00060 
00061         void loadConfig(const boost::filesystem::path& path,
00062             boost::program_options::variables_map& variables,
00063             boost::program_options::options_description& description);
00064 
00065         void setupTokensMapping();
00066 
00067         FixedPathType mFixedPath;
00068 
00069         boost::filesystem::path mLogPath;
00070 
00071         TokensMappingContainer mTokensMapping;
00072 };
00073 
00074 } /* namespace Cfg */
00075 
00076 #endif /* COMPONENTS_FILES_CONFIGURATIONMANAGER_HPP */