From 1d7b3bd180c62789f2f425cfeaca2c9269c3a3cd Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 27 Aug 2018 14:18:14 +0200 Subject: [PATCH] Ref T312, simulator factory not copyable plus check function (bypassing timer) --- src/blackcore/simulator.cpp | 6 ++++++ src/blackcore/simulator.h | 21 ++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/blackcore/simulator.cpp b/src/blackcore/simulator.cpp index 53338666d..552bf9c41 100644 --- a/src/blackcore/simulator.cpp +++ b/src/blackcore/simulator.cpp @@ -1145,4 +1145,10 @@ namespace BlackCore this->stopImpl(); m_isRunning = false; } + + void ISimulatorListener::check() + { + if (!m_isRunning) { return; } + this->checkImpl(); + } } // namespace diff --git a/src/blackcore/simulator.h b/src/blackcore/simulator.h index b1f72b271..d1ad990d0 100644 --- a/src/blackcore/simulator.h +++ b/src/blackcore/simulator.h @@ -584,9 +584,6 @@ namespace BlackCore //! Info about the backend system (if available) virtual QString backendInfo() const; - //! Overall (swift) application shutting down - virtual bool isShuttingDown() const; - public slots: //! Start listening for the simulator to start. void start(); @@ -594,6 +591,9 @@ namespace BlackCore //! Stops listening. void stop(); + //! Check simulator availability + void check(); + signals: //! Emitted when the listener discovers the simulator running. void simulatorStarted(const BlackMisc::Simulation::CSimulatorPluginInfo &info); @@ -603,12 +603,18 @@ namespace BlackCore //! \sa ISimulatorFactory::createListener(). ISimulatorListener(const BlackMisc::Simulation::CSimulatorPluginInfo &info); + //! Overall (swift) application shutting down + virtual bool isShuttingDown() const; + //! Plugin specific implementation to start listener virtual void startImpl() = 0; //! Plugin specific implementation to stop listener virtual void stopImpl() = 0; + //! Plugin specific implementation to check + virtual void checkImpl() = 0; + private: BlackMisc::Simulation::CSimulatorPluginInfo m_info; bool m_isRunning = false; @@ -621,6 +627,11 @@ namespace BlackCore //! ISimulatorVirtual destructor virtual ~ISimulatorFactory() {} + //! Not copyable @{ + ISimulatorFactory(const ISimulatorFactory &) = delete; + ISimulatorFactory &operator=(const ISimulatorFactory &) = delete; + //! @} + //! Create a new instance of a driver //! \param info metadata about simulator //! \param ownAircraftProvider in memory access to own aircraft data @@ -638,6 +649,10 @@ namespace BlackCore //! Simulator listener instance virtual ISimulatorListener *createListener(const BlackMisc::Simulation::CSimulatorPluginInfo &info) = 0; + + protected: + //! Default ctor + ISimulatorFactory() {} }; } // namespace