88 lines
1.7 KiB
C++
88 lines
1.7 KiB
C++
#ifndef _OWLPS_POSITIONING_INPUTMEDIUM_HH_
|
|
#define _OWLPS_POSITIONING_INPUTMEDIUM_HH_
|
|
|
|
#include "request.hh"
|
|
|
|
/// Super class of all input media
|
|
/**
|
|
* Provide interface for input media, i.e. to read Request sent by a
|
|
* Mobile.
|
|
*/
|
|
class InputMedium
|
|
{
|
|
protected:
|
|
/// The Request just read
|
|
Request current_request ;
|
|
/// Number of the current line proceeded
|
|
unsigned long current_line_nb ;
|
|
|
|
public:
|
|
/// Default constructor
|
|
InputMedium(void) ;
|
|
|
|
virtual ~InputMedium(void) {} ///< Destructor (do nothing)
|
|
|
|
/** @name Read accessors */
|
|
//@{
|
|
|
|
/// #current_request read accessor
|
|
const Request& get_current_request(void) const ;
|
|
|
|
/// #current_line_nb read accessor
|
|
unsigned int get_current_line_nb(void) const ;
|
|
|
|
/// Checks if the last request has been reached
|
|
/**
|
|
* @return \em true if the last request has been reached.
|
|
* @return \em false if there is something more to read.
|
|
*/
|
|
virtual bool eof(void) const = 0 ;
|
|
|
|
//@} // End Read accessors
|
|
|
|
/** @name Operations */
|
|
//@{
|
|
|
|
/// Reads the next request
|
|
/**
|
|
* Reads a Request, increments current_line_nb, updates #current_request
|
|
* and returns it.
|
|
* @return The Request read, or an empty Request in case of error or
|
|
* EOF (note that when casted in bool, an empty Request is false, see
|
|
* Request::operator bool()).
|
|
*/
|
|
virtual const Request& get_next_request(void) = 0 ;
|
|
|
|
//@} // End Operations
|
|
} ;
|
|
|
|
|
|
|
|
/* *** Constructors *** */
|
|
|
|
|
|
inline InputMedium::InputMedium()
|
|
{
|
|
current_line_nb = 0 ;
|
|
}
|
|
|
|
|
|
|
|
/* *** Read accessors *** */
|
|
|
|
|
|
inline const Request& InputMedium::get_current_request() const
|
|
{
|
|
return current_request ;
|
|
}
|
|
|
|
|
|
inline unsigned int InputMedium::get_current_line_nb() const
|
|
{
|
|
return current_line_nb ;
|
|
}
|
|
|
|
|
|
|
|
#endif // _OWLPS_POSITIONING_INPUTMEDIUM_HH_
|