2012-02-06 16:44:09 +01:00
|
|
|
/*
|
2013-05-29 18:43:35 +02:00
|
|
|
* This file is part of the Owl Positioning System (OwlPS) project.
|
|
|
|
* It is subject to the copyright notice and license terms in the
|
|
|
|
* COPYRIGHT.t2t file found in the top-level directory of this
|
|
|
|
* distribution and at
|
2016-11-03 05:10:34 +01:00
|
|
|
* https://code.lm7.fr/mcy/owlps/src/master/COPYRIGHT.t2t
|
2013-05-29 18:43:35 +02:00
|
|
|
* No part of the OwlPS Project, including this file, may be copied,
|
|
|
|
* modified, propagated, or distributed except according to the terms
|
|
|
|
* contained in the COPYRIGHT.t2t file; the COPYRIGHT.t2t file must be
|
|
|
|
* distributed along with this file, either separately or by replacing
|
2013-06-22 23:30:17 +02:00
|
|
|
* this notice by the COPYRIGHT.t2t file's contents.
|
2012-02-06 16:44:09 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
2012-01-26 09:41:41 +01:00
|
|
|
unsigned int Configuration::uint_value(const string &key)
|
|
|
|
{
|
|
|
|
return configuration[key].as<unsigned int>() ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
/**
|
2013-05-30 21:23:05 +02:00
|
|
|
* @returns `true` if the string `value` exists in the vector `key.`
|
|
|
|
* @returns `false` if `value` is not found in `key.`
|
2011-06-20 12:11:20 +02:00
|
|
|
*/
|
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> >() ;
|
|
|
|
|
2013-10-02 22:22:20 +02:00
|
|
|
for (auto i = key_values.begin() ; i != key_values.end() ; ++i)
|
2010-02-16 16:19:39 +01:00
|
|
|
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> >() ;
|
|
|
|
}
|
2013-05-17 20:02:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
bool Configuration::autocalibration_enabled()
|
|
|
|
{
|
|
|
|
return string_value("positioning.generate-reference-points") != "false" ;
|
|
|
|
}
|