175 lines
4.9 KiB
C++
175 lines
4.9 KiB
C++
/*
|
|
* 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_WAYPOINT_HH_
|
|
#define _OWLPS_POSITIONING_WAYPOINT_HH_
|
|
|
|
class Building ;
|
|
|
|
#include "point3d.hh"
|
|
|
|
#include <boost/tr1/unordered_set.hpp>
|
|
#include <ostream>
|
|
#include <stdexcept>
|
|
|
|
/// Represents a junction point between several rooms (i.e. Area)
|
|
/**
|
|
* A Waypoint is defined by its coordinates and linked to the buildings
|
|
* it belongs to. You \em should always construct a Waypoint with at least
|
|
* one associated Building, but you \em can not do so, for instance in an
|
|
* automatic construction (container…).
|
|
*/
|
|
class Waypoint: public Point3D
|
|
{
|
|
protected:
|
|
/// List of Building associated with the Waypoint
|
|
std::tr1::unordered_set<Building*> buildings ;
|
|
|
|
public:
|
|
Waypoint(const Building *_b = NULL, const float &_x = 0,
|
|
const float &_y = 0, const float &_z = 0) ;
|
|
|
|
Waypoint(const Building *_b, const Point3D &p) ;
|
|
|
|
Waypoint(const Point3D &p): Point3D(p) {}
|
|
|
|
Waypoint(const Waypoint &wp): Point3D(wp), buildings(wp.buildings) {}
|
|
|
|
~Waypoint(void) ;
|
|
|
|
/** @name Read accessors */
|
|
//@{
|
|
/// #buildings's first element read accessor
|
|
Building* get_1st_building(void) const ;
|
|
const std::tr1::unordered_set<Building*>& get_buildings(void) const ;
|
|
//@}
|
|
|
|
/** @name Write accessors */
|
|
//@{
|
|
/// Adds a Building to the \link #buildings building list\endlink
|
|
void add_building(const Building *_b) ;
|
|
/// Adds the Building list of \em source to #buildings
|
|
void add_buildings(const Waypoint &source) ;
|
|
/// Removes a Building from #buildings
|
|
void remove_building(const Building *_b) ;
|
|
//@}
|
|
|
|
/** @name Operators */
|
|
//@{
|
|
Waypoint& operator=(const Waypoint &wp) ;
|
|
bool operator==(const Waypoint &wp) const ;
|
|
bool operator!=(const Waypoint &wp) const ;
|
|
operator std::string(void) const ;
|
|
//@}
|
|
|
|
/// Displays a Waypoint
|
|
friend std::ostream& operator<<(std::ostream &os, const Waypoint &wp) ;
|
|
} ;
|
|
|
|
|
|
|
|
/* *** Read accessors *** */
|
|
|
|
|
|
/**
|
|
* @return A pointer to the first Building associated with the Waypoint
|
|
* (i.e. the first element of #buildings). If #buildings is empty, NULL
|
|
* is returned.
|
|
*/
|
|
inline Building* Waypoint::get_1st_building() const
|
|
{
|
|
if (buildings.empty())
|
|
return NULL ;
|
|
return *buildings.begin() ;
|
|
}
|
|
|
|
|
|
inline const std::tr1::unordered_set<Building*>&
|
|
Waypoint::get_buildings() const
|
|
{
|
|
return buildings ;
|
|
}
|
|
|
|
|
|
|
|
/* *** Write accessors *** */
|
|
|
|
|
|
/**
|
|
* @param _b A pointer to the Building to add. If it is
|
|
* NULL, nothing will be done.
|
|
* The memory pointed by this pointer must not be deallocated before
|
|
* the Waypoint destruction (do \em not pass a pointer to a local
|
|
* variable!).
|
|
*/
|
|
inline void Waypoint::add_building(const Building *_b)
|
|
{
|
|
if (_b != NULL)
|
|
buildings.insert(const_cast<Building*>(_b)) ;
|
|
}
|
|
|
|
|
|
inline void Waypoint::remove_building(const Building *_b)
|
|
{
|
|
if (_b != NULL)
|
|
buildings.erase(const_cast<Building*>(_b)) ;
|
|
}
|
|
|
|
|
|
inline void Waypoint::add_buildings(const Waypoint &source)
|
|
{
|
|
buildings.insert(source.buildings.begin(), source.buildings.end()) ;
|
|
}
|
|
|
|
|
|
|
|
/* *** Operators *** */
|
|
|
|
|
|
inline bool Waypoint::operator!=(const Waypoint &wp) const
|
|
{
|
|
return !(*this == wp) ;
|
|
}
|
|
|
|
|
|
|
|
#endif // _OWLPS_POSITIONING_WAYPOINT_HH_
|