libRoadRunner Plugin C++ API  1.0.0
 All Classes Files Functions Variables Friends Pages
rrPluginManager.h
Go to the documentation of this file.
1 
41 #ifndef rrPluginManagerH
42 #define rrPluginManagerH
43 #include <vector>
44 #include <string>
45 #include "rrPluginsAPIExporter.h"
46 #include "rrConstants.h"
47 #include "rrStringList.h"
48 #include "Poco/SharedLibrary.h"
49 //---------------------------------------------------------------------------
50 /* A minimalistic Plugin manager. */
51 
52 namespace rrp
53 {
54 
55 using std::string;
56 using std::vector;
57 using std::pair;
58 using rr::gEmptyString;
59 using rr::StringList;
60 using Poco::SharedLibrary;
61 
62 class Plugin;
63 
67 typedef pair< Poco::SharedLibrary*, Plugin* > rrPlugin;
68 
79 class PLUGINS_API_DECLSPEC PluginManager
80 {
81  public:
88  PluginManager(const string& pluginFolder = gEmptyString);
93  virtual ~PluginManager();
94 
100  bool setPluginDir(const string& dir);
101 
106  string getPluginDir();
107 
112  bool load(const string& pluginName = gEmptyString);
113 
118  bool unload(Plugin* plugin = NULL);
119 
123  int getNumberOfPlugins();
124 
129  int getNumberOfCategories();
130 
137  Plugin* getFirstPlugin();
138 
144  Plugin* getNextPlugin();
145 
151  Plugin* getPreviousPlugin();
152 
157  Plugin* getCurrentPlugin();
158 
164  Plugin* getPlugin(const string& name);
165 
170  StringList getPluginNames();
171 
176  StringList getPluginLibraryNames();
177  private:
178  string mPluginFolder;
179  string mPluginExtension; //Different on different OS's
180  vector< rrPlugin > mPlugins;
181  vector< rrPlugin >::iterator mPluginsIter;
182 
183  bool loadPlugin(const string& sharedLib);
184  bool checkImplementationLanguage(SharedLibrary* plugin);
185  const char* getImplementationLanguage(SharedLibrary* plugin);
186  Plugin* createCPlugin(SharedLibrary *libHandle);
187  Plugin* getPlugin(const int& i);
188  Plugin* operator[](const int& i);
189  bool unloadAll();
190 };
191 
192 }
193 #endif
194 
Definition: rrPlugin.h:94
Definition: rrPluginManager.h:79