Commit 31b03c0d authored by Steffen Vogel's avatar Steffen Vogel 🎅🏼
Browse files

plugin: do not store plugin name/desc in member variables

parent 50713278
......@@ -75,7 +75,7 @@ public:
{
for (Plugin *p : *plugins) {
T *t = dynamic_cast<T *>(p);
if (!t || t->name != name)
if (!t || t->getName() != name)
continue;
return t;
......@@ -118,7 +118,7 @@ class Plugin {
friend plugin::Registry;
public:
Plugin(const std::string& name, const std::string &desc);
Plugin();
virtual ~Plugin();
// copying a plugin doesn't make sense, so explicitly deny it
......@@ -127,18 +127,21 @@ public:
virtual void dump();
const std::string & getName() const;
const std::string & getDescription() const;
/// Get plugin name
virtual std::string
getName() const = 0;
// Get plugin description
virtual std::string
getDescription() const = 0;
protected:
std::string name;
std::string description;
std::string path;
Logger
getLogger()
{
return logging.get("plugin:" + name);
return logging.get("plugin:" + getName());
}
};
......@@ -146,10 +149,12 @@ template<typename T = Plugin>
void
Registry::dumpList()
{
getLogger()->info("Available plugins:");
for (Plugin *p : *plugins) {
T *t = dynamic_cast<T *>(p);
if (t)
std::cout << " - " << p->getName() << ": " << p->getDescription() << std::endl;
getLogger()->info(" - {}: {}", p->getName(), p->getDescription());
}
}
......
......@@ -32,9 +32,7 @@ using namespace villas::plugin;
List<> * Registry::plugins;
Plugin::Plugin(const std::string& name, const std::string& desc) :
name(name),
description(desc)
Plugin::Plugin()
{
Registry::add(this);
}
......@@ -97,15 +95,5 @@ void
Plugin::dump()
{
Logger logger = Registry::getLogger();
logger->info("Name: '{}' Description: '{}'", name, description);
}
const std::string & Plugin::getName() const
{
return name;
}
const std::string & Plugin::getDescription() const
{
return description;
logger->info("Name: '{}' Description: '{}'", getName(), getDescription());
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment