2010-01-07 16:34:31 +01:00
|
|
|
#ifndef _OWLPS_POSITIONING_INPUTCSV_HH_
|
|
|
|
#define _OWLPS_POSITIONING_INPUTCSV_HH_
|
|
|
|
|
|
|
|
#include "inputmedium.hh"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <fstream>
|
|
|
|
|
2010-03-05 17:24:18 +01:00
|
|
|
/// Reads \link Request requests \endlink from a CSV file
|
2010-01-07 16:34:31 +01:00
|
|
|
class InputCSV: public InputMedium
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
std::string input_file_name ;
|
|
|
|
std::ifstream input_file ;
|
2010-02-02 19:37:37 +01:00
|
|
|
/// Current line contents
|
|
|
|
std::string current_line ;
|
|
|
|
|
|
|
|
/// Checks if the file is readable and closes it if not
|
|
|
|
bool eof_close(void) ;
|
|
|
|
void read_next_line(void) ;
|
2010-01-07 16:34:31 +01:00
|
|
|
|
|
|
|
public:
|
2010-01-16 12:23:07 +01:00
|
|
|
InputCSV(const std::string &filename) ;
|
2010-03-05 17:24:18 +01:00
|
|
|
|
2010-02-16 16:19:39 +01:00
|
|
|
~InputCSV(void) ;
|
2010-01-07 16:34:31 +01:00
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/** @name Read accessors */
|
|
|
|
//@{
|
|
|
|
/// Checks if the end of the CSV file has been reached
|
2010-01-07 16:34:31 +01:00
|
|
|
bool eof(void) const ;
|
2010-01-16 12:23:07 +01:00
|
|
|
//@}
|
2010-01-07 16:34:31 +01:00
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/** @name Operations */
|
|
|
|
//@{
|
|
|
|
/// Reads the next request
|
2010-01-11 19:40:45 +01:00
|
|
|
const Request& get_next_request(void) ;
|
2010-01-16 12:23:07 +01:00
|
|
|
//@}
|
2010-01-07 16:34:31 +01:00
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/** @name Operators */
|
|
|
|
//@{
|
2010-01-07 16:34:31 +01:00
|
|
|
operator bool(void) const ;
|
2010-01-16 12:23:07 +01:00
|
|
|
//@}
|
2010-01-07 16:34:31 +01:00
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/* *** Read accessors *** */
|
2010-01-07 16:34:31 +01:00
|
|
|
|
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/**
|
|
|
|
* @return \em true if the end of file is reached.
|
|
|
|
* @return \em false if there is something more to read.
|
|
|
|
*/
|
2010-01-07 16:34:31 +01:00
|
|
|
inline bool InputCSV::eof() const
|
|
|
|
{
|
2010-02-02 19:37:37 +01:00
|
|
|
return ! input_file && input_file.eof() ;
|
2010-01-07 16:34:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/* *** Operators *** */
|
2010-01-07 16:34:31 +01:00
|
|
|
|
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/**
|
|
|
|
* @return The bool value of #input_file.
|
|
|
|
* @sa std::ifstream
|
|
|
|
*/
|
2010-01-07 16:34:31 +01:00
|
|
|
inline InputCSV::operator bool() const
|
|
|
|
{
|
|
|
|
return input_file ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _OWLPS_POSITIONING_INPUTCSV_HH_
|