| 1 | /* |
| 2 | * SPDX-FileName: fg_io.hxx |
| 3 | * SPDX-FileComment: Higher level I/O management routines |
| 4 | * SPDX-FileCopyrightText: Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt |
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 6 | */ |
| 7 | |
| 8 | #pragma once |
| 9 | |
| 10 | #include <string> |
| 11 | #include <vector> |
| 12 | |
| 13 | #include <simgear/compiler.h> |
| 14 | #include <simgear/props/props.hxx> |
| 15 | #include <simgear/structure/subsystem_mgr.hxx> |
| 16 | |
| 17 | |
| 18 | class FGProtocol; |
| 19 | |
| 20 | class FGIO : public SGSubsystem |
| 21 | { |
| 22 | public: |
| 23 | FGIO() = default; |
| 24 | ~FGIO() = default; |
| 25 | |
| 26 | // Subsystem API. |
| 27 | void bind() override; |
| 28 | void init() override; |
| 29 | void reinit() override; |
| 30 | void shutdown() override; |
| 31 | void unbind() override; |
| 32 | void update(double dt) override; |
| 33 | |
| 34 | // Subsystem identification. |
| 35 | static const char* staticSubsystemClassId() { return "io"; } |
| 36 | |
| 37 | /** |
| 38 | * helper to determine early in startup, if MP will be used. |
| 39 | * This information is needed in the position-init code, to adjust the |
| 40 | * start position off active runways. |
| 41 | */ |
| 42 | static bool isMultiplayerRequested(); |
| 43 | |
| 44 | private: |
| 45 | FGProtocol* add_channel(const std::string& config, bool& o_ok); |
| 46 | |
| 47 | FGProtocol* parse_port_config(const std::string& cfgstr, bool& o_ok); |
| 48 | FGProtocol* parse_port_config(const string_list& tokens, bool& o_ok); |
| 49 | |
| 50 | void addToPropertyTree(const std::string name, const std::string config); |
| 51 | void removeFromPropertyTree(const std::string name); |
| 52 | std::string generateName(const std::string protocol); |
| 53 | |
| 54 | private: |
| 55 | // define the global I/O channel list |
| 56 | //io_container global_io_list; |
| 57 | |
| 58 | typedef std::vector<FGProtocol*> ProtocolVec; |
| 59 | ProtocolVec io_channels; |
| 60 | |
| 61 | SGPropertyNode_ptr _realDeltaTime; |
| 62 | |
| 63 | bool commandAddChannel(const SGPropertyNode* arg, SGPropertyNode* root); |
| 64 | bool commandRemoveChannel(const SGPropertyNode* arg, SGPropertyNode* root); |
| 65 | }; |