owlps/owlps-positioner/src/building.hh

159 lines
4.2 KiB
C++
Raw Normal View History

/*
* This file is part of the Owl Positioning System (OwlPS).
* OwlPS is a project of the University of Franche-Comte
* (Université de Franche-Comté), France.
*
* Copyright © Université de Franche-Comté 2007-2012.
*
* Corresponding author: Matteo Cypriani <mcy@lm7.fr>
*
***********************************************************************
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL:
* http://www.cecill.info
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided
* only with a limited warranty and the software's authors, the holder
* of the economic rights, and the successive licensors have only
* limited liability.
*
* In this respect, the user's attention is drawn to the risks
* associated with loading, using, modifying and/or developing or
* reproducing the software by the user in light of its specific status
* of free software, that may mean that it is complicated to manipulate,
* and that also therefore means that it is reserved for developers and
* experienced professionals having in-depth computer knowledge. Users
* are therefore encouraged to load and test the software's suitability
* as regards their requirements in conditions enabling the security of
* their systems and/or data to be ensured and, more generally, to use
* and operate it in the same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*
***********************************************************************
*/
#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_