From 037fee0e59f53efb3c41567405f90175cc42f6a7 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Fri, 16 May 2025 22:11:30 -0400 Subject: [PATCH] refactor: remove archConsole use its only implemented method directly in logOutputters --- src/lib/arch/Arch.h | 5 +-- src/lib/arch/ArchConsoleStd.cpp | 21 ---------- src/lib/arch/ArchConsoleStd.h | 33 --------------- src/lib/arch/CMakeLists.txt | 5 --- src/lib/arch/IArchConsole.h | 56 ------------------------- src/lib/arch/unix/ArchConsoleUnix.h | 19 --------- src/lib/arch/win32/ArchConsoleWindows.h | 19 --------- src/lib/base/LogOutputters.cpp | 13 ++++-- 8 files changed, 10 insertions(+), 161 deletions(-) delete mode 100644 src/lib/arch/ArchConsoleStd.cpp delete mode 100644 src/lib/arch/ArchConsoleStd.h delete mode 100644 src/lib/arch/IArchConsole.h delete mode 100644 src/lib/arch/unix/ArchConsoleUnix.h delete mode 100644 src/lib/arch/win32/ArchConsoleWindows.h diff --git a/src/lib/arch/Arch.h b/src/lib/arch/Arch.h index 5f67a3663..635d8d079 100644 --- a/src/lib/arch/Arch.h +++ b/src/lib/arch/Arch.h @@ -28,7 +28,6 @@ #if SYSAPI_WIN32 -#include "arch/win32/ArchConsoleWindows.h" #include "arch/win32/ArchDaemonWindows.h" #include "arch/win32/ArchLogWindows.h" #include "arch/win32/ArchMultithreadWindows.h" @@ -39,7 +38,6 @@ #elif SYSAPI_UNIX -#include "arch/unix/ArchConsoleUnix.h" #include "arch/unix/ArchDaemonUnix.h" #include "arch/unix/ArchLogUnix.h" #include "arch/unix/ArchNetworkBSD.h" @@ -69,8 +67,7 @@ to each method to those implementations. Clients should use the exactly one of these objects before attempting to call any method, typically at the beginning of \c main(). */ -class Arch : public ARCH_CONSOLE, - public ARCH_DAEMON, +class Arch : public ARCH_DAEMON, public ARCH_LOG, public ARCH_MULTITHREAD, public ARCH_NETWORK, diff --git a/src/lib/arch/ArchConsoleStd.cpp b/src/lib/arch/ArchConsoleStd.cpp deleted file mode 100644 index 0a7c719e6..000000000 --- a/src/lib/arch/ArchConsoleStd.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Deskflow -- mouse and keyboard sharing utility - * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. - * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman - * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception - */ - -#include "arch/ArchConsoleStd.h" -#include "base/Log.h" - -#include - -void ArchConsoleStd::writeConsole(ELevel level, const char *str) -{ - if ((level >= kFATAL) && (level <= kWARNING)) - std::cerr << str << std::endl; - else - std::cout << str << std::endl; - - std::cout.flush(); -} diff --git a/src/lib/arch/ArchConsoleStd.h b/src/lib/arch/ArchConsoleStd.h deleted file mode 100644 index e23c2313b..000000000 --- a/src/lib/arch/ArchConsoleStd.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Deskflow -- mouse and keyboard sharing utility - * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. - * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman - * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception - */ - -#pragma once - -#include "arch/IArchConsole.h" - -//! Cross platform implementation of IArchConsole -class ArchConsoleStd : public IArchConsole -{ -public: - ArchConsoleStd() = default; - ~ArchConsoleStd() override = default; - - // IArchConsole overrides - void openConsole(const char *title) override - { - // do nothing - } - void closeConsole() override - { - // do nothing - } - void showConsole(bool) override - { - // do nothing - } - void writeConsole(ELevel level, const char *) override; -}; diff --git a/src/lib/arch/CMakeLists.txt b/src/lib/arch/CMakeLists.txt index 5b54a82cc..1f590e517 100644 --- a/src/lib/arch/CMakeLists.txt +++ b/src/lib/arch/CMakeLists.txt @@ -6,7 +6,6 @@ # Platform Specific Code if(WIN32) set(PLATFORM_CODE - win32/ArchConsoleWindows.h win32/ArchDaemonWindows.cpp win32/ArchDaemonWindows.h win32/ArchLogWindows.cpp @@ -29,7 +28,6 @@ if(WIN32) elseif(UNIX) set(PLATFORM_CODE - unix/ArchConsoleUnix.h unix/ArchDaemonUnix.cpp unix/ArchDaemonUnix.h unix/ArchLogUnix.cpp @@ -52,11 +50,8 @@ endif() add_library(arch STATIC ${PLATFORM_CODE} Arch.cpp Arch.h - ArchConsoleStd.cpp - ArchConsoleStd.h ArchDaemonNone.cpp ArchDaemonNone.h - IArchConsole.h IArchDaemon.h IArchLog.h IArchMultithread.h diff --git a/src/lib/arch/IArchConsole.h b/src/lib/arch/IArchConsole.h deleted file mode 100644 index b0d7cde5f..000000000 --- a/src/lib/arch/IArchConsole.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Deskflow -- mouse and keyboard sharing utility - * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. - * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman - * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception - */ - -#pragma once - -#include "base/ELevel.h" -#include "common/IInterface.h" - -//! Interface for architecture dependent console output -/*! -This interface defines the console operations required by -deskflow. Each architecture must implement this interface. -*/ -class IArchConsole : public IInterface -{ -public: - //! @name manipulators - //@{ - - //! Open the console - /*! - Opens the console for writing. The console is opened automatically - on the first write so calling this method is optional. Uses \c title - for the console's title if appropriate for the architecture. Calling - this method on an already open console must have no effect. - */ - virtual void openConsole(const char *title) = 0; - - //! Close the console - /*! - Close the console. Calling this method on an already closed console - must have no effect. - */ - virtual void closeConsole() = 0; - - //! Show the console - /*! - Causes the console to become visible. This generally only makes sense - for a console in a graphical user interface. Other implementations - will do nothing. Iff \p showIfEmpty is \c false then the implementation - may optionally only show the console if it's not empty. - */ - virtual void showConsole(bool showIfEmpty) = 0; - - //! Write to the console - /*! - Writes the given string to the console, opening it if necessary. - */ - virtual void writeConsole(ELevel, const char *) = 0; - - //@} -}; diff --git a/src/lib/arch/unix/ArchConsoleUnix.h b/src/lib/arch/unix/ArchConsoleUnix.h deleted file mode 100644 index 2525043a6..000000000 --- a/src/lib/arch/unix/ArchConsoleUnix.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Deskflow -- mouse and keyboard sharing utility - * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. - * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman - * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception - */ - -#pragma once - -#include "arch/ArchConsoleStd.h" - -#define ARCH_CONSOLE ArchConsoleUnix - -class ArchConsoleUnix : public ArchConsoleStd -{ -public: - ArchConsoleUnix() = default; - ~ArchConsoleUnix() override = default; -}; diff --git a/src/lib/arch/win32/ArchConsoleWindows.h b/src/lib/arch/win32/ArchConsoleWindows.h deleted file mode 100644 index ecde1d998..000000000 --- a/src/lib/arch/win32/ArchConsoleWindows.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Deskflow -- mouse and keyboard sharing utility - * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. - * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman - * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception - */ - -#pragma once - -#include "arch/ArchConsoleStd.h" - -#define ARCH_CONSOLE ArchConsoleWindows - -class ArchConsoleWindows : public ArchConsoleStd -{ -public: - ArchConsoleWindows() = default; - ~ArchConsoleWindows() override = default; -}; diff --git a/src/lib/base/LogOutputters.cpp b/src/lib/base/LogOutputters.cpp index 6a5616610..ff18ee7fb 100644 --- a/src/lib/base/LogOutputters.cpp +++ b/src/lib/base/LogOutputters.cpp @@ -12,6 +12,7 @@ #include "base/String.h" #include +#include enum EFileLogOutputter { @@ -48,22 +49,26 @@ bool StopLogOutputter::write(ELevel, const char *) void ConsoleLogOutputter::open(const char *title) { - ARCH->openConsole(title); + // do nothing } void ConsoleLogOutputter::close() { - ARCH->closeConsole(); + // do nothing } void ConsoleLogOutputter::show(bool showIfEmpty) { - ARCH->showConsole(showIfEmpty); + // do nothing } bool ConsoleLogOutputter::write(ELevel level, const char *msg) { - ARCH->writeConsole(level, msg); + if ((level >= kFATAL) && (level <= kWARNING)) + std::cerr << msg << std::endl; + else + std::cout << msg << std::endl; + std::cout.flush(); return true; }