fpmas 1.6
Public Member Functions | List of all members
fpmas::api::model::Range< CellType > Class Template Referenceabstract

#include <spatial_model.h>

Inheritance diagram for fpmas::api::model::Range< CellType >:
Inheritance graph
[legend]

Public Member Functions

virtual bool contains (CellType *root, CellType *cell) const =0
 
virtual std::size_t radius (CellType *origin) const =0
 

Detailed Description

template<typename CellType>
class fpmas::api::model::Range< CellType >

Range API.

Ranges might be associated to SpatialAgents to build their mobility and perception fields.

Ranges are assumed to be continuous: for any given root, if this->contains(root, cell), the current Cell network must contain a path from root to cell such that this->contains(root, cell_path) is true for any cell_path on the path. This is required for the DistributedMoveAlgorithm to work properly.

Member Function Documentation

◆ contains()

template<typename CellType >
virtual bool fpmas::api::model::Range< CellType >::contains ( CellType *  root,
CellType *  cell 
) const
pure virtual

Returns true if and only if cell is contained in this range, considering that the range uses root as its origin.

In practice, root is usually the location of the SpatialAgent to which this range is associated.

Notice that root and cell can be DISTANT. In consequence, it is not safe to use root's or cell's neighbors in this method implementation.

Parameters
rootorigin of the range
cellcell to check

Implemented in fpmas::model::VoidRange< CellType >, and fpmas::model::LocationRange< CellType >.

◆ radius()

template<typename CellType >
virtual std::size_t fpmas::api::model::Range< CellType >::radius ( CellType *  origin) const
pure virtual

Returns the radius of this range, i.e. a value greater or equal to the maximum shortest path length between origin and any cell contained in this range, considering origin as the location of the object to which this range is associated.

Notice that such path length must be understood as a "graph distance", and not confused with any other type of distance that might be associated to CellType.

It represents the maximum count of edges on a shortest path from origin to any point in the range in the current Cell network. In consequence, implementations will probably depend on the underlying environment implementation on which this range is used (Grid, generic graph, geographic graph...).

Here is a trivial example. Consider that the current environment (or "Cell network") is a simple chain of cells, with a distance of 1km between each cell. The underlying graph might be represented as follow: 1 – 2 – 3 – 4 – 5 – 6 – ...

Now, let's implement a Range that represents the fact that a SpatialAgent can move 2km to its left or to its right. Considering the definition above, the radius returned by this method will be 2, since in the current environment a SpatialAgent associated to this Range will be able to move at most two cells to its left or to its right, whatever its current position is (so, in this case, there is no need to use the origin parameter).

Parameters
originorigin cell of the range (typically, the location of the agent associated to the range)
Returns
range radius

Implemented in fpmas::model::VoidRange< CellType >, and fpmas::model::LocationRange< CellType >.


The documentation for this class was generated from the following file: