18 #include <unordered_map> 27 virtual const std::string who_am_i() = 0;
30 typedef IPlugin* (*plugin_creator_t)();
31 typedef std::unordered_map<std::string, plugin_creator_t> plugin_creator_map_t;
33 IPlugin* create_plugin(
const std::string& plugin_name);
34 IPlugin* create_plugin(
const std::string& plugin_name,
35 const plugin_creator_map_t& plugin_creator_map);
37 void create_all_plugins(
const plugin_creator_map_t& plugin_creator_map,
38 std::unordered_map<std::string, IPlugin*>& plugin_m);
41 template <
typename PluginType> IPlugin* default_plugin_creator() {
42 return new (std::nothrow) PluginType;
45 void register_plugin_creator(
const std::string& plugin_name,
46 plugin_creator_t creator);
47 void register_plugin_creator(
const std::string& plugin_name,
48 plugin_creator_t creator,
49 plugin_creator_map_t& plugin_creator_map);
51 template <
typename PluginType>
52 void register_plugin_class(
const std::string& plugin_name) {
53 return register_plugin_creator(plugin_name,
54 default_plugin_creator<PluginType>);
58 template <
typename PluginType>
59 void register_plugin_class(
const std::string& plugin_name,
60 plugin_creator_map_t& plugin_creator_map) {
61 return register_plugin_creator(
62 plugin_name, default_plugin_creator<PluginType>, plugin_creator_map);