owlps/owlps-positioning/inputcsv.hh

72 lines
1.2 KiB
C++

#ifndef _OWLPS_POSITIONING_INPUTCSV_HH_
#define _OWLPS_POSITIONING_INPUTCSV_HH_
#include "inputmedium.hh"
#include <string>
#include <fstream>
/// Reads requests (Request) from a CSV file
class InputCSV: public InputMedium
{
protected:
/// Name of the input CSV file
std::string input_file_name ;
/// Stream corresponding to the input CSV file
std::ifstream input_file ;
public:
/// Constructs an InputCSV from a CSV input file name
InputCSV(const std::string &filename) ;
/** @name Read accessors */
//@{
/// Checks if the end of the CSV file has been reached
bool eof(void) const ;
//@}
/** @name Operations */
//@{
/// Reads the next request
const Request& get_next_request(void) ;
//@}
/** @name Operators */
//@{
/// Cast to bool operator
operator bool(void) const ;
//@}
} ;
/* *** Read accessors *** */
/**
* @return \em true if the end of file is reached.
* @return \em false if there is something more to read.
*/
inline bool InputCSV::eof() const
{
return input_file.eof() ;
}
/* *** Operators *** */
/**
* @return The bool value of #input_file.
* @sa std::ifstream
*/
inline InputCSV::operator bool() const
{
return input_file ;
}
#endif // _OWLPS_POSITIONING_INPUTCSV_HH_