]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/performancedb.hxx
apt.dat parser: clearer log and exception messages
[flightgear.git] / src / AIModel / performancedb.hxx
1 #ifndef PERFORMANCEDB_HXX
2 #define PERFORMANCEDB_HXX
3
4 #include <string>
5 #include <map>
6 #include <vector>
7
8 class PerformanceData;
9 class SGPath;
10
11 #include <simgear/structure/subsystem_mgr.hxx>
12
13 /**
14  * Registry for performance data.
15  *
16  * Allows to store performance data for later reuse/retrieval. Just
17  * a simple map for now.
18  * 
19  * @author Thomas F�rster <t.foerster@biologie.hu-berlin.de>
20 */
21 //TODO provide std::map interface?
22 class PerformanceDB : public SGSubsystem
23 {
24 public:
25     PerformanceDB();
26     virtual ~PerformanceDB();
27
28     virtual void init();
29     virtual void shutdown();
30
31     virtual void update(double dt);
32
33     bool havePerformanceDataForAircraftType(const std::string& acType) const;
34
35     /**
36      * get performance data for an aircraft type / class. Type is specific, eg
37      * '738' or 'A319'. Class is more generic, such as 'jet_transport'.
38      */
39     PerformanceData* getDataFor(const std::string& acType, const std::string& acClass) const;
40
41     PerformanceData* getDefaultPerformance() const;
42
43     static const char* subsystemName() { return "aircraft-performance-db"; }
44 private:
45     void load(const SGPath& path);
46
47     void registerPerformanceData(const std::string& id, PerformanceData* data);
48
49
50     typedef std::map<std::string, PerformanceData*> PerformanceDataDict;
51     PerformanceDataDict _db;
52     
53     const std::string& findAlias(const std::string& acType) const;
54   
55     typedef std::pair<std::string, std::string> StringPair;
56   /// alias list, to allow type/class names to share data. This is used to merge
57   /// related types together. Note it's ordered, and not a map since we permit
58   /// partial matches when merging - the first matching alias is used.
59     std::vector<StringPair> _aliases;
60 };
61
62 #endif