diff --git a/cpp/include/loot/game_interface.h b/cpp/include/loot/game_interface.h index 49d7708e..d48a2762 100644 --- a/cpp/include/loot/game_interface.h +++ b/cpp/include/loot/game_interface.h @@ -141,22 +141,18 @@ public: * @brief Get data for a loaded plugin. * @param pluginName * The filename of the plugin to get data for. - * @returns A shared pointer to a const PluginInterface implementation. The - * pointer is null if the given plugin has not been loaded. Repeated - * calls given the same filename may return different pointers to - * equivalent objects. + * @returns A pointer to a const PluginInterface implementation. The + * pointer is null if the given plugin has not been loaded. */ - virtual std::shared_ptr GetPlugin( + virtual std::unique_ptr GetPlugin( std::string_view pluginName) const = 0; /** * @brief Get a set of const references to all loaded plugins' PluginInterface * objects. - * @returns A set of shared pointers to const PluginInterface objects. - * Repeated calls may return different pointers to equivalent - * objects. + * @returns A set of pointers to const PluginInterface objects. */ - virtual std::vector> GetLoadedPlugins() + virtual std::vector> GetLoadedPlugins() const = 0; /** diff --git a/cpp/src/api/game.cpp b/cpp/src/api/game.cpp index 9932a895..70b8c7da 100644 --- a/cpp/src/api/game.cpp +++ b/cpp/src/api/game.cpp @@ -171,7 +171,7 @@ void Game::LoadPlugins(const std::vector& pluginPaths, void Game::ClearLoadedPlugins() { game_->clear_loaded_plugins(); } -std::shared_ptr Game::GetPlugin( +std::unique_ptr Game::GetPlugin( std::string_view pluginName) const { const auto pluginOpt = game_->plugin(convert(pluginName)); if (!pluginOpt->is_some()) { @@ -179,19 +179,19 @@ std::shared_ptr Game::GetPlugin( } try { - return std::make_shared( + return std::make_unique( std::move(pluginOpt->as_ref().boxed_clone())); } catch (const ::rust::Error& e) { std::rethrow_exception(mapError(e)); } } -std::vector> Game::GetLoadedPlugins() +std::vector> Game::GetLoadedPlugins() const { - std::vector> plugins; + std::vector> plugins; for (const auto& pluginRef : game_->loaded_plugins()) { plugins.push_back( - std::make_shared(std::move(pluginRef.boxed_clone()))); + std::make_unique(std::move(pluginRef.boxed_clone()))); } return plugins; diff --git a/cpp/src/api/game.h b/cpp/src/api/game.h index ea660a77..2c6659a6 100644 --- a/cpp/src/api/game.h +++ b/cpp/src/api/game.h @@ -35,10 +35,10 @@ public: void ClearLoadedPlugins() override; - std::shared_ptr GetPlugin( + std::unique_ptr GetPlugin( std::string_view pluginName) const override; - std::vector> GetLoadedPlugins() + std::vector> GetLoadedPlugins() const override; std::vector SortPlugins(