Dragonfly  4.3
A text-based game engine
PathManager.h
1 ///
2 /// PathManager.h
3 ///
4 /// Manage pathfinding for all Objects.
5 ///
6 
7 #ifndef __PATH_MANAGER_H__
8 #define __PATH_MANAGER_H__
9 
10 // System includes.
11 #include <string>
12 #include <vector>
13 
14 // Engine includes.
15 #include "Manager.h"
16 #include "PathFind.h"
17 
18 // Two-letter acronym for easier access to manager.
19 #define PM df::PathManager::getInstance()
20 
21 namespace df {
22 
23 class PathManager : public Manager {
24 
25  private:
26  PathManager(); ///< Private since a singleton.
27  PathManager(PathManager const&); ///< Don't allow copy.
28  void operator=(PathManager const&); ///< Don't allow assignment.
29  std::vector<PathFind *> m_finder; ///< PathFind's registered.
30  int m_min_cycle_time; ///< Min pathfinding time, in millisec.
31 
32  public:
33 
34  /// Get the one and only instance of the PathManager.
35  static PathManager &getInstance();
36 
37  /// Start up PathManager.
38  /// Set min cycle time default to 1/10 frame time.
39  int startUp();
40 
41  /// Shut down PathManager.
42  void shutDown();
43 
44  /// Register PathFind with PathManager.
45  /// Return 0 if ok, else -1.
46  int registerPathFind(PathFind *p_path_find);
47 
48  /// Unregister PathFind with PathManager.
49  /// Return 0 if ok, else -1.
50  int unregisterPathFind(PathFind *p_path_find);
51 
52  /// Set minimum cycle time (minimum game loop time spent pathfinding).
53  void setMinCycleTime(int new_min_cycle_time);
54 
55  /// Get minimum cycle time (minimum game loop time spent pathfinding).
56  int getMinCycleTime();
57 
58  /// Cycle through registered PathFinders.
59  /// Spend at least min_cycle time, but no more than max_cycle_time.
60  void cycle(int max_cycle_time=-1);
61 };
62 
63 } // end of namespace df
64 
65 #endif // __PATH_MANAGER_H__
void setMinCycleTime(int new_min_cycle_time)
Set minimum cycle time (minimum game loop time spent pathfinding).
void cycle(int max_cycle_time=-1)
Cycle through registered PathFinders.
A 2-d bounding box.
Definition: Box.h:10
Definition: PathFind.h:29
std::vector< PathFind * > m_finder
PathFind&#39;s registered.
Definition: PathManager.h:29
void shutDown()
Shut down PathManager.
int startUp()
Start up PathManager.
Definition: PathManager.h:23
Definition: Manager.h:20
void operator=(PathManager const &)
Don&#39;t allow assignment.
static PathManager & getInstance()
Get the one and only instance of the PathManager.
int getMinCycleTime()
Get minimum cycle time (minimum game loop time spent pathfinding).
PathManager()
Private since a singleton.
int m_min_cycle_time
Min pathfinding time, in millisec.
Definition: PathManager.h:30
int registerPathFind(PathFind *p_path_find)
Register PathFind with PathManager.
int unregisterPathFind(PathFind *p_path_find)
Unregister PathFind with PathManager.