| 1 | /* |
| 2 | * SPDX-FileCopyrightText: (C) 2019-2022 swift Project Community / Contributors (https://swift-project.org/) |
| 3 | * SPDX-FileCopyrightText: (C) 2019-2022 Lars Toenning <[email protected]> |
| 4 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 5 | */ |
| 6 | #pragma once |
| 7 | |
| 8 | #include <memory> |
| 9 | |
| 10 | #include <simgear/props/props.hxx> |
| 11 | #include <simgear/structure/subsystem_mgr.hxx> |
| 12 | |
| 13 | #include "dbusconnection.h" |
| 14 | #include "dbusdispatcher.h" |
| 15 | #include "dbusserver.h" |
| 16 | #include "plugin.h" |
| 17 | |
| 18 | namespace flightgear::swift { |
| 19 | |
| 20 | class SwiftConnection : public SGSubsystem |
| 21 | { |
| 22 | public: |
| 23 | SwiftConnection() = default; |
| 24 | ~SwiftConnection(); |
| 25 | |
| 26 | // Subsystem API. |
| 27 | void init() override; |
| 28 | void reinit() override; |
| 29 | void shutdown() override; |
| 30 | void update(double delta_time_sec) override; |
| 31 | |
| 32 | // Subsystem identification. |
| 33 | static const char* staticSubsystemClassId() { return "swift"; } |
| 34 | |
| 35 | private: |
| 36 | bool startServer(const SGPropertyNode* arg, SGPropertyNode* root); |
| 37 | bool stopServer(const SGPropertyNode* arg, SGPropertyNode* root); |
| 38 | |
| 39 | // non-virtual shutdown function to avoid calling a virtual function from dtor for proper cleanup |
| 40 | void shutdownSwift(); |
| 41 | |
| 42 | std::unique_ptr<CPlugin> m_plugin; |
| 43 | bool m_initialized = false; |
| 44 | }; |
| 45 | } // namespace flightgear::swift |