mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
plugin: do not store plugin name/desc in member variables
This commit is contained in:
parent
1595a39b2e
commit
8e8c29ba6c
2 changed files with 15 additions and 22 deletions
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue