Add access to a list of registered plugin klasses.
This commit is contained in:
parent
7ff9b59825
commit
fe6838e843
@ -18,9 +18,12 @@
|
|||||||
Fl_Plugin class . */
|
Fl_Plugin class . */
|
||||||
|
|
||||||
#ifndef Fl_Plugin_H
|
#ifndef Fl_Plugin_H
|
||||||
# define Fl_Plugin_H
|
#define Fl_Plugin_H
|
||||||
|
|
||||||
# include "Fl_Preferences.H"
|
#include "Fl_Preferences.H"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,6 +86,7 @@ public:
|
|||||||
static void removePlugin(Fl_Preferences::ID id);
|
static void removePlugin(Fl_Preferences::ID id);
|
||||||
static int load(const char *filename);
|
static int load(const char *filename);
|
||||||
static int loadAll(const char *dirpath, const char *pattern=0);
|
static int loadAll(const char *dirpath, const char *pattern=0);
|
||||||
|
static std::vector<std::string> klass_list();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2118,3 +2118,25 @@ int Fl_Plugin_Manager::loadAll(const char *dirpath, const char *pattern) {
|
|||||||
free(dir);
|
free(dir);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Return a list of all plugin klasses that have been registered so far.
|
||||||
|
The returned strings can be used to crate a manager for the klass of
|
||||||
|
plugins, which in turn can be used to list plugins for that klass.
|
||||||
|
```
|
||||||
|
auto kl = Fl_Plugin_Manager::klass_list();
|
||||||
|
for (auto &k: kl) {
|
||||||
|
Fl_Plugin_Manager m { k.c_str() };
|
||||||
|
std::cout << m.plugins() << "plugins have registered for klass" << k << std::endl;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
\return a copy of a vector of strings
|
||||||
|
*/
|
||||||
|
std::vector<std::string> Fl_Plugin_Manager::klass_list() {
|
||||||
|
Fl_Preferences p(0, "plugins");
|
||||||
|
std::vector<std::string> pm;
|
||||||
|
for (int i = 0; i < p.groups(); i++) {
|
||||||
|
pm.push_back(p.group(i));
|
||||||
|
}
|
||||||
|
return pm;
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user