2012-02-06 16:44:09 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the Owl Positioning System (OwlPS).
|
|
|
|
* OwlPS is a project of the University of Franche-Comté
|
|
|
|
* (Université de Franche-Comté), France.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2010-02-11 09:46:40 +01:00
|
|
|
#include "configuration.hh"
|
|
|
|
|
2010-02-16 16:19:39 +01:00
|
|
|
using namespace std ;
|
2010-02-11 09:46:40 +01:00
|
|
|
namespace po = boost::program_options ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* *** Attribute definitions *** */
|
|
|
|
|
|
|
|
po::variables_map Configuration::configuration ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* *** Read accessors *** */
|
|
|
|
|
|
|
|
|
|
|
|
po::variables_map& Configuration::getw_configuration()
|
|
|
|
{
|
|
|
|
return configuration ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-16 16:19:39 +01:00
|
|
|
bool Configuration::is_configured(const string &key)
|
2010-02-11 09:46:40 +01:00
|
|
|
{
|
|
|
|
if (configuration.count(key))
|
|
|
|
return true ;
|
|
|
|
return false ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const std::string&
|
2010-02-16 16:19:39 +01:00
|
|
|
Configuration::string_value(const string &key)
|
2010-02-11 09:46:40 +01:00
|
|
|
{
|
2010-02-16 16:19:39 +01:00
|
|
|
return configuration[key].as<string>() ;
|
2010-02-11 09:46:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-16 16:19:39 +01:00
|
|
|
int Configuration::int_value(const string &key)
|
2010-02-11 09:46:40 +01:00
|
|
|
{
|
|
|
|
return configuration[key].as<int>() ;
|
|
|
|
}
|
2010-02-16 16:19:39 +01:00
|
|
|
|
|
|
|
|
2011-07-23 18:09:58 +02:00
|
|
|
float Configuration::float_value(const string &key)
|
|
|
|
{
|
|
|
|
return configuration[key].as<float>() ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-29 14:19:31 +02:00
|
|
|
bool Configuration::bool_value(const string &key)
|
|
|
|
{
|
|
|
|
return configuration[key].as<bool>() ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-20 12:11:20 +02:00
|
|
|
/**
|
|
|
|
* @return \em true if the string \em value exists in the vector \em key.
|
|
|
|
* @return \em false if \em value is not found in \em key.
|
|
|
|
*/
|
2010-02-16 16:19:39 +01:00
|
|
|
bool Configuration::
|
|
|
|
value_exists_in_string_vector(const string &key, const string &value)
|
|
|
|
{
|
|
|
|
if (! is_configured(key))
|
|
|
|
return false ;
|
|
|
|
|
|
|
|
vector<string> key_values = configuration[key].as< vector<string> >() ;
|
|
|
|
|
|
|
|
for (vector<string>::const_iterator i = key_values.begin() ;
|
|
|
|
i != key_values.end() ; ++i)
|
|
|
|
if (*i == value)
|
|
|
|
return true ;
|
|
|
|
|
|
|
|
return false ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-20 12:11:20 +02:00
|
|
|
const vector<string>& Configuration::
|
|
|
|
string_vector_value(const string &key)
|
2010-02-16 16:19:39 +01:00
|
|
|
{
|
|
|
|
return configuration[key].as< vector<string> >() ;
|
|
|
|
}
|