2007-06-28 07:47:20 +00:00
|
|
|
|
#ifndef PERFORMANCEDB_HXX
|
|
|
|
|
#define PERFORMANCEDB_HXX
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <map>
|
2012-10-05 18:12:46 +01:00
|
|
|
|
#include <vector>
|
2007-06-28 07:47:20 +00:00
|
|
|
|
|
2012-10-05 18:12:46 +01:00
|
|
|
|
class PerformanceData;
|
|
|
|
|
class SGPath;
|
2007-06-28 07:47:20 +00:00
|
|
|
|
|
2015-12-19 00:29:00 -08:00
|
|
|
|
#include <simgear/structure/subsystem_mgr.hxx>
|
|
|
|
|
|
2007-06-28 07:47:20 +00:00
|
|
|
|
/**
|
|
|
|
|
* Registry for performance data.
|
|
|
|
|
*
|
|
|
|
|
* Allows to store performance data for later reuse/retrieval. Just
|
|
|
|
|
* a simple map for now.
|
|
|
|
|
*
|
2009-05-05 10:36:38 +00:00
|
|
|
|
* @author Thomas F<EFBFBD>rster <t.foerster@biologie.hu-berlin.de>
|
2007-06-28 07:47:20 +00:00
|
|
|
|
*/
|
|
|
|
|
//TODO provide std::map interface?
|
2015-12-19 00:29:00 -08:00
|
|
|
|
class PerformanceDB : public SGSubsystem
|
2007-06-28 07:47:20 +00:00
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
PerformanceDB();
|
2015-12-19 00:29:00 -08:00
|
|
|
|
virtual ~PerformanceDB();
|
2007-06-28 07:47:20 +00:00
|
|
|
|
|
2015-12-19 00:29:00 -08:00
|
|
|
|
virtual void init();
|
|
|
|
|
virtual void shutdown();
|
|
|
|
|
|
|
|
|
|
virtual void update(double dt);
|
|
|
|
|
|
|
|
|
|
bool havePerformanceDataForAircraftType(const std::string& acType) const;
|
2007-06-28 07:47:20 +00:00
|
|
|
|
|
2012-10-05 18:12:46 +01:00
|
|
|
|
/**
|
|
|
|
|
* get performance data for an aircraft type / class. Type is specific, eg
|
|
|
|
|
* '738' or 'A319'. Class is more generic, such as 'jet_transport'.
|
|
|
|
|
*/
|
2015-12-19 00:29:00 -08:00
|
|
|
|
PerformanceData* getDataFor(const std::string& acType, const std::string& acClass) const;
|
|
|
|
|
|
|
|
|
|
PerformanceData* getDefaultPerformance() const;
|
2007-06-28 07:47:20 +00:00
|
|
|
|
|
2015-12-19 00:29:00 -08:00
|
|
|
|
static const char* subsystemName() { return "aircraft-performance-db"; }
|
2007-06-28 07:47:20 +00:00
|
|
|
|
private:
|
2015-12-19 00:29:00 -08:00
|
|
|
|
void load(const SGPath& path);
|
|
|
|
|
|
|
|
|
|
void registerPerformanceData(const std::string& id, PerformanceData* data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef std::map<std::string, PerformanceData*> PerformanceDataDict;
|
|
|
|
|
PerformanceDataDict _db;
|
2012-10-05 18:12:46 +01:00
|
|
|
|
|
2012-11-24 11:59:13 +01:00
|
|
|
|
const std::string& findAlias(const std::string& acType) const;
|
2012-10-05 18:12:46 +01:00
|
|
|
|
|
|
|
|
|
typedef std::pair<std::string, std::string> StringPair;
|
|
|
|
|
/// alias list, to allow type/class names to share data. This is used to merge
|
|
|
|
|
/// related types together. Note it's ordered, and not a map since we permit
|
|
|
|
|
/// partial matches when merging - the first matching alias is used.
|
|
|
|
|
std::vector<StringPair> _aliases;
|
2007-06-28 07:47:20 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|