FlightGear next
runwayprefs.hxx
Go to the documentation of this file.
1/*
2 * SPDX-FileName: runwayprefs.hxx
3 * SPDX-FileComment: A number of classes to configure runway assignments by the AI code
4 * SPDX-FileCopyrightText: Copyright (C) 2004 Durk Talsma.
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
8#pragma once
9
10#include <time.h>
11
12#include <simgear/compiler.h>
13
14#include "airports_fwd.hxx"
15
16
17typedef std::vector<time_t> timeVec;
18typedef std::vector<time_t>::const_iterator timeVecConstIterator;
19
20typedef std::vector<std::string> stringVec;
21typedef std::vector<std::string>::iterator stringVecIterator;
22typedef std::vector<std::string>::const_iterator stringVecConstIterator;
23
24
25/***************************************************************************/
27{
28private:
29 timeVec start;
30 timeVec end;
31 stringVec scheduleNames;
32 double tailWind;
33 double crssWind;
34
35public:
36 ScheduleTime() : tailWind(0), crssWind(0){};
37 ScheduleTime(const ScheduleTime& other);
38 ScheduleTime& operator=(const ScheduleTime& other);
39 std::string getName(time_t dayStart);
40
41 void clear();
42 void addStartTime(time_t time) { start.push_back(time); };
43 void addEndTime(time_t time) { end.push_back(time); };
44 void addScheduleName(const std::string& sched) { scheduleNames.push_back(sched); };
45 void setTailWind(double wnd) { tailWind = wnd; };
46 void setCrossWind(double wnd) { tailWind = wnd; };
47
48 double getTailWind() { return tailWind; };
49 double getCrossWind() { return crssWind; };
50};
51
52//typedef vector<ScheduleTime> ScheduleTimes;
53/*****************************************************************************/
54
56{
57private:
58 std::string type;
59 stringVec preferredRunways;
60
61public:
63 RunwayList(const RunwayList& other);
64 RunwayList& operator=(const RunwayList& other);
65
66 void set(const std::string&, const std::string&);
67 void clear();
68
69 std::string getType() { return type; };
70 const stringVec& getPreferredRunways() const { return preferredRunways; };
71};
72
73/*****************************************************************************/
74
76{
77private:
78 std::string name;
79 RunwayListVec rwyList;
80 int active = -1;
81 int choice[2] = {0};
82 int nrActive = 0;
83
84public:
86 RunwayGroup(const RunwayGroup& other);
87 RunwayGroup& operator=(const RunwayGroup& other);
88
89 void setName(const std::string& nm) { name = nm; };
90 void add(const RunwayList& list) { rwyList.push_back(list); };
91 void setActive(const FGAirport* airport, double windSpeed, double windHeading, double maxTail, double maxCross, stringVec* curr);
92
93 int getNrActiveRunways() { return nrActive; };
94 void getActive(int i, std::string& name, std::string& type);
95
96 const std::string& getName() const { return name; };
97 void clear() { rwyList.clear(); };
98};
99
100/******************************************************************************/
101
103{
104private:
105 FGAirport* _ap;
106
107 ScheduleTime comTimes; // Commercial Traffic;
108 ScheduleTime genTimes; // General Aviation;
109 ScheduleTime milTimes; // Military Traffic;
110 ScheduleTime ulTimes; // Ultralight Traffic
111
112 PreferenceList preferences;
113
114 bool initialized;
115
116public:
117 explicit FGRunwayPreference(FGAirport* ap);
119
121
122 ScheduleTime* getSchedule(const char* trafficType);
123 RunwayGroup* getGroup(const std::string& groupName);
124
125 std::string getId();
126
127 bool available() { return initialized; };
128 void setInitialized(bool state) { initialized = state; };
129
130 void setMilTimes(const ScheduleTime& t) { milTimes = t; };
131 void setGenTimes(const ScheduleTime& t) { genTimes = t; };
132 void setComTimes(const ScheduleTime& t) { comTimes = t; };
133 void setULTimes(const ScheduleTime& t) { ulTimes = t; };
134
135 void addRunwayGroup(RunwayGroup& g) { preferences.push_back(g); };
136};
#define i(x)
std::vector< RunwayGroup > PreferenceList
std::vector< RunwayList > RunwayListVec
void setMilTimes(const ScheduleTime &t)
void addRunwayGroup(RunwayGroup &g)
void setComTimes(const ScheduleTime &t)
void setULTimes(const ScheduleTime &t)
void setInitialized(bool state)
FGRunwayPreference(FGAirport *ap)
std::string getId()
void setGenTimes(const ScheduleTime &t)
RunwayGroup * getGroup(const std::string &groupName)
ScheduleTime * getSchedule(const char *trafficType)
FGRunwayPreference & operator=(const FGRunwayPreference &other)
RunwayGroup & operator=(const RunwayGroup &other)
const std::string & getName() const
void setName(const std::string &nm)
void add(const RunwayList &list)
void getActive(int i, std::string &name, std::string &type)
int getNrActiveRunways()
void setActive(const FGAirport *airport, double windSpeed, double windHeading, double maxTail, double maxCross, stringVec *curr)
RunwayList & operator=(const RunwayList &other)
std::string getType()
const stringVec & getPreferredRunways() const
void set(const std::string &, const std::string &)
void setCrossWind(double wnd)
void addEndTime(time_t time)
void addStartTime(time_t time)
double getTailWind()
std::string getName(time_t dayStart)
void setTailWind(double wnd)
ScheduleTime & operator=(const ScheduleTime &other)
void addScheduleName(const std::string &sched)
double getCrossWind()
const char * name
std::vector< std::string >::iterator stringVecIterator
std::vector< std::string >::const_iterator stringVecConstIterator
std::vector< time_t > timeVec
std::vector< std::string > stringVec
std::vector< time_t >::const_iterator timeVecConstIterator