1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

plugin: require name and add method to dump list

This commit is contained in:
daniel-k 2017-12-06 16:58:17 +01:00
parent d63c2b30bf
commit a194f8d0b2
4 changed files with 21 additions and 4 deletions

View file

@ -101,7 +101,8 @@ protected:
class FpgaIpFactory : public Plugin {
public:
FpgaIpFactory()
FpgaIpFactory(std::string concreteName) :
Plugin(std::string("FPGA IP Factory: ") + concreteName)
{ pluginType = Plugin::Type::FpgaIp; }
/// Returns a running and checked FPGA IP

View file

@ -66,6 +66,10 @@ private:
class InterruptControllerFactory : public FpgaIpFactory {
public:
InterruptControllerFactory() :
FpgaIpFactory(getName())
{}
FpgaIp* create()
{ return new InterruptController; }

View file

@ -40,7 +40,7 @@ public:
FpgaIp,
};
Plugin();
Plugin(std::string name);
virtual ~Plugin();
// each plugin is a singleton, so copying is not allowed
@ -53,6 +53,9 @@ public:
virtual int parse(json_t *cfg);
virtual void dump();
static void
dumpList();
/** Find registered and loaded plugin with given name and type. */
static Plugin *
lookup(Type type, std::string name);

View file

@ -45,9 +45,9 @@ Plugin::pluginListBuffer;
int Plugin::pluginListNiftyCounter;
Plugin::Plugin() :
Plugin::Plugin(std::string name) :
pluginType(Plugin::Type::Unknown),
name(""),
name(name),
description(""),
path(""),
state(STATE_INITIALIZED)
@ -120,6 +120,15 @@ Plugin::dump()
std::cout << " - " << this->name << ": " << this->description << std::endl;
}
void
Plugin::dumpList()
{
std::cout << "Registered plugins:" << std::endl;
for(auto& p : pluginList) {
std::cout << " - " << p->name << std::endl;
}
}
Plugin*
Plugin::lookup(Plugin::Type type, std::string name)
{