2012-02-06 16:44:09 +01:00
|
|
|
/*
|
2013-05-29 18:43:35 +02:00
|
|
|
* 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
|
2016-11-03 05:10:34 +01:00
|
|
|
* https://code.lm7.fr/mcy/owlps/src/master/COPYRIGHT.t2t
|
2013-05-29 18:43:35 +02:00
|
|
|
* 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
|
2013-06-22 23:30:17 +02:00
|
|
|
* this notice by the COPYRIGHT.t2t file's contents.
|
2012-02-06 16:44:09 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2010-02-18 12:23:05 +01:00
|
|
|
#ifndef _OWLPS_POSITIONING_DIRECTION_HH_
|
|
|
|
#define _OWLPS_POSITIONING_DIRECTION_HH_
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
2013-06-04 00:39:10 +02:00
|
|
|
/// Represents a direction in which a mobile is when it sends a
|
2010-02-18 12:23:05 +01:00
|
|
|
/// CalibrationRequest
|
|
|
|
class Direction
|
|
|
|
{
|
|
|
|
protected:
|
2013-06-17 21:24:56 +02:00
|
|
|
uint_fast8_t direction ;
|
2010-02-18 12:23:05 +01:00
|
|
|
|
|
|
|
void assert_valid(void) const ;
|
|
|
|
bool is_valid(void) const ;
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum {north = 1, east, south, west} ;
|
|
|
|
|
|
|
|
Direction(void): direction(0) {}
|
2013-06-17 21:24:56 +02:00
|
|
|
Direction(const uint_fast8_t source) ;
|
2010-02-18 12:23:05 +01:00
|
|
|
Direction(const Direction &source): direction(source.direction) {}
|
|
|
|
|
|
|
|
/** @name Accessors */
|
|
|
|
//@{
|
|
|
|
void clear(void) ;
|
|
|
|
//@}
|
|
|
|
|
|
|
|
/** @name Operators */
|
|
|
|
//@{
|
2011-07-30 20:38:42 +02:00
|
|
|
Direction& operator=(const Direction &source) ;
|
2013-06-17 21:24:56 +02:00
|
|
|
Direction& operator=(const uint_fast8_t source) ;
|
2010-02-18 12:23:05 +01:00
|
|
|
bool operator==(const Direction &source) const ;
|
|
|
|
bool operator!=(const Direction &source) const ;
|
|
|
|
operator bool(void) const ;
|
|
|
|
operator int(void) const ;
|
|
|
|
operator std::string(void) const ;
|
|
|
|
//@}
|
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* *** Accessors *** */
|
|
|
|
|
|
|
|
|
|
|
|
inline void Direction::clear()
|
|
|
|
{
|
|
|
|
direction = 0 ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* *** Operators *** */
|
|
|
|
|
|
|
|
|
|
|
|
inline bool Direction::operator==(const Direction &source) const
|
|
|
|
{
|
|
|
|
return direction == source.direction ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline bool Direction::operator!=(const Direction &source) const
|
|
|
|
{
|
|
|
|
return !(*this == source) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline Direction::operator int() const
|
|
|
|
{
|
|
|
|
return static_cast<int>(direction) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-05-30 20:13:44 +02:00
|
|
|
namespace std
|
|
|
|
{
|
|
|
|
template<> struct hash<Direction>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
size_t operator()(const Direction &source) const
|
|
|
|
{
|
|
|
|
hash<int> h ;
|
|
|
|
return h(source) ;
|
|
|
|
}
|
|
|
|
} ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-02-18 12:23:05 +01:00
|
|
|
#endif // _OWLPS_POSITIONING_DIRECTION_HH_
|