[Positioning] Add class Output
Add class Output to handle outputs. Update UserInterface to add option "output.medium"; update posexcept.
This commit is contained in:
parent
7088e524d4
commit
9ed1000bb3
|
@ -55,6 +55,7 @@ OBJ_LIST = \
|
|||
realposition.o \
|
||||
configuration.o \
|
||||
userinterface.o \
|
||||
output.o \
|
||||
outputterminal.o \
|
||||
input.o \
|
||||
inputcsv.o \
|
||||
|
@ -134,6 +135,18 @@ inputlogcsv.o: \
|
|||
$(SRC_DIR)/inputlogmedium.hh \
|
||||
$(OBJ_DIR)/request.o
|
||||
input.o: \
|
||||
$(OBJ_DIR)/inputcsv.o \
|
||||
$(OBJ_DIR)/inputlogcsv.o \
|
||||
$(OBJ_DIR)/calibrationrequest.o \
|
||||
$(OBJ_DIR)/configuration.o \
|
||||
$(OBJ_DIR)/posexcept.o \
|
||||
$(OBJ_DIR)/stock.o
|
||||
outputterminal.o: \
|
||||
$(SRC_DIR)/outputmedium.hh \
|
||||
$(OBJ_DIR)/result.o
|
||||
output.o: \
|
||||
$(OBJ_DIR)/outputterminal.o \
|
||||
$(OBJ_DIR)/configuration.o \
|
||||
$(OBJ_DIR)/posexcept.o
|
||||
realposition.o: \
|
||||
$(SRC_DIR)/positioningalgorithm.hh \
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
|
||||
- Tests unitaires
|
||||
Remplacer TS_ASSERT_DIFFERS(a, b) par TS_ASSERT(a != b) pour tester
|
||||
operator!=() au lieu de !operator==().
|
||||
|
||||
- Input
|
||||
° Finir le test unitaire.
|
||||
° Remplacer TS_ASSERT_DIFFERS(a, b) par TS_ASSERT(a != b) pour
|
||||
tester operator!=() au lieu de !operator==().
|
||||
° Finir le test de Input.
|
||||
° Finir le test de Output.
|
||||
|
||||
- PosUtil
|
||||
° Déplacer les #define des canaux Wi-Fi dans le .cc
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
#include "output.hh"
|
||||
#include "outputterminal.hh"
|
||||
#include "configuration.hh"
|
||||
#include "posexcept.hh"
|
||||
|
||||
#include <string>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
|
||||
|
||||
/* *** Constructors *** */
|
||||
|
||||
|
||||
Output::Output()
|
||||
{
|
||||
initialise_output_media() ;
|
||||
}
|
||||
|
||||
|
||||
Output::~Output()
|
||||
{
|
||||
for (vector<OutputMedium*>::const_iterator i = output_media.begin() ;
|
||||
i != output_media.end() ; ++i)
|
||||
delete *i ;
|
||||
output_media.clear() ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* *** Operations *** */
|
||||
|
||||
|
||||
void Output::initialise_output_media()
|
||||
{
|
||||
if (! Configuration::is_configured("output.medium"))
|
||||
{
|
||||
initialise_output_terminal() ;
|
||||
return ;
|
||||
}
|
||||
|
||||
const vector<string> &media_names =
|
||||
Configuration::string_vector_value("output.medium") ;
|
||||
|
||||
for (vector<string>::const_iterator i = media_names.begin() ;
|
||||
i != media_names.end() ; ++i)
|
||||
{
|
||||
if (*i == "Terminal")
|
||||
initialise_output_terminal() ;
|
||||
|
||||
else
|
||||
throw output_medium_type_unknown(*i) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Output::initialise_output_terminal()
|
||||
{
|
||||
output_media.push_back(new OutputTerminal) ;
|
||||
}
|
||||
|
||||
|
||||
void Output::write(const Result &result) const
|
||||
{
|
||||
for (vector<OutputMedium*>::const_iterator i = output_media.begin() ;
|
||||
i != output_media.end() ; ++i)
|
||||
(*i)->write(result) ;
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
#ifndef _OWLPS_POSITIONING_OUTPUT_HH_
|
||||
#define _OWLPS_POSITIONING_OUTPUT_HH_
|
||||
|
||||
class OutputMedium ;
|
||||
class Result ;
|
||||
|
||||
#include <vector>
|
||||
|
||||
/// Handles the outputs
|
||||
class Output
|
||||
{
|
||||
protected:
|
||||
/// List of output media used
|
||||
std::vector<OutputMedium*> output_media ;
|
||||
|
||||
/** @name Internal operations */
|
||||
//@{
|
||||
void initialise_output_media(void) ;
|
||||
void initialise_output_terminal(void) ;
|
||||
//@}
|
||||
|
||||
public:
|
||||
Output(void) ;
|
||||
|
||||
~Output(void) ;
|
||||
|
||||
/** @name Operations */
|
||||
//@{
|
||||
void write(const Result &result) const ;
|
||||
//@}
|
||||
} ;
|
||||
|
||||
#endif // _OWLPS_POSITIONING_OUTPUT_HH_
|
|
@ -5,6 +5,7 @@
|
|||
using namespace std ;
|
||||
|
||||
|
||||
|
||||
bad_direction::bad_direction(const char _direction) throw()
|
||||
{
|
||||
direction = _direction ;
|
||||
|
@ -32,6 +33,10 @@ const char* element_not_found::what() const throw()
|
|||
}
|
||||
|
||||
|
||||
|
||||
/* *** Input *** */
|
||||
|
||||
|
||||
/**
|
||||
* @param _medium_name The medium that is unknown
|
||||
*/
|
||||
|
@ -83,3 +88,23 @@ const char* error_opening_input_file::what() const throw()
|
|||
file_name + " »!" ;
|
||||
return message.c_str() ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* *** Output *** */
|
||||
|
||||
|
||||
/**
|
||||
* @param _medium_name The medium that is unknown
|
||||
*/
|
||||
output_medium_type_unknown::
|
||||
output_medium_type_unknown(const string &_medium_name) throw():
|
||||
medium_name(_medium_name) {}
|
||||
|
||||
|
||||
const char* output_medium_type_unknown::what() const throw()
|
||||
{
|
||||
string message = "The specified output medium « "+ medium_name +
|
||||
" » is unknown!" ;
|
||||
return message.c_str() ;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <string>
|
||||
|
||||
|
||||
|
||||
class bad_direction: public std::exception
|
||||
{
|
||||
private:
|
||||
|
@ -28,6 +29,10 @@ public:
|
|||
} ;
|
||||
|
||||
|
||||
|
||||
/* *** Input *** */
|
||||
|
||||
|
||||
class input_medium_type_unknown: public std::exception
|
||||
{
|
||||
private:
|
||||
|
@ -80,4 +85,20 @@ public:
|
|||
} ;
|
||||
|
||||
|
||||
/* *** Output *** */
|
||||
|
||||
|
||||
class output_medium_type_unknown: public std::exception
|
||||
{
|
||||
private:
|
||||
std::string medium_name ;
|
||||
|
||||
public:
|
||||
output_medium_type_unknown(const std::string &_medium_name) throw() ;
|
||||
~output_medium_type_unknown(void) throw() {}
|
||||
const char* what(void) const throw() ;
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
#endif // _OWLPS_POSITIONING_POSEXCEPT_HH_
|
||||
|
|
|
@ -92,6 +92,11 @@ this option more than once. Allowed: none, CSV. The `none` value \
|
|||
completely disables logging.")
|
||||
("log.csv-file", po::value<string>(),
|
||||
"CSV file to use for logging (when log.medium = CSV).")
|
||||
// Output options
|
||||
("output.medium,O", po::value< vector<string> >()->composing(),
|
||||
"Medium to which the results will be wrote. You can specify \
|
||||
this option more than once. Allowed: Terminal. If this option is \
|
||||
absent, results will be printed on the terminal.")
|
||||
;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
#include <cxxtest/TestSuite.h>
|
||||
|
||||
#include "output.hh"
|
||||
|
||||
class Output_test: public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
|
||||
void test_constructor(void)
|
||||
{
|
||||
TS_ASSERT_THROWS_NOTHING(Output output1) ;
|
||||
// TODO: test with a mock Configuration
|
||||
}
|
||||
|
||||
} ;
|
Loading…
Reference in New Issue