From 6745274c94f2693bbe8557c192d8b969e949de3f Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Fri, 17 May 2013 14:02:38 -0400 Subject: [PATCH] [Positioner] Configuration::autocalibration_enabled() Add Configuration::autocalibration_enabled() as a shortcut to test if the autocalibration is enabled. --- owlps-positioner/src/configuration.cc | 6 ++++++ owlps-positioner/src/configuration.hh | 13 +++++++++++++ owlps-positioner/src/fbcm.cc | 2 +- owlps-positioner/src/input.cc | 3 +-- owlps-positioner/src/positioning.cc | 3 +-- owlps-positioner/src/stock.cc | 1 + 6 files changed, 23 insertions(+), 5 deletions(-) diff --git a/owlps-positioner/src/configuration.cc b/owlps-positioner/src/configuration.cc index 585c571..8c20107 100644 --- a/owlps-positioner/src/configuration.cc +++ b/owlps-positioner/src/configuration.cc @@ -126,3 +126,9 @@ string_vector_value(const string &key) { return configuration[key].as< vector >() ; } + + +bool Configuration::autocalibration_enabled() +{ + return string_value("positioning.generate-reference-points") != "false" ; +} diff --git a/owlps-positioner/src/configuration.hh b/owlps-positioner/src/configuration.hh index a3b8838..711e680 100644 --- a/owlps-positioner/src/configuration.hh +++ b/owlps-positioner/src/configuration.hh @@ -54,10 +54,16 @@ private: static boost::program_options::variables_map configuration ; public: + /** @name General accessors */ + //@{ /// Returns a reference to the configuration structure static boost::program_options::variables_map& getw_configuration(void) ; /// Checks if the key exists in the configuration static bool is_configured(const std::string &key) ; + //@} + + /** @name Type-specific accessors */ + //@{ /// Returns the string value corresponding to \em key static const std::string& string_value(const std::string &key) ; /// Returns the int value corresponding to \em key @@ -75,6 +81,13 @@ public: /// Returns the vector value corresponding to \em key static const std::vector& string_vector_value(const std::string &key) ; + //@} + + /** @name Option-specific accessors */ + //@{ + /// Checks if the autocalibration is enabled + static bool autocalibration_enabled(void) ; + //@} } ; #endif // _OWLPS_POSITIONING_CONFIGURATION_HH_ diff --git a/owlps-positioner/src/fbcm.cc b/owlps-positioner/src/fbcm.cc index 2939320..f92fe0a 100644 --- a/owlps-positioner/src/fbcm.cc +++ b/owlps-positioner/src/fbcm.cc @@ -49,7 +49,7 @@ Result FBCM::compute(const Request &_request) { // If the autocalibration is activated, we have to regenerate the // Friis indexes each time we calculate a position - if (Configuration::bool_value("positioning.generate-reference-points")) + if (Configuration::autocalibration_enabled()) Stock::update_all_friis_indexes() ; return TrilaterationAlgorithm::compute(_request) ; } diff --git a/owlps-positioner/src/input.cc b/owlps-positioner/src/input.cc index 260d82f..d8566e4 100644 --- a/owlps-positioner/src/input.cc +++ b/owlps-positioner/src/input.cc @@ -193,8 +193,7 @@ const Request& Input::get_next_request() const calibration_request->reference_point_delete_requests() ; Stock::store_calibration_request(*calibration_request) ; - if (Configuration::bool_value( - "positioning.generate-reference-points")) + if (Configuration::autocalibration_enabled()) Stock::regenerate_reference_points() ; } else if (Configuration::is_configured("verbose")) diff --git a/owlps-positioner/src/positioning.cc b/owlps-positioner/src/positioning.cc index 07326f7..a57d56b 100644 --- a/owlps-positioner/src/positioning.cc +++ b/owlps-positioner/src/positioning.cc @@ -120,8 +120,7 @@ void Positioning::initialise_algorithms() * is not activated (if it is, Friis indexes will be * regenerated each time FBCM wants to computes a position) */ - if (! Configuration:: - bool_value("positioning.generate-reference-points")) + if (! Configuration::autocalibration_enabled()) Stock::update_all_friis_indexes() ; algorithms.push_back(new FBCM) ; } diff --git a/owlps-positioner/src/stock.cc b/owlps-positioner/src/stock.cc index 81cf787..5ded8c5 100644 --- a/owlps-positioner/src/stock.cc +++ b/owlps-positioner/src/stock.cc @@ -461,6 +461,7 @@ closest_reference_point(const Request &request) void Stock::regenerate_reference_points() { + assert(Configuration::autocalibration_enabled()) ; assert(! aps.empty()) ; assert(! reference_points.empty()) ;