PluginManager.hh
1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#ifndef PLUGIN_PLUGINMANAGER_HH
#define PLUGIN_PLUGINMANAGER_HH
#include <string>
#include <map>
#include <dsgpatt_Singleton.hh>
#include <log4cxx/logger.h>
#include <AMDA_exception.hh>
#include "Plugin.hh"
namespace AMDA {
namespace Plugins {
/**
* logger definition
*/
extern log4cxx::LoggerPtr gLogger;
/**
* Exception specific for AMDA::XMLParameterConfigurator module
*/
struct exception: virtual AMDA_exception { };
/**
* Class PluginManager
* Description : Manage plugin loading
*/
class PluginManager: public Singleton<PluginManager> {
public:
// Design pattern
friend class Singleton<PluginManager> ;
/**
Loads 'path/PluginName' plugin
*/
void loadPlugin(const std::string &path, const std::string &sPluginName);
/**
Loads a plugin which match with: ${sPluginName}/lib/{sPluginName}.so
*/
void loadPlugin(const std::string &sPluginName);
/**
Attempt to load all libraries which match with this pattern '.so'
*/
void loadPluginFromPath(const std::string& pluginsPath);
void loadPluginFromConfigFile(const char* fileName);
/**
Get a reference to the list of Plugins
*/
inline const std::map<std::string, Plugin>& getALLPluginLoaded() {
return _loadedPlugins;
}
void registerPlugin(const std::string &pluginName,
const std::string &pluginPath);
protected:
/**
Constructor (default one)
*/
PluginManager() {
}
/**
Copy Constructor (normally should not be used)
*/
// PluginManager(const PluginManager& /*copied*/) {
// }
/**
Destructor
*/
virtual ~PluginManager() {
}
private:
/// Map of plugins by their associated file names
typedef std::map<std::string, Plugin> PluginMap;
PluginMap _loadedPlugins; ///< All plugins currently loaded
};
} // namespace Plugins
} // namespace AMDA
#endif // PLUGIN_PLUGINMANAGER_HH