FlightGear next
fg_io.hxx
Go to the documentation of this file.
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
18class FGProtocol;
19
20class FGIO : public SGSubsystem
21{
22public:
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
42 static bool isMultiplayerRequested();
43
44private:
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
54private:
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};
void unbind() override
Definition fg_io.cxx:501
static const char * staticSubsystemClassId()
Definition fg_io.hxx:35
void init() override
Definition fg_io.cxx:376
FGIO()=default
void update(double dt) override
Definition fg_io.cxx:445
void bind() override
Definition fg_io.cxx:496
~FGIO()=default
static bool isMultiplayerRequested()
helper to determine early in startup, if MP will be used.
Definition fg_io.cxx:505
void reinit() override
Definition fg_io.cxx:433
void shutdown() override
Definition fg_io.cxx:473
const char * name
std::vector< std::string > string_list
Definition globals.hxx:36
static bool add_channel(const string &type, const string &channel_str)
Definition options.cxx:667