owlps/owlps-positioner/inputmedium.hh

106 lines
2.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
* https://code.lm7.fr/mcy/owlps/src/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 COPYRIGHT.t2t file's contents.
*/
#ifndef _OWLPS_POSITIONING_INPUTMEDIUM_HH_
#define _OWLPS_POSITIONING_INPUTMEDIUM_HH_
class ReferencePoint ;
class Direction ;
#include "request.hh"
#include <string>
/// Super class of all input media
/**
* This class Provides an interface for input media, i.e. to read
* Request sent by a Mobile.
*/
class InputMedium
{
protected:
Request *current_request ;
/// Number of the current line proceeded
unsigned long current_line_nb ;
/** @name Operations */
//@{
/// Reads data & fills the current request
virtual bool fill_current_request(void) = 0 ;
/// Checks if the current request is a calibration request and, if so,
/// fills it with additionnal data
void fill_calibration_request_data(const std::string &mac_mobile,
Point3D &position,
const Direction &direction,
const uint8_t type) ;
//@}
public:
InputMedium(void) ;
virtual ~InputMedium(void) ;
/** @name Read accessors */
//@{
const Request& get_current_request(void) const ;
unsigned int get_current_line_nb(void) const ;
/// Checks if the last request has been reached
/**
* @returns `true` if the last request has been reached.
* @returns `false` if there is something more to read.
*/
virtual bool eof(void) const = 0 ;
//@} // End Read accessors
/** @name Operations */
//@{
/// Reads the next request
const Request& get_next_request(void) ;
/// Converts #current_request into a CalibrationRequest
void current_request_to_calibration_request(
const ReferencePoint *const reference_point,
const Direction &direction,
const uint_fast8_t request_type) ;
/// Clears (reallocates to Request if needed) #current_request
void clear_current_request(void) ;
//@} // End Operations
} ;
/* *** 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_