From bfa27a14b0eaa73f2d63df02e160eaeeb3403acd Mon Sep 17 00:00:00 2001 From: Alexander Aksenov Date: Fri, 27 Apr 2018 20:07:03 +0300 Subject: [PATCH] Move Protocol's derived classes commons in Protocol Signed-off-by: Alexander Aksenov --- src/debug/netcoredbg/debugger.h | 7 +++++++ src/debug/netcoredbg/miprotocol.h | 5 +---- src/debug/netcoredbg/vscodeprotocol.h | 5 +---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/debug/netcoredbg/debugger.h b/src/debug/netcoredbg/debugger.h index 45e90cb..b5b2a01 100644 --- a/src/debug/netcoredbg/debugger.h +++ b/src/debug/netcoredbg/debugger.h @@ -57,7 +57,14 @@ public: class Protocol { +protected: + bool m_exit; + Debugger *m_debugger; + public: + Protocol() : m_exit(false), m_debugger(nullptr) {} + void SetDebugger(Debugger *debugger) { m_debugger = debugger; } + virtual void EmitInitializedEvent() = 0; virtual void EmitStoppedEvent(StoppedEvent event) = 0; virtual void EmitExitedEvent(ExitedEvent event) = 0; diff --git a/src/debug/netcoredbg/miprotocol.h b/src/debug/netcoredbg/miprotocol.h index 6d40340..e349915 100644 --- a/src/debug/netcoredbg/miprotocol.h +++ b/src/debug/netcoredbg/miprotocol.h @@ -15,8 +15,6 @@ class MIProtocol : public Protocol { static std::mutex m_outMutex; - bool m_exit; - Debugger *m_debugger; std::string m_fileExec; std::vector m_execArgs; @@ -25,10 +23,9 @@ class MIProtocol : public Protocol std::unordered_map m_vars; std::unordered_map > m_breakpoints; public: - void SetDebugger(Debugger *debugger) { m_debugger = debugger; } static std::string EscapeMIValue(const std::string &str); - MIProtocol() : m_exit(false), m_debugger(nullptr), m_varCounter(0) {} + MIProtocol() : Protocol(), m_varCounter(0) {} void EmitInitializedEvent() override {} void EmitStoppedEvent(StoppedEvent event) override; void EmitExitedEvent(ExitedEvent event) override; diff --git a/src/debug/netcoredbg/vscodeprotocol.h b/src/debug/netcoredbg/vscodeprotocol.h index 2f2e7de..7801a08 100644 --- a/src/debug/netcoredbg/vscodeprotocol.h +++ b/src/debug/netcoredbg/vscodeprotocol.h @@ -27,8 +27,6 @@ class VSCodeProtocol : public Protocol LogFile } m_engineLogOutput; std::ofstream m_engineLog; - bool m_exit; - Debugger *m_debugger; uint64_t m_seqCounter; @@ -41,8 +39,7 @@ class VSCodeProtocol : public Protocol public: - VSCodeProtocol() : m_engineLogOutput(LogNone), m_exit(false), m_debugger(nullptr), m_seqCounter(1) {} - void SetDebugger(Debugger *debugger) { m_debugger = debugger; } + VSCodeProtocol() : Protocol(), m_engineLogOutput(LogNone), m_seqCounter(1) {} void EngineLogging(const std::string &path); void EmitInitializedEvent() override; -- 2.7.4