00001
00002 #ifndef CConfManager_h
00003 #define CConfManager_h 1
00004
00005
00006 #include "jic/config/CConfFileParser.hpp"
00007
00008 #include "jic/config/CArgsParser.hpp"
00009
00010 #include "jic/exc/CConfException.hpp"
00011
00012 namespace CONFIG {
00013
00014 class CConfManager
00015 {
00016
00017 public:
00018 ~CConfManager();
00019
00020 std::string getConfValue (char* szKey) const throw (CConfException);
00021
00022 std::string getConfValue (std::string strKey) const throw (CConfException);
00023
00024 void setFileName (std::string strFileName);
00025
00026 static CConfManager* Instance ();
00027
00028 void parseConf () throw (CConfException);
00029
00030 void setArgs (int nArgs, char** pArgsValues);
00031
00032 void setArgsNames (MAP_char_string& rArgsNames);
00033
00034 std::string getString (const std::string &szKey) const throw (CConfException);
00035
00036 int getInt (const std::string &szKey) const throw (CConfException);
00037
00038 char getChar (const std::string &szKey) const throw (CConfException);
00039
00040 std::string getString (const std::string &szKey, const std::string &szDefVal) const throw (CConfException);
00041
00042 int getInt (const std::string &szKey, int nDefVal) const throw (CConfException);
00043
00044 char getChar (const std::string &szKey, char cDefVal) const throw (CConfException);
00045
00046
00047
00048 protected:
00049 CConfManager();
00050
00051
00052
00053 private:
00054
00055 const std::string get_strConfFileName () const;
00056 void set_strConfFileName (std::string value);
00057
00058 const int get_nArgs () const;
00059 void set_nArgs (int value);
00060
00061 char** get_pArgsValues ();
00062 void set_pArgsValues (char** value);
00063
00064 const CArgsParser get_argConfParser () const;
00065 void set_argConfParser (CArgsParser value);
00066
00067
00068
00069 private:
00070
00071
00072 std::string m_strConfFileName;
00073
00074 static CConfManager* m_instance;
00075
00076 int m_nArgs;
00077
00078 char** m_pArgsValues;
00079
00080
00081
00082 CArgsParser m_argConfParser;
00083
00084 CConfFileParser *m_pConfFileParser;
00085
00086
00087
00088 };
00089
00090
00091
00092 inline std::string CConfManager::getString (const std::string &szKey) const throw (CConfException)
00093 {
00094 return getConfValue(szKey);
00095 }
00096
00097 inline const std::string CConfManager::get_strConfFileName () const
00098 {
00099 return m_strConfFileName;
00100 }
00101
00102 inline void CConfManager::set_strConfFileName (std::string value)
00103 {
00104 m_strConfFileName = value;
00105 }
00106
00107 inline const int CConfManager::get_nArgs () const
00108 {
00109 return m_nArgs;
00110 }
00111
00112 inline void CConfManager::set_nArgs (int value)
00113 {
00114 m_nArgs = value;
00115 }
00116
00117 inline char** CConfManager::get_pArgsValues ()
00118 {
00119 return m_pArgsValues;
00120 }
00121
00122 inline void CConfManager::set_pArgsValues (char** value)
00123 {
00124 m_pArgsValues = value;
00125 }
00126
00127 inline const CArgsParser CConfManager::get_argConfParser () const
00128 {
00129 return m_argConfParser;
00130 }
00131
00132 inline void CConfManager::set_argConfParser (CArgsParser value)
00133 {
00134 m_argConfParser = value;
00135 }
00136
00137 }
00138
00139 #endif