Definition at line 16 of file OptionAgent.h.
Public Member Functions | |
void | parseCmdOpt (int argc, char *argv[], const OptionParams ¶ms) |
Parse command line options. | |
void | setParam (const std::string &name, const std::string &value) |
Set param. | |
void | setParam (const std::string &name, long value) |
Store this integer value like string param. | |
void | setPersistent (const std::string &name, const std::string &value) |
Set param also on disk. | |
void | setPersistent (const std::string &name, long value) |
void | setDefault (const std::string &name, const std::string &value) |
Set value when it is empty. | |
void | setDefault (const std::string &name, int value) |
std::string | getParam (const std::string &name, const std::string &implicit="") const |
Return value. | |
int | getAsInt (const std::string &name, int implicit=0) const |
Returns number value. | |
bool | getAsBool (const std::string &name, bool implicit=false) const |
Returns boolean value. | |
void | addWatcher (const std::string &name, BaseMsg *msg) |
void | removeWatchers (const std::string &listenerName) |
void | receiveString (const StringMsg *msg) |
Handle incoming message. | |
Protected Member Functions | |
virtual void | own_init () |
Set user and sytem dir and process "script/options.lua" - this will set user and system paths and process "script/init.lua". | |
virtual void | own_shutdown () |
Save user config. |
|
Definition at line 336 of file OptionAgent.cpp. 00337 { 00338 m_environ->addWatcher(name, msg); 00339 }
|
|
Returns boolean value. Implicit value is false.
Definition at line 279 of file OptionAgent.cpp. 00281 { 00282 return m_environ->getAsBool(name, implicit); 00283 }
|
|
Returns number value. Implicit value is zero.
Definition at line 264 of file OptionAgent.cpp. 00266 { 00267 return m_environ->getAsInt(name, implicit); 00268 }
|
|
Return value. Implicit value is "".
Definition at line 249 of file OptionAgent.cpp. 00251 { 00252 return m_environ->getParam(name, implicit); 00253 }
|
|
Set user and sytem dir and process "script/options.lua" - this will set user and system paths and process "script/init.lua".
Reimplemented from BaseAgent. Definition at line 51 of file OptionAgent.cpp. 00052 { 00053 m_environ = new Environ(); 00054 prepareVersion(); 00055 prepareDataPaths(); 00056 prepareLang(); 00057 }
|
|
Save user config. Delete left messages. Reimplemented from BaseAgent. Definition at line 64 of file OptionAgent.cpp. 00065 {
00066 delete m_environ;
00067 }
|
|
Parse command line options. Format: $0 [name=value ...]
Definition at line 136 of file OptionAgent.cpp. 00137 { 00138 if (argc >= 1) { 00139 setParam("program", argv[0]); 00140 } 00141 00142 for (int i = 1; i < argc; ++i) { 00143 if (argv[i][0] == '-') { 00144 parseDashOpt(argv[i], params); 00145 } 00146 else { 00147 parseParamOpt(argv[i], params); 00148 } 00149 } 00150 }
|
|
Handle incoming message. Messages:
Reimplemented from BaseListener. Definition at line 379 of file OptionAgent.cpp. 00380 { 00381 if (msg->equalsName("param_changed")) { 00382 std::string param = msg->getValue(); 00383 if ("systemdir" == param) { 00384 readSystemConfig(); 00385 } 00386 else if ("userdir" == param) { 00387 readUserConfig(); 00388 } 00389 else { 00390 throw UnknownMsgException(msg); 00391 } 00392 } 00393 else { 00394 throw UnknownMsgException(msg); 00395 } 00396 }
|
|
Definition at line 342 of file OptionAgent.cpp. 00343 { 00344 m_environ->removeWatchers(listenerName); 00345 }
|
|
Definition at line 330 of file OptionAgent.cpp.
|
|
Set value when it is empty.
Definition at line 324 of file OptionAgent.cpp.
|
|
Store this integer value like string param.
Definition at line 235 of file OptionAgent.cpp. 00236 { 00237 m_environ->setParam(name, value); 00238 }
|
|
Set param. Notice watchers. When watcher is not available, it will be removed.
Definition at line 226 of file OptionAgent.cpp. 00227 { 00228 m_environ->setParam(name, value); 00229 }
|
|
Definition at line 315 of file OptionAgent.cpp. 00316 { 00317 setPersistent(name, StringTool::toString(value)); 00318 }
|
|
Set param also on disk. Preserve all current params in options file. Definition at line 290 of file OptionAgent.cpp. 00291 { 00292 //NOTE: path must be created before change of environ 00293 Path config = Path::dataWritePath(CONFIG_FILE); 00294 00295 Environ *swap_env = m_environ; 00296 m_environ = new Environ(); 00297 00298 try { 00299 if (config.exists()) { 00300 ScriptAgent::agent()->doFile(config); 00301 } 00302 } 00303 catch (ScriptException &e) { 00304 LOG_WARNING(e.info()); 00305 } 00306 setParam(name, value); 00307 m_environ->store(config); 00308 00309 delete m_environ; 00310 m_environ = swap_env; 00311 setParam(name, value); 00312 }
|