fpmas 1.6
grid.h
Go to the documentation of this file.
1#ifndef FPMAS_GRID_API_H
2#define FPMAS_GRID_API_H
3
8#include "spatial_model.h"
9
10namespace fpmas { namespace api { namespace model {
11
15 typedef long DiscreteCoordinate;
16
30
44 : x(x), y(y) {}
45 };
46
50 float euclidian_distance(const DiscretePoint& p1, const DiscretePoint& p2);
51
58 bool operator<(const DiscretePoint& p1, const DiscretePoint& p2);
66 bool operator==(const DiscretePoint& p1, const DiscretePoint& p2);
70 bool operator!=(const DiscretePoint& p1, const DiscretePoint& p2);
71
78 class GridCell : public Cell, public RandomAgent {
79 public:
85 virtual DiscretePoint location() const = 0;
86 };
87
93 bool operator<(const GridCell& c1, const GridCell& c2);
94
103 protected:
116 virtual void moveTo(DiscretePoint point) = 0;
117
118 public:
133 virtual DiscretePoint locationPoint() const = 0;
134
135 virtual ~GridAgentBase() {}
136 };
145 template<typename GridCellType>
146 class GridAgent :
147 public SpatialAgent<GridCellType>, public GridAgentBase, public RandomAgent {
148 protected:
149 static_assert(
150 std::is_base_of<api::model::GridCell, GridCellType>::value,
151 "fpmas::api::model::GridCell must be a base of the specified GridCell"
152 );
155 };
156
160 template<typename CellType>
162 public:
173 virtual CellType* build(DiscretePoint location) = 0;
174
175 virtual ~GridCellFactory() {}
176 };
177
182}}}
183
184namespace fpmas {
191 std::string to_string(const api::model::DiscretePoint& point);
192
193 namespace api { namespace model {
201 std::ostream& operator<<(std::ostream& os, const DiscretePoint& point);
202 }}
203}
204#endif
Definition: spatial_model.h:90
Definition: grid.h:102
virtual void moveTo(DiscretePoint point)=0
virtual DiscretePoint locationPoint() const =0
Definition: grid.h:147
virtual CellType * build(DiscretePoint location)=0
Definition: grid.h:78
virtual DiscretePoint location() const =0
Definition: model.h:462
Definition: spatial_model.h:656
Definition: spatial_model.h:234
bool operator==(const DiscretePoint &p1, const DiscretePoint &p2)
Definition: grid.cpp:20
bool operator<(const DiscretePoint &p1, const DiscretePoint &p2)
Definition: grid.cpp:14
SpatialAgentMapping< GridCell > GridAgentMapping
Definition: grid.h:181
std::ostream & operator<<(std::ostream &os, const DiscretePoint &point)
Definition: grid.cpp:28
float euclidian_distance(const DiscretePoint &p1, const DiscretePoint &p2)
Definition: grid.cpp:10
bool operator!=(const DiscretePoint &p1, const DiscretePoint &p2)
Definition: grid.cpp:24
long DiscreteCoordinate
Definition: grid.h:15
Definition: fpmas.cpp:3
std::string to_string(const api::graph::DistributedId &id)
Definition: distributed_id.cpp:4
DiscretePoint(DiscreteCoordinate x, DiscreteCoordinate y)
Definition: grid.h:43
DiscreteCoordinate x
Definition: grid.h:25
DiscreteCoordinate y
Definition: grid.h:29
DiscretePoint()
Definition: grid.h:36