FIFE
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
route.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2013 by the FIFE team *
3  * http://www.fifengine.net *
4  * This file is part of FIFE. *
5  * *
6  * FIFE is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Lesser General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2.1 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20  ***************************************************************************/
21 
22 #ifndef FIFE_ROUTE_H
23 #define FIFE_ROUTE_H
24 
25 // Standard C++ library includes
26 #include <list>
27 
28 // 3rd party library includes
29 
30 // FIFE includes
31 // These includes are split up in two parts, separated by one empty line
32 // First block: files included from the FIFE root src directory
33 // Second block: files included from the same folder
34 #include "util/base/fifeclass.h"
35 
36 namespace FIFE {
37 
38  class Location;
39  class Object;
40 
49  enum RouteStatus {
55  };
57 
59  typedef std::list<Location> Path;
60 
64  class Route : public FifeClass {
65  public:
70  Route(const Location& start, const Location& end);
71 
74  ~Route();
75 
79  void setRouteStatus(RouteStatusInfo status);
80 
85 
89  void setStartNode(const Location& node);
90 
94  const Location& getStartNode();
95 
99  void setEndNode(const Location& node);
100 
104  const Location& getEndNode();
105 
109  const Location& getCurrentNode();
110 
114  const Location& getPreviousNode();
115 
119  const Location& getNextNode();
120 
126  bool walkToNextNode(int32_t step = 1);
127 
131  bool reachedEnd();
132 
136  void setPath(const Path& path);
137 
141  Path getPath();
142 
146  void cutPath(uint32_t length = 1);
147 
151  void setReplanned(bool replanned);
152 
156  bool isReplanned();
157 
162 
167 
171  void setSessionId(int32_t id);
172 
176  int32_t getSessionId();
177 
181  void setRotation(int32_t rotation);
182 
186  int32_t getRotation();
187 
191  void setCostId(const std::string& cost);
192 
196  const std::string& getCostId();
197 
201  bool isMultiCell();
202 
206  void setOccupiedArea(const std::vector<ModelCoordinate>& area);
207 
211  const std::vector<ModelCoordinate>& getOccupiedArea();
212 
217  std::vector<ModelCoordinate> getOccupiedCells(int32_t rotation);
218 
222  int32_t getZStepRange();
223 
224  bool isAreaLimited();
225  const std::list<std::string> getLimitedAreas();
226 
230  void setObject(Object* obj);
231 
235  Object* getObject();
236 
237  private:
239  typedef Path::iterator PathIterator;
240 
243 
246 
249 
252 
255 
258 
260  int32_t m_sessionId;
261 
263  int32_t m_rotation;
264 
267 
269  std::string m_costId;
270 
272  std::vector<ModelCoordinate> m_area;
273 
276  };
277 
278 } // FIFE
279 
280 #endif
void setOccupiedArea(const std::vector< ModelCoordinate > &area)
Sets occupied coordinates for multi cell object.
Definition: route.cpp:252
void cutPath(uint32_t length=1)
Cuts path after the given length.
Definition: route.cpp:179
Object * m_object
pointer to multi object
Definition: route.h:275
Location m_endNode
end location
Definition: route.h:248
void setObject(Object *obj)
Sets the object, needed for multi cell and z-step range.
Definition: route.cpp:292
RouteStatusInfo m_status
search status
Definition: route.h:242
std::list< Location > Path
A path is a list with locations. Each location holds the coordinate for one cell. ...
Definition: ipather.h:38
int32_t getZStepRange()
Returns z-step range from object.
Definition: route.cpp:268
const Location & getPreviousNode()
Returns previous location.
Definition: route.cpp:106
const Location & getStartNode()
Returns the start location.
Definition: route.cpp:76
Object class.
Definition: object.h:51
bool walkToNextNode(int32_t step=1)
Changes the position on the path.
Definition: route.cpp:135
Object * getObject()
Returns the object, needed for multi cell and z-step range.
Definition: route.cpp:296
void setRouteStatus(RouteStatusInfo status)
Sets route status.
Definition: route.cpp:55
int32_t m_sessionId
session id of the search
Definition: route.h:260
const Location & getNextNode()
Returns next location.
Definition: route.cpp:119
const Location & getEndNode()
Returns the target location.
Definition: route.cpp:92
Base class for all fife classes Used e.g.
Definition: fifeclass.h:42
uint32_t getPathLength()
Returns the length of the path.
Definition: route.cpp:213
uint32_t m_walked
walked steps on the path
Definition: route.h:257
PathIterator m_current
current position on the path
Definition: route.h:254
A basic route.
Definition: route.h:64
bool reachedEnd()
Gets if the end of the path was achieved.
Definition: route.cpp:154
int32_t m_rotation
current rotation
Definition: route.h:263
const std::list< std::string > getLimitedAreas()
Definition: route.cpp:284
void setPath(const Path &path)
Sets the path for the route.
Definition: route.cpp:161
unsigned char uint8_t
Definition: core.h:38
void setRotation(int32_t rotation)
Sets the current rotation.
Definition: route.cpp:229
void setStartNode(const Location &node)
Sets the start location.
Definition: route.cpp:65
int32_t getSessionId()
Returns the session identifier.
Definition: route.cpp:225
void setCostId(const std::string &cost)
Sets cost identifier which should be used for pathfinding.
Definition: route.cpp:237
bool isAreaLimited()
Definition: route.cpp:275
RouteStatusInfo getRouteStatus()
Returns route status.
Definition: route.cpp:61
Path::iterator PathIterator
path iterator
Definition: route.h:239
RouteStatus
Defines different route status types for the search.
Definition: route.h:49
void setReplanned(bool replanned)
Sets the route to replanned.
Definition: route.cpp:205
Path m_path
path
Definition: route.h:251
std::vector< ModelCoordinate > m_area
occupied cells by multicell object
Definition: route.h:272
~Route()
Destructor.
Definition: route.cpp:52
Path getPath()
Returns the path.
Definition: route.cpp:175
uint32_t getWalkedLength()
Returns the walked steps.
Definition: route.cpp:217
const std::vector< ModelCoordinate > & getOccupiedArea()
Returns occupied coordinates for multi cell object.
Definition: route.cpp:256
std::string m_costId
used cost identifier
Definition: route.h:269
const std::string & getCostId()
Returns cost identifier which is used for pathfinding.
Definition: route.cpp:241
std::vector< ModelCoordinate > getOccupiedCells(int32_t rotation)
Returns relative coordinates for multi cell object based on rotation.
Definition: route.cpp:260
const Location & getCurrentNode()
Returns current location.
Definition: route.cpp:96
bool isMultiCell()
Gets if path is for a multi cell object.
Definition: route.cpp:245
void setEndNode(const Location &node)
Sets the target location.
Definition: route.cpp:80
int32_t getRotation()
Returns the current rotation.
Definition: route.cpp:233
unsigned int uint32_t
Definition: core.h:40
bool m_replanned
is path replanned
Definition: route.h:266
Location m_startNode
start location
Definition: route.h:245
bool isReplanned()
Gets if the route is replanned.
Definition: route.cpp:209
Route(const Location &start, const Location &end)
Constructor.
Definition: route.cpp:40
uint8_t RouteStatusInfo
Definition: route.h:56
void setSessionId(int32_t id)
Sets the session identifier.
Definition: route.cpp:221