Debian Codegraph @

utils/fgai/AIManager.hxx

raw symbols SCIP
1 // Copyright (C) 2009 - 2012 Mathias Froehlich
2 //
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License as
5 // published by the Free Software Foundation; either version 2 of the
6 // License, or (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful, but
9 // WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16
17 #ifndef AIManager_hxx
18 #define AIManager_hxx
19
20 #include <simgear/hla/HLAFederate.hxx>
21 #include "AIBVHPager.hxx"
22
23 namespace fgai {
24
25 class AIObject;
26
27 class AIManager : public simgear::HLAFederate {
28 public:
29 AIManager();
30 virtual ~AIManager();
31
32 virtual simgear::HLAObjectClass* createObjectClass(const std::string& name);
33
34 virtual bool init();
35 virtual bool update();
36 virtual bool shutdown();
37
38 void insert(const SGSharedPtr<AIObject>& aiObject);
39 void schedule(AIObject& object, const SGTimeStamp& simTime);
40
41 const SGTimeStamp& getSimTime() const
42 { return _simTime; }
43
44 const AIBVHPager& getPager() const;
45 AIBVHPager& getPager();
46
47 /// For the list of ai object that are active
48 typedef std::list<SGSharedPtr<AIObject> > ObjectList;
49 /// For the schedule of the next update of an ai object
50 typedef std::map<SGTimeStamp, ObjectList> TimeStampObjectListMap;
51
52 typedef std::map<SGTimeStamp, ObjectList::iterator> TimeStampObjectListIteratorMap;
53
54 private:
55 /// The current simulation time
56 SGTimeStamp _simTime;
57 /// The maximum time advance step size that is taken
58 SGTimeStamp _maxStep;
59
60 /// Single element list that is used to store the currently worked on
61 /// ai object. This is a helper for any work method in the object.
62 ObjectList _currentObject;
63
64 /// List of objects that are inserted and need to be initialized
65 ObjectList _initObjectList;
66 /// List of running and ready to use objects, is in execution order
67 ObjectList _objectList;
68 /// Map of insert points for specific simulation times
69 TimeStampObjectListIteratorMap _timeStampObjectListIteratorMap;
70
71 /// for paging bounding volume trees
72 AIBVHPager _pager;
73 };
74
75 } // namespace fgai
76
77 #endif