80 lines
1.9 KiB
C++
80 lines
1.9 KiB
C++
#ifndef GERMANAIRLINESVA_FILE_SIMDATABASE_H
|
|
#define GERMANAIRLINESVA_FILE_SIMDATABASE_H
|
|
|
|
#include <cstdint>
|
|
#include <cstring>
|
|
#include <fstream>
|
|
#include <functional>
|
|
#include <iostream>
|
|
#include <map>
|
|
#include <stdexcept>
|
|
#include <string>
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
#include "config/config.h"
|
|
#include "constants.h"
|
|
#include "simdata/gate.h"
|
|
#include "simdata/runway.h"
|
|
#include "simdata/simdataXP.h"
|
|
|
|
/*
|
|
* Header
|
|
*
|
|
* CHAR[5] | UINT8
|
|
* --------+--------
|
|
* VGAS | VERSION
|
|
*/
|
|
/*
|
|
* Airport
|
|
*
|
|
* UINT8 | CHAR[] | UINT16 | GATE[] | UINT8 | RUNWAY[]
|
|
* --------+--------+----------+--------+---------+---------
|
|
* STRLEN | ICAO | NUMGATES | GATES | NUMRWYS | RUNWAYS
|
|
*/
|
|
|
|
namespace germanairlinesva
|
|
{
|
|
namespace file
|
|
{
|
|
namespace simdata
|
|
{
|
|
class SimDatabase
|
|
{
|
|
private:
|
|
std::map<
|
|
std::string,
|
|
std::pair<std::vector<germanairlinesva::file::simdata::Gate>,
|
|
std::vector<germanairlinesva::file::simdata::Runway>>>
|
|
airports;
|
|
|
|
void fromFile();
|
|
void readVersion1(std::ifstream &in);
|
|
|
|
public:
|
|
SimDatabase(int xPlaneVersion,
|
|
const char *hash,
|
|
std::unique_ptr<config::Config> &configuration,
|
|
std::function<void(const std::string)> toLog);
|
|
|
|
void toFile() const;
|
|
|
|
inline std::size_t getCount() const { return this->airports.size(); }
|
|
inline const std::pair<const std::vector<Gate>,
|
|
const std::vector<Runway>>
|
|
operator[](std::string key)
|
|
{
|
|
try {
|
|
return this->airports.at(key);
|
|
} catch (std::out_of_range &ex) {
|
|
return std::pair<const std::vector<Gate>,
|
|
const std::vector<Runway>>();
|
|
}
|
|
}
|
|
};
|
|
} // namespace simdata
|
|
} // namespace file
|
|
} // namespace germanairlinesva
|
|
|
|
#endif
|