68 lines
1.3 KiB
C++
68 lines
1.3 KiB
C++
#include "positioning.hh"
|
|
#include "realposition.hh"
|
|
#include "configuration.hh"
|
|
#include "posexcept.hh"
|
|
|
|
using namespace std ;
|
|
|
|
|
|
|
|
/* *** Constructors *** */
|
|
|
|
|
|
Positioning::Positioning()
|
|
{
|
|
initialise_algorithms() ;
|
|
loop() ;
|
|
}
|
|
|
|
|
|
Positioning::~Positioning()
|
|
{
|
|
for (vector<PositioningAlgorithm*>::const_iterator i =
|
|
algorithms.begin() ; i != algorithms.end() ; ++i)
|
|
delete *i ;
|
|
algorithms.clear() ;
|
|
}
|
|
|
|
|
|
|
|
/* *** Operations *** */
|
|
|
|
|
|
void Positioning::initialise_algorithms()
|
|
{
|
|
if (! Configuration::is_configured("positioning.algorithm"))
|
|
throw no_positioning_algorithm() ;
|
|
|
|
const vector<string> &algo_names =
|
|
Configuration::string_vector_value("positioning.algorithm") ;
|
|
|
|
for (vector<string>::const_iterator i = algo_names.begin() ;
|
|
i != algo_names.end() ; ++i)
|
|
{
|
|
if (*i == "Real")
|
|
algorithms.push_back(new RealPosition) ;
|
|
|
|
else
|
|
throw positioning_algorithm_unknown(*i) ;
|
|
}
|
|
}
|
|
|
|
|
|
void Positioning::loop()
|
|
{
|
|
vector<PositioningAlgorithm*>::const_iterator algo ;
|
|
|
|
while (! input.eof())
|
|
{
|
|
const Request &request = input.get_next_request() ;
|
|
for (algo = algorithms.begin() ; algo != algorithms.end() ;
|
|
++algo)
|
|
{
|
|
Result res = (*algo)->compute(request) ;
|
|
output.write(res) ;
|
|
}
|
|
}
|
|
}
|