mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Use unique_ptr instead of shared_ptr for PluginInterface pointers
unique_ptr is simpler, and can be easily converted to shared_ptr if needed, and makes it obvious that each call will return a new pointer. This does mean that if I want to hold onto the objects again in the future for some reason, that'll need the API to change back, but that seems unlikely. unique_ptr not being copyable does make using it a little more awkward, but that only happened in one place in LOOT's code, and there the pointer needs to become shared anyway.
This commit is contained in:
@@ -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<const PluginInterface> GetPlugin(
|
||||
virtual std::unique_ptr<const PluginInterface> 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<std::shared_ptr<const PluginInterface>> GetLoadedPlugins()
|
||||
virtual std::vector<std::unique_ptr<const PluginInterface>> GetLoadedPlugins()
|
||||
const = 0;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user