84 lines
1.5 KiB
C++
84 lines
1.5 KiB
C++
#ifndef _OWLPS_POSITIONING_DIRECTION_HH_
|
|
#define _OWLPS_POSITIONING_DIRECTION_HH_
|
|
|
|
#include <string>
|
|
|
|
/// \brief Represents a direction in which a mobile is when it sends a
|
|
/// CalibrationRequest
|
|
class Direction
|
|
{
|
|
protected:
|
|
char direction ;
|
|
|
|
void assert_valid(void) const ;
|
|
bool is_valid(void) const ;
|
|
|
|
public:
|
|
enum {north = 1, east, south, west} ;
|
|
|
|
Direction(void): direction(0) {}
|
|
Direction(const char source) ;
|
|
Direction(const Direction &source): direction(source.direction) {}
|
|
|
|
/** @name Accessors */
|
|
//@{
|
|
void clear(void) ;
|
|
//@}
|
|
|
|
/** @name Operators */
|
|
//@{
|
|
const Direction& operator=(const Direction &source) ;
|
|
const Direction& operator=(const char source) ;
|
|
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 ;
|
|
//@}
|
|
|
|
// Hashes a Direction
|
|
friend size_t hash_value(const Direction &source) ;
|
|
} ;
|
|
|
|
|
|
|
|
/* *** 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 bool() const
|
|
{
|
|
return is_valid() ;
|
|
}
|
|
|
|
|
|
inline Direction::operator int() const
|
|
{
|
|
return static_cast<int>(direction) ;
|
|
}
|
|
|
|
|
|
|
|
#endif // _OWLPS_POSITIONING_DIRECTION_HH_
|