diff options
Diffstat (limited to 'libadhocutil/plugins.h')
-rw-r--r-- | libadhocutil/plugins.h | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/libadhocutil/plugins.h b/libadhocutil/plugins.h index d51ad2b..d9ed4a3 100644 --- a/libadhocutil/plugins.h +++ b/libadhocutil/plugins.h @@ -22,7 +22,7 @@ namespace AdHoc { class NoSuchPluginException : public std::runtime_error { public: /// Constructor taking name and type of plugin requested. - NoSuchPluginException(const std::string &, const std::type_info &); + NoSuchPluginException(const std::string_view &, const std::type_info &); }; /// Base class for all plugin implementations. @@ -35,7 +35,7 @@ namespace AdHoc { class DLL_PUBLIC Plugin { public: /// Constructor taking name, filename and line of install. - Plugin(const std::string &, const std::string &, int); + Plugin(const std::string_view &, const std::string_view &, int); virtual ~Plugin() = default; /// Get the plugin type from the subclass. @@ -71,7 +71,7 @@ namespace AdHoc { class LoadLibraryException : public std::runtime_error { public: /// Constuctor taking syscall error details. - LoadLibraryException(const std::string & f, const char * msg); + LoadLibraryException(const std::string_view & f, const std::string_view & msg); }; template <typename T> @@ -79,7 +79,7 @@ namespace AdHoc { class DLL_PUBLIC PluginOf : public Plugin { public: /// Constructor taking an instance and name, filename and line of install for Plugin. - PluginOf(const std::shared_ptr<T> & t, const std::string & n, const std::string & f, int l); + PluginOf(const std::shared_ptr<T> & t, const std::string_view & n, const std::string_view & f, int l); ~PluginOf() = default; /// Get the type of this plugin. @@ -98,7 +98,7 @@ namespace AdHoc { public: /// Callback definition to resolve a plugin type and name to a potential library /// containing an implementation. - typedef std::function<std::optional<std::string> (const std::type_info &, const std::string &)> PluginResolver; + typedef std::function<std::optional<std::string> (const std::type_info &, const std::string_view &)> PluginResolver; PluginManager(); virtual ~PluginManager() = default; @@ -106,9 +106,9 @@ namespace AdHoc { /// Install a plugin. void add(const PluginPtr &); /// Uninstall a plugin. - void remove(const std::string &, const std::type_info &); + void remove(const std::string_view &, const std::type_info &); /// Get a specific plugin. - PluginPtr get(const std::string &, const std::type_info &) const; + PluginPtr get(const std::string_view &, const std::type_info &) const; /// Get all plugins. std::set<PluginPtr> getAll() const; /// Get all plugins of a specific type. @@ -121,7 +121,7 @@ namespace AdHoc { * @param f Filename of plugin. * @param l Line number. */ - template<typename T> void add(const std::shared_ptr<T> & i, const std::string & n, const std::string & f, int l); + template<typename T> void add(const std::shared_ptr<T> & i, const std::string_view & n, const std::string_view & f, int l); /** * Create and install a plugin @@ -133,7 +133,7 @@ namespace AdHoc { * @param l Line number. * @param args Arguments to construct an instance of I with. */ - template<typename T, typename I, typename ... Args> void create(const std::string & n, const std::string & f, int l, const Args & ... args) + template<typename T, typename I, typename ... Args> void create(const std::string_view & n, const std::string_view & f, int l, const Args & ... args) { add<T>(std::make_shared<I>(args...), n, f, l); } @@ -142,19 +142,19 @@ namespace AdHoc { * Uninstall a plugin. * @param n Name of plugin. */ - template<typename T> void remove(const std::string & n); + template<typename T> void remove(const std::string_view & n); /** * Get a specific plugin. * @param n Name of plugin. */ - template<typename T> std::shared_ptr<const PluginOf<T>> get(const std::string & n) const; + template<typename T> std::shared_ptr<const PluginOf<T>> get(const std::string_view & n) const; /** * Get the implementation from specific plugin. * @param n Name of plugin. */ - template<typename T> std::shared_ptr<T> getImplementation(const std::string & n) const; + template<typename T> std::shared_ptr<T> getImplementation(const std::string_view & n) const; /** * Get all plugins of a given time. |