owlps/owlps-positioning/src/building.hh

125 lines
2.5 KiB
C++

/*
* This file is part of the Owl Positioning System (OwlPS).
* OwlPS is a project of the University of Franche-Comté
* (Université de Franche-Comté), France.
*/
#ifndef _OWLPS_POSITIONING_BUILDING_HH_
#define _OWLPS_POSITIONING_BUILDING_HH_
class Area ;
class Waypoint ;
#include <string>
#include <ostream>
#include <boost/tr1/unordered_set.hpp>
#include <boost/tr1/unordered_map.hpp>
/// Represents a building, containing one or more Area
class Building
{
protected:
std::string name ;
/// List of Area contained in the Building
std::tr1::unordered_map<std::string, Area*> areas ;
/// List of Waypoint in the Building
std::tr1::unordered_set<Waypoint*> waypoints ;
public :
Building(const std::string &_name = "Unnamed building"):
name(_name) {}
Building(const Building &source):
name(source.name), areas(source.areas),
waypoints(source.waypoints) {}
~Building(void) ;
/** @name Read accessors */
//@{
const std::string& get_name(void) const ;
const std::tr1::unordered_map<std::string, Area*>&
get_areas(void) const ;
const std::tr1::unordered_set<Waypoint*>& get_waypoints(void) const ;
//@}
/** @name Write accessors */
//@{
void set_name(const std::string &_name) ;
/// Adds an Area to the \link #areas list of areas\endlink
void add_area(Area *&a) ;
/// Adds a Waypoint to the \link #waypoints list of waypoints\endlink
void add_waypoint(const Waypoint *wp) ;
//@}
/** @name Operators */
//@{
Building& operator=(const Building &source) ;
bool operator==(const Building &source) const ;
bool operator!=(const Building &source) const ;
//@}
/// Displays a Building
friend std::ostream& operator<<(std::ostream &os, const Building &b) ;
} ;
/* *** Read accessors *** */
inline const std::string& Building::get_name() const
{
return name ;
}
inline const std::tr1::unordered_map<std::string, Area*>&
Building::get_areas() const
{
return areas ;
}
inline const std::tr1::unordered_set<Waypoint*>&
Building::get_waypoints() const
{
return waypoints ;
}
/* *** Write accessors *** */
inline void Building::set_name(const std::string &_name)
{
name = _name ;
}
/**
* @param wp A pointer to the Waypoint to add. If \em wp is NULL,
* nothing will be added.
*/
inline void Building::add_waypoint(const Waypoint *wp)
{
if (wp != NULL)
waypoints.insert(const_cast<Waypoint*>(wp)) ;
}
/* *** Operators *** */
inline bool Building::operator!=(const Building &b) const
{
return !(*this == b) ;
}
#endif // _OWLPS_POSITIONING_BUILDING_HH_