19 #ifndef _CONFIGURATION_HPP_
20 #define _CONFIGURATION_HPP_
26 #include <boost/filesystem.hpp>
30 namespace bfs = boost::filesystem;
41 void addAppInstance (
const std::string &instanceId) { instances.insert(instanceId); }
42 bool isAllowedInstance(
const std::string &instanceId) {
return (all_instances)?
true:(instances.find(instanceId) != instances.end()); }
50 static Config*
instance(
const std::string app_id =
"kisscpp_application",
51 const std::string app_instance =
"0",
52 const std::string explicit_config_path =
"");
54 void initiate(
const std::string explicit_config_path =
"");
63 template<
typename T> T
get (
const std::string &s) {
return cfg_data.get <T>(s); }
64 template<
typename T> T
get (
const std::string &s, T default_value) {
return cfg_data.get <T>(s,default_value); }
65 template<
typename T> boost::optional<T>
get_optional(
const std::string &s) {
return cfg_data.get_optional<T>(s); }
67 std::string
getAppId() {
return application_id; }
71 bool isAllowedClient(
const std::string &app_id,
const std::string &app_instance);
82 Config(
const std::string app_id,
83 const std::string app_instance,
84 const std::string explicit_config_path) :
85 allow_all_ip_addrs (false),
86 allow_all_applications(false)
90 application_id = app_id;
91 application_instance = app_instance;
97 bool loadConfig (std::string &cfg_path,
BoostPtree &pt);
98 void populateWhiteLists ();
99 void populateDefaultDirs();
101 static Config *singleton_instance;
103 std::string config_path_instance;
104 std::string config_path_common;
108 std::string application_id;
109 std::string application_instance;
111 bool allow_all_ip_addrs;
112 bool allow_all_applications;
119 #endif // _STATSKEEPER_HPP_
std::map< std::string, InstanceListType > MappedWhiteListType
Definition: configuration.hpp:45
WhiteListType instances
Definition: configuration.hpp:39
boost::property_tree::ptree BoostPtree
Definition: boost_ptree.hpp:31
BoostPtree get_child(const std::string &s)
Definition: configuration.hpp:62
std::set< std::string > WhiteListType
Definition: configuration.hpp:34
std::string getAppId()
Definition: configuration.hpp:67
Definition: logstream.hpp:145
bool isAllowedIp(const std::string &ip_address)
Definition: configuration.cpp:65
void addAppInstance(const std::string &instanceId)
Definition: configuration.hpp:41
boost::optional< T > get_optional(const std::string &s)
Definition: configuration.hpp:65
void initiate(const std::string explicit_config_path="")
Definition: configuration.cpp:38
bool all_instances
Definition: configuration.hpp:38
bool isAllowedClient(const std::string &app_id, const std::string &app_instance)
Definition: configuration.cpp:79
~Config()
Definition: configuration.hpp:56
std::string getAppInstance()
Definition: configuration.hpp:68
bool isAllowedInstance(const std::string &instanceId)
Definition: configuration.hpp:42
Definition: configuration.hpp:47
static Config * instance(const std::string app_id="kisscpp_application", const std::string app_instance="0", const std::string explicit_config_path="")
Definition: configuration.cpp:26