]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/performancedb.cxx
Clear chat messages when an aircraft becomes inactive in the property tree.
[flightgear.git] / src / AIModel / performancedb.cxx
1 #include "performancedb.hxx"
2
3 PerformanceDB::PerformanceDB()
4 {
5     // these are the 6 classes originally defined in the PERFSTRUCT
6     registerPerformanceData("light", new PerformanceData(
7         2.0, 2.0,  450.0, 1000.0,  70.0, 70.0,  80.0, 100.0,  80.0,  70.0, 60.0, 15.0));
8     registerPerformanceData("ww2_fighter", new PerformanceData(
9         4.0, 2.0,  3000.0, 1500.0,  110.0, 110.0,  180.0, 250.0,  200.0,  130.0, 100.0, 15.0));
10     registerPerformanceData("jet_fighter", new PerformanceData(
11         7.0, 3.0,  4000.0, 2000.0,  120.0, 150.0,  350.0, 500.0,  350.0,  170.0, 150.0, 15.0));
12     registerPerformanceData("jet_transport", new PerformanceData(
13         5.0, 2.0,  3000.0, 1500.0,  100.0, 140.0,  300.0, 430.0,  300.0,  170.0, 130.0, 15.0));
14     registerPerformanceData("tanker", new PerformanceData(
15         5.0, 2.0,  3000.0, 1500.0,  100.0, 140.0,  300.0, 430.0,  300.0,  170.0, 130.0, 15.0));
16     registerPerformanceData("ufo", new PerformanceData(
17         30.0, 30.0, 6000.0, 6000.0, 150.0, 150.0, 300.0, 430.0, 300.0, 170.0, 130.0, 15.0));
18
19 }
20
21
22 PerformanceDB::~PerformanceDB()
23 {}
24
25 void PerformanceDB::registerPerformanceData(const std::string& id, PerformanceData* data) {
26     //TODO if key exists already replace data "inplace", i.e. copy to existing PerfData instance
27     // this updates all aircraft currently using the PerfData instance.
28     _db[id] = data;
29 }
30
31 void PerformanceDB::registerPerformanceData(const std::string& id, const std::string& filename) {
32     registerPerformanceData(id, new PerformanceData(filename));
33 }
34
35 PerformanceData* PerformanceDB::getDataFor(const std::string& id) {
36     if (_db.find(id) == _db.end()) // id not found -> return jet_transport data
37         return _db["jet_transport"];
38
39     return _db[id];
40 }