]> git.mxchange.org Git - flightgear.git/blob - src/ATCDCL/ATCmgr.hxx
Goodbye automake.
[flightgear.git] / src / ATCDCL / ATCmgr.hxx
1 // ATCMgr.hxx - definition of FGATCMgr 
2 // - a global management class for FlightGear generated ATC
3 //
4 // Written by David Luff, started February 2002.
5 //
6 // Copyright (C) 2002  David C Luff - david.luff@nottingham.ac.uk
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21
22 #ifndef _FG_ATCMGR_HXX
23 #define _FG_ATCMGR_HXX
24
25 #include <simgear/structure/subsystem_mgr.hxx>
26
27 #include <string>
28 #include <list>
29 #include <map>
30
31 #include "ATC.hxx"
32
33 class FGATCMgr : public SGSubsystem
34 {
35
36 private:
37
38     bool initDone;      // Hack - guard against update getting called before init
39
40     // A list of pointers to all currently active ATC classes
41     typedef std::map<std::string,FGATC*> atc_list_type;
42     typedef atc_list_type::iterator atc_list_iterator;
43     typedef atc_list_type::const_iterator atc_list_const_iterator;
44
45     // Everything put in this list should be created dynamically
46     // on the heap and ***DELETED WHEN REMOVED!!!!!***
47     atc_list_type* atc_list;
48     atc_list_iterator atc_list_itr;
49     // Any member function of FGATCMgr is permitted to leave this iterator pointing
50     // at any point in or at the end of the list.
51     // Hence any new access must explicitly first check for atc_list.end() before dereferencing.
52
53     // Position of the Users Aircraft
54     SGGeod _aircraftPos;
55
56     // Pointers to current users position
57     SGPropertyNode_ptr lon_node;
58     SGPropertyNode_ptr lat_node;
59     SGPropertyNode_ptr elev_node;
60
61     //FGATIS atis;
62         
63     // Voice related stuff
64     bool voice;                 // Flag - true if we are using voice
65 #ifdef ENABLE_AUDIO_SUPPORT
66     bool voiceOK;               // Flag - true if at least one voice has loaded OK
67     FGATCVoice* v1;
68 #endif
69
70 public:
71
72     FGATCMgr();
73     ~FGATCMgr();
74
75     void init();
76
77     void bind();
78
79     void unbind();
80
81     void update(double dt);
82
83
84     // Return a pointer to an appropriate voice for a given type of ATC
85     // creating the voice if necessary - ie. make sure exactly one copy
86     // of every voice in use exists in memory.
87     //
88     // TODO - in the future this will get more complex and dole out country/airport
89     // specific voices, and possible make sure that the same voice doesn't get used
90     // at different airports in quick succession if a large enough selection are available.
91     FGATCVoice* GetVoicePointer(const atc_type& type);
92     
93     atc_type GetComm1ATCType() { return(INVALID/* kludge */); }
94     FGATC* GetComm1ATCPointer() { return(0/* kludge */); }
95     atc_type GetComm2ATCType() { return(INVALID); }
96     FGATC* GetComm2ATCPointer() { return(0/* kludge */); }
97     
98
99 private:
100
101     // Remove a class from the atc_list and delete it from memory
102         // *if* no other comm channel or AI plane is using it.
103     void ZapOtherService(const std::string ncunit, const std::string svc_name);
104
105     // Return a pointer to a class in the list given ICAO code and type
106     // Return NULL if the given service is not in the list
107     // - *** THE CALLING FUNCTION MUST CHECK FOR THIS ***
108     FGATC* FindInList(const std::string& id, const atc_type& tp);
109
110     // Search the specified radio for stations on the same frequency and in range.
111     void FreqSearch(const std::string navcomm, const int unit);
112 };
113
114 #endif  // _FG_ATCMGR_HXX