Debian Codegraph @

src/AIModel/performancedb.hxx

raw symbols SCIP
1 #pragma once
2
3 #include <string>
4 #include <map>
5 #include <vector>
6
7 class PerformanceData;
8 class SGPath;
9
10 #include <simgear/structure/subsystem_mgr.hxx>
11
12 /**
13 * Registry for performance data.
14 *
15 * Allows to store performance data for later reuse/retrieval. Just
16 * a simple map for now.
17 *
18 * @author Thomas F�rster <[email protected]>
19 */
20 // TODO: provide std::map interface?
21 class PerformanceDB : public SGSubsystem
22 {
23 public:
24 PerformanceDB() = default;
25 virtual ~PerformanceDB() = default;
26
27 // Subsystem API.
28 void init() override;
29 void shutdown() override;
30 void update(double dt) override;
31
32 // Subsystem identification.
33 static const char* staticSubsystemClassId() { return "aircraft-performance-db"; }
34
35 bool havePerformanceDataForAircraftType(const std::string& acType) const;
36
37 /**
38 * get performance data for an aircraft type / class. Type is specific, eg
39 * '738' or 'A319'. Class is more generic, such as 'jet_transport'.
40 */
41 PerformanceData* getDataFor(const std::string& acType, const std::string& acClass) const;
42
43 PerformanceData* getDefaultPerformance() const;
44
45 private:
46 void load(const SGPath& path);
47
48 void registerPerformanceData(const std::string& id, PerformanceData* data);
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 };