diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2014-02-10 16:46:53 -0800 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2014-02-10 16:46:53 -0800 |
commit | 33728840ecec854fbf2f5d100d415cd66e261802 (patch) | |
tree | 7c2c9c683578b2ea4f84734788fe67edceb82f29 | |
parent | cd339486b70d8d43ea9fd64c764e63c65730f4cb (diff) | |
download | infinitytier-33728840ecec854fbf2f5d100d415cd66e261802.tar.gz infinitytier-33728840ecec854fbf2f5d100d415cd66e261802.zip |
More local.conf stuff.
-rw-r--r-- | node/NodeConfig.cpp | 23 | ||||
-rw-r--r-- | node/NodeConfig.hpp | 18 |
2 files changed, 41 insertions, 0 deletions
diff --git a/node/NodeConfig.cpp b/node/NodeConfig.cpp index ea2b5946..777b596b 100644 --- a/node/NodeConfig.cpp +++ b/node/NodeConfig.cpp @@ -118,6 +118,29 @@ NodeConfig::~NodeConfig() _writeLocalConfig(); } +void NodeConfig::putLocalConfig(const std::string &key,const char *value) +{ + Mutex::Lock _l(_localConfig_m); + _localConfig[key] = value; + _writeLocalConfig(); +} + +void NodeConfig::putLocalConfig(const std::string &key,const std::string &value) +{ + Mutex::Lock _l(_localConfig_m); + _localConfig[key] = value; + _writeLocalConfig(); +} + +std::string NodeConfig::getLocalConfig(const std::string &key) const +{ + Mutex::Lock _l(_localConfig_m); + Dictionary::const_iterator i(_localConfig.find(key)); + if (i == _localConfig.end()) + return std::string(); + return i->second; +} + void NodeConfig::clean() { Mutex::Lock _l(_networks_m); diff --git a/node/NodeConfig.hpp b/node/NodeConfig.hpp index d7a3984a..164bd891 100644 --- a/node/NodeConfig.hpp +++ b/node/NodeConfig.hpp @@ -69,6 +69,24 @@ public: ~NodeConfig(); /** + * Store something in local configuration cache + * + * By convention, keys starting with _ will not be shown in the command bus + * local config functions. + * + * @param key Configuration key + * @param value Configuration value + */ + void putLocalConfig(const std::string &key,const char *value); + void putLocalConfig(const std::string &key,const std::string &value); + + /** + * @param key Configuration key + * @return Value or empty string if not found + */ + std::string getLocalConfig(const std::string &key) const; + + /** * @param nwid Network ID * @return Network or NULL if no network for that ID */ |