| 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 | |
| 17 | typedef std::vector<time_t> timeVec; |
| 18 | typedef std::vector<time_t>::const_iterator timeVecConstIterator; |
| 19 | |
| 20 | typedef std::vector<std::string> stringVec; |
| 21 | typedef std::vector<std::string>::iterator stringVecIterator; |
| 22 | typedef std::vector<std::string>::const_iterator stringVecConstIterator; |
| 23 | |
| 24 | |
| 25 | /***************************************************************************/ |
| 26 | class ScheduleTime |
| 27 | { |
| 28 | private: |
| 29 | timeVec start; |
| 30 | timeVec end; |
| 31 | stringVec scheduleNames; |
| 32 | double tailWind; |
| 33 | double crssWind; |
| 34 | |
| 35 | public: |
| 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 | |
| 55 | class RunwayList |
| 56 | { |
| 57 | private: |
| 58 | std::string type; |
| 59 | stringVec preferredRunways; |
| 60 | |
| 61 | public: |
| 62 | RunwayList(){}; |
| 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 | |
| 75 | class RunwayGroup |
| 76 | { |
| 77 | private: |
| 78 | std::string name; |
| 79 | RunwayListVec rwyList; |
| 80 | int active = -1; |
| 81 | int choice[2] = {0}; |
| 82 | int nrActive = 0; |
| 83 | |
| 84 | public: |
| 85 | RunwayGroup(){}; |
| 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 | |
| 102 | class FGRunwayPreference |
| 103 | { |
| 104 | private: |
| 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 | |
| 116 | public: |
| 117 | explicit FGRunwayPreference(FGAirport* ap); |
| 118 | FGRunwayPreference(const FGRunwayPreference& other); |
| 119 | |
| 120 | FGRunwayPreference& operator=(const FGRunwayPreference& other); |
| 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 | }; |