65 lines
1.0 KiB
C++
65 lines
1.0 KiB
C++
|
#include "input.hh"
|
||
|
#include "inputcsv.hh"
|
||
|
#include "request.hh"
|
||
|
#include "configuration.hh"
|
||
|
#include "posexcept.hh"
|
||
|
|
||
|
using namespace std ;
|
||
|
|
||
|
|
||
|
/* *** Constructors *** */
|
||
|
|
||
|
|
||
|
Input::Input()
|
||
|
{
|
||
|
medium = NULL ;
|
||
|
initialise_input_medium() ;
|
||
|
}
|
||
|
|
||
|
|
||
|
Input::~Input()
|
||
|
{
|
||
|
delete medium ;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
/* *** Operations *** */
|
||
|
|
||
|
|
||
|
void Input::initialise_input_medium()
|
||
|
{
|
||
|
if (! Configuration::is_configured("input.medium"))
|
||
|
throw no_input_medium() ;
|
||
|
|
||
|
const string &medium_name =
|
||
|
Configuration::get_string_value("input.medium") ;
|
||
|
|
||
|
if (medium_name == "CSV")
|
||
|
{
|
||
|
if (! Configuration::is_configured("input.csv-file"))
|
||
|
throw no_input_csv_file() ;
|
||
|
medium = new
|
||
|
InputCSV(Configuration::get_string_value("input.csv-file")) ;
|
||
|
}
|
||
|
|
||
|
else
|
||
|
throw input_medium_type_unknown(medium_name) ;
|
||
|
}
|
||
|
|
||
|
|
||
|
const Request& Input::get_next_request() const
|
||
|
{
|
||
|
if (medium == NULL)
|
||
|
throw null_input_medium() ;
|
||
|
return medium->get_next_request() ;
|
||
|
}
|
||
|
|
||
|
|
||
|
bool Input::eof() const
|
||
|
{
|
||
|
if (medium == NULL)
|
||
|
throw null_input_medium() ;
|
||
|
return medium->eof() ;
|
||
|
}
|