OregonCore  revision fb2a440-git
Your Favourite TBC server
WaypointManager.h
Go to the documentation of this file.
1 /*
2  * This file is part of the OregonCore Project. See AUTHORS file for Copyright information
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation; either version 2 of the License, or (at your
7  * option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef OREGON_WAYPOINTMANAGER_H
19 #define OREGON_WAYPOINTMANAGER_H
20 
21 #include <ace/Singleton.h>
22 #include <ace/Null_Mutex.h>
23 #include <vector>
24 
26 {
28  float x, y, z, orientation;
29  bool run;
33 };
34 
35 typedef std::vector<WaypointData*> WaypointPath;
36 typedef UNORDERED_MAP<uint32, WaypointPath> WaypointPathContainer;
37 
39 {
40  friend class ACE_Singleton<WaypointMgr, ACE_Null_Mutex>;
41 
42  public:
43  // Attempts to reload a single path from database
44  void ReloadPath(uint32 id);
45 
46  // Loads all paths from database, should only run on startup
47  void Load();
48 
49  // Returns the path from a given id
50  WaypointPath const* GetPath(uint32 id) const
51  {
52  WaypointPathContainer::const_iterator itr = _waypointStore.find(id);
53  if (itr != _waypointStore.end())
54  return &itr->second;
55 
56  return NULL;
57  }
58 
59  private:
60  // Only allow instantiation from ACE_Singleton
61  WaypointMgr();
62  ~WaypointMgr();
63 
65 };
66 
67 #define sWaypointMgr ACE_Singleton<WaypointMgr, ACE_Null_Mutex>::instance()
68 
69 #endif
70 
WaypointPath const * GetPath(uint32 id) const
std::vector< WaypointData * > WaypointPath
ACE_UINT8 uint8
Definition: Define.h:73
UNORDERED_MAP< uint32, WaypointPath > WaypointPathContainer
ACE_UINT32 uint32
Definition: Define.h:71
WaypointPathContainer _waypointStore