#include <map>
#include <string>
-#include <Moof/Singleton.hh>
#include <Moof/Serializable.hh>
namespace Mf {
-class Settings : public Singleton<Settings>
+class Settings
{
public:
Settings() {}
Settings(int argc, char* argv[]);
+ // get global instance
+ static Settings& getInstance();
+
void parseArgs(int argc, char* argv[]);
void loadFromFile(const std::string& filePath, bool precedence = false);
bool getNumber(const std::string& key, T& value);
private:
- std::map<std::string,SerializablePtr> map_;
+ Serializable::Map map_;
};
template <typename T>
bool Settings::get(const std::string& key, T& value)
{
- std::map<std::string,SerializablePtr>::const_iterator it = map_.find(key);
+ Serializable::Map::const_iterator it = map_.find(key);
if (it != map_.end())
{
- SerializablePtr obj = (*it).second;
+ SerializableP obj = (*it).second;
return obj->get(value);
}
else
template <typename T>
bool Settings::getNumber(const std::string& key, T& value)
{
- std::map<std::string,SerializablePtr>::const_iterator it = map_.find(key);
+ Serializable::Map::const_iterator it = map_.find(key);
if (it != map_.end())
{
- SerializablePtr obj = (*it).second;
+ SerializableP obj = (*it).second;
return obj->getNumber(value);
}
else