From a194f8d0b253231969ea968b0df77bd6a723288c Mon Sep 17 00:00:00 2001 From: daniel-k Date: Wed, 6 Dec 2017 16:58:17 +0100 Subject: [PATCH] plugin: require name and add method to dump list --- fpga/include/villas/fpga/ip.hpp | 3 ++- fpga/include/villas/fpga/ips/intc.hpp | 4 ++++ fpga/include/villas/plugin.hpp | 5 ++++- fpga/lib/plugin.cpp | 13 +++++++++++-- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/fpga/include/villas/fpga/ip.hpp b/fpga/include/villas/fpga/ip.hpp index 0ed4bdca1..2f31562da 100644 --- a/fpga/include/villas/fpga/ip.hpp +++ b/fpga/include/villas/fpga/ip.hpp @@ -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 diff --git a/fpga/include/villas/fpga/ips/intc.hpp b/fpga/include/villas/fpga/ips/intc.hpp index 1facaa38c..2bf36fecf 100644 --- a/fpga/include/villas/fpga/ips/intc.hpp +++ b/fpga/include/villas/fpga/ips/intc.hpp @@ -66,6 +66,10 @@ private: class InterruptControllerFactory : public FpgaIpFactory { public: + InterruptControllerFactory() : + FpgaIpFactory(getName()) + {} + FpgaIp* create() { return new InterruptController; } diff --git a/fpga/include/villas/plugin.hpp b/fpga/include/villas/plugin.hpp index b2ce41755..54ad8d568 100644 --- a/fpga/include/villas/plugin.hpp +++ b/fpga/include/villas/plugin.hpp @@ -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); diff --git a/fpga/lib/plugin.cpp b/fpga/lib/plugin.cpp index fd3c83494..0c887ed48 100644 --- a/fpga/lib/plugin.cpp +++ b/fpga/lib/plugin.cpp @@ -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) {