39
41
module::Registry::~Registry()
41
map<string, plugin::Plugin *>::iterator plugin_iter;
43
std::map<std::string, plugin::Plugin *>::iterator plugin_iter;
43
45
/* Give all plugins a chance to cleanup, before
44
46
* all plugins are deleted.
61
63
plugin_registry.clear();
64
@TODO When we delete modules here, we segfault on a bad string. Why?
66
@TODO When we delete modules here, we segfault on a bad string. Why?
65
67
map<string, module::Module *>::iterator module_iter= module_map.begin();
66
69
while (module_iter != module_map.end())
68
71
delete (*module_iter).second;
71
74
module_map.clear();
73
map<string, module::Library *>::iterator library_iter= library_map.begin();
76
std::map<std::string, module::Library *>::iterator library_iter= library_map.begin();
74
77
while (library_iter != library_map.end())
76
79
delete (*library_iter).second;
88
module::Module *module::Registry::find(string name)
91
module::Module *module::Registry::find(std::string name)
90
transform(name.begin(), name.end(), name.begin(), ::tolower);
93
std::transform(name.begin(), name.end(), name.begin(), ::tolower);
92
map<string, module::Module *>::iterator map_iter;
95
std::map<std::string, module::Module *>::iterator map_iter;
93
96
map_iter= module_map.find(name);
94
97
if (map_iter != module_map.end())
95
98
return (*map_iter).second;
99
102
void module::Registry::add(module::Module *handle)
101
string add_str(handle->getName());
104
std::string add_str(handle->getName());
102
105
transform(add_str.begin(), add_str.end(),
103
106
add_str.begin(), ::tolower);
108
111
void module::Registry::remove(module::Module *handle)
110
string remove_str(handle->getName());
111
transform(remove_str.begin(), remove_str.end(),
112
remove_str.begin(), ::tolower);
113
std::string remove_str(handle->getName());
114
std::transform(remove_str.begin(), remove_str.end(),
115
remove_str.begin(), ::tolower);
114
117
module_map.erase(remove_str);
120
void module::Registry::copy(plugin::Plugin::vector &arg)
122
arg.reserve(plugin_registry.size());
124
std::transform(plugin_registry.begin(),
125
plugin_registry.end(),
126
std::back_inserter(arg),
127
boost::bind(&plugin::Plugin::map::value_type::second, _1) );
128
assert(arg.size() == plugin_registry.size());
117
131
vector<module::Module *> module::Registry::getList(bool active)
119
133
module::Module *plugin= NULL;
121
vector<module::Module *> plugins;
135
std::vector<module::Module *> plugins;
122
136
plugins.reserve(module_map.size());
124
map<string, module::Module *>::iterator map_iter;
138
std::map<std::string, module::Module *>::iterator map_iter;
125
139
for (map_iter= module_map.begin();
126
140
map_iter != module_map.end();
160
void module::Registry::removeLibrary(const string &plugin_name)
174
void module::Registry::removeLibrary(const std::string &plugin_name)
162
map<string, module::Library *>::iterator iter=
176
std::map<std::string, module::Library *>::iterator iter=
163
177
library_map.find(plugin_name);
164
178
if (iter != library_map.end())
171
module::Library *module::Registry::findLibrary(const string &plugin_name) const
185
module::Library *module::Registry::findLibrary(const std::string &plugin_name) const
173
map<string, module::Library *>::const_iterator iter=
187
std::map<std::string, module::Library *>::const_iterator iter=
174
188
library_map.find(plugin_name);
175
189
if (iter != library_map.end())
176
190
return (*iter).second;