From e7bb903f0305b2c3c14074d23d52cc982072667e Mon Sep 17 00:00:00 2001 From: Bob Polis Date: Wed, 6 Oct 2021 14:12:38 +0200 Subject: [PATCH] Added name member --- plugin.hpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugin.hpp b/plugin.hpp index c4f9716..bbfc727 100644 --- a/plugin.hpp +++ b/plugin.hpp @@ -34,7 +34,8 @@ namespace sc { std::string::size_type lastdot = plugname.rfind("."); if (plugname.substr(lastdot + 1) == ext) { plugin plugin {dir + '/' + plugname}; - plugins.emplace(plugname.substr(0, lastdot), std::move(plugin)); + plugin.name(plugname.substr(0, lastdot)); + plugins.emplace(plugin.name(), std::move(plugin)); } } } @@ -102,7 +103,10 @@ namespace sc { return *this; } - std::string path() const { return _path; } + const std::string& path() const { return _path; } + + const std::string& name() const { return _name; } + void name(const std::string& nm) { _name = nm; } std::unique_ptr operator()() const { std::unique_ptr obj; @@ -116,6 +120,7 @@ namespace sc { static std::map> plugins; std::string _path; + std::string _name; void* _plugin {nullptr}; using factory = T*(*)(); factory _factory {nullptr};