owlps/owlps-positioning/src/inputcsv.hh

69 lines
1.1 KiB
C++
Raw Normal View History

#ifndef _OWLPS_POSITIONING_INPUTCSV_HH_
#define _OWLPS_POSITIONING_INPUTCSV_HH_
#include "inputmedium.hh"
#include "textfilereader.hh"
#include <string>
/// Reads \link Request requests \endlink from a CSV file
/**
* CSV format is:
* Mobile_MAC;Timestamp;X;Y;Z;Direction;AP_MAC_1;SS_1;;AP_MAC_n;SS_n
*/
class InputCSV: public InputMedium
{
protected:
TextFileReader file ;
/// Current line contents
std::string current_line ;
void read_next_line(void) ;
public:
InputCSV(const std::string &filename) ;
~InputCSV(void) {}
/** @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 */
//@{
operator bool(void) const ;
//@}
} ;
/* *** Read accessors *** */
inline bool InputCSV::eof() const
{
return file.eof() ;
}
/* *** Operators *** */
inline InputCSV::operator bool() const
{
return ! eof() ;
}
#endif // _OWLPS_POSITIONING_INPUTCSV_HH_