owlps/owlps-positioner/inputcsv.hh

82 lines
1.7 KiB
C++

/*
* This file is part of the Owl Positioning System (OwlPS) project.
* It is subject to the copyright notice and license terms in the
* COPYRIGHT.t2t file found in the top-level directory of this
* distribution and at
* http://code.lm7.fr/p/owlps/source/tree/master/COPYRIGHT.t2t
* No part of the OwlPS Project, including this file, may be copied,
* modified, propagated, or distributed except according to the terms
* contained in the COPYRIGHT.t2t file; the COPYRIGHT.t2t file must be
* distributed along with this file, either separately or by replacing
* this notice by the COPYRITGHT.t2t file's contents.
*/
#ifndef _OWLPS_POSITIONING_INPUTCSV_HH_
#define _OWLPS_POSITIONING_INPUTCSV_HH_
#include "inputmedium.hh"
#include "csvfilereader.hh"
#include <string>
/// Reads [requests](@ref Request) from a CSV file
/**
* CSV format is:
* Format_version;Mobile_MAC;Request_type;Number_of_packets;
* Timestamp;X;Y;Z;Direction;AP_MAC_1;Packet_ID_1;SS_1;…;
* AP_MAC_n;Packet_ID_n;SS_n
*/
class InputCSV: public InputMedium
{
protected:
CSVFileReader file ;
/** @name Operations */
//@{
/// Reads data & fills the current request
bool fill_current_request(void) ;
//@}
public:
InputCSV(const std::string &filename):
file(filename) {}
~InputCSV(void) {}
/** @name Read accessors */
//@{
/// Checks if the end of the CSV file has been reached
bool eof(void) const ;
//@}
/** @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_