From 364e2d25c08f2a323071c00ab0d5d502276852e6 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Thu, 13 Nov 2025 21:54:21 +0000 Subject: [PATCH] Prevent copy & move of abstract classes To prevent slicing, following C++ Core Guidelines C.21 and C.67. --- cpp/include/loot/database_interface.h | 7 +++++++ cpp/include/loot/game_interface.h | 7 +++++++ cpp/include/loot/plugin_interface.h | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/cpp/include/loot/database_interface.h b/cpp/include/loot/database_interface.h index f5f43366..69242714 100644 --- a/cpp/include/loot/database_interface.h +++ b/cpp/include/loot/database_interface.h @@ -39,8 +39,15 @@ namespace loot { /** @brief The interface provided by API's database handle. */ class DatabaseInterface { public: + DatabaseInterface() = default; + DatabaseInterface(const DatabaseInterface&) = delete; + DatabaseInterface(DatabaseInterface&&) = delete; + virtual ~DatabaseInterface() = default; + DatabaseInterface& operator=(const DatabaseInterface&) = delete; + DatabaseInterface& operator=(DatabaseInterface&&) = delete; + /** * @name Data Reading & Writing * @{ diff --git a/cpp/include/loot/game_interface.h b/cpp/include/loot/game_interface.h index 71238b84..49d7708e 100644 --- a/cpp/include/loot/game_interface.h +++ b/cpp/include/loot/game_interface.h @@ -32,8 +32,15 @@ namespace loot { /** @brief The interface provided for accessing game-specific functionality. */ class GameInterface { public: + GameInterface() = default; + GameInterface(const GameInterface&) = delete; + GameInterface(GameInterface&&) = delete; + virtual ~GameInterface() = default; + GameInterface& operator=(const GameInterface&) = delete; + GameInterface& operator=(GameInterface&&) = delete; + /** * @brief Get the game's type. * @returns The game's type. diff --git a/cpp/include/loot/plugin_interface.h b/cpp/include/loot/plugin_interface.h index dc152a01..d3bfec0b 100644 --- a/cpp/include/loot/plugin_interface.h +++ b/cpp/include/loot/plugin_interface.h @@ -40,8 +40,15 @@ namespace loot { */ class PluginInterface { public: + PluginInterface() = default; + PluginInterface(const PluginInterface&) = delete; + PluginInterface(PluginInterface&&) = delete; + virtual ~PluginInterface() = default; + PluginInterface& operator=(const PluginInterface&) = delete; + PluginInterface& operator=(PluginInterface&&) = delete; + /** * Get the plugin's filename. * @return The plugin filename. If the plugin was ghosted when it was loaded,