]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/performancedb.hxx
PerformanceDB improvements.
[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 /**
12  * Registry for performance data.
13  *
14  * Allows to store performance data for later reuse/retrieval. Just
15  * a simple map for now.
16  * 
17  * @author Thomas F�rster <t.foerster@biologie.hu-berlin.de>
18 */
19 //TODO provide std::map interface?
20 class PerformanceDB
21 {
22 public:
23     PerformanceDB();
24     ~PerformanceDB();
25
26     void registerPerformanceData(const std::string& id, PerformanceData* data);
27     void registerPerformanceData(const std::string& id, const std::string& filename);
28
29     /**
30      * get performance data for an aircraft type / class. Type is specific, eg
31      * '738' or 'A319'. Class is more generic, such as 'jet_transport'.
32      */
33     PerformanceData* getDataFor(const std::string& acType, const std::string& acClass);
34     void load(const SGPath& path);
35
36 private:
37     std::map<std::string, PerformanceData*> _db;
38     
39     std::string findAlias(const std::string& acType) const;
40   
41     typedef std::pair<std::string, std::string> StringPair;
42   /// alias list, to allow type/class names to share data. This is used to merge
43   /// related types together. Note it's ordered, and not a map since we permit
44   /// partial matches when merging - the first matching alias is used.
45     std::vector<StringPair> _aliases;
46 };
47
48 #endif