6 #ifndef BOOST_PLUGIN_FACTORY_VP_2004_08_25 7 #define BOOST_PLUGIN_FACTORY_VP_2004_08_25 17 namespace utilmm {
namespace plugin {
20 typedef std::map<std::string, boost::any> exported_plugins_t;
21 typedef exported_plugins_t& (*get_plugins_list_t)();
22 typedef exported_plugins_t& (get_plugins_list_np)();
24 template<
class BasePlugin>
25 std::pair<abstract_factory<BasePlugin>*,
27 get_abstract_factory(
const dll& d,
const std::string& klass)
29 boost::shared_ptr<get_plugins_list_np> f;
30 f = d.template get<exported_plugins_t& (*)()>(
"boost_exported_plugins_list");
31 exported_plugins_t& e = (*f)();
35 abstract_factory<BasePlugin>** xw =
36 boost::any_cast<abstract_factory<BasePlugin>*>(&(e[klass]));
39 throw std::logic_error(
"Can't cast to the right factor type\n");
41 abstract_factory<BasePlugin>* w = *xw;
42 return make_pair(w, f);
44 throw std::logic_error(
"Class of the specified name is not found");
58 template<
class BasePlugin,
class Base,
class Parameters>
62 template<
class BasePlugin,
class Base>
65 BasePlugin*
create(
const std::string& name)
67 std::pair<abstract_factory<BasePlugin>*,
69 return r.first->create(r.second);
73 template<
class BasePlugin,
class Base,
class A1>
76 BasePlugin*
create(
const std::string& name, A1 a1)
78 std::pair<abstract_factory<BasePlugin>*,
80 return r.first->create(r.second, a1);
84 template<
class BasePlugin,
class Base,
class A1,
class A2>
87 BasePlugin*
create(
const std::string& name, A1 a1, A2 a2)
89 std::pair<abstract_factory<BasePlugin>*,
91 return r.first->create(r.second, a1, a2);
97 template<
class BasePlugin,
class Base,
class Parameters>
100 public plugin_factory_item_N<BasePlugin, Parameters>
104 using plugin_factory_item_N<BasePlugin, Parameters>::create;
110 template<
class BasePlugin>
112 public boost::mpl::inherit_linearly<
113 typename virtual_constructors<BasePlugin>::type,
114 plugin_factory_item<BasePlugin, _, _>,
115 empty_plugin_factory_item>::type
Definition: undirected_graph.hh:345
boost::shared_ptr< std::map< std::string, boost::any > &()> dll_handle
Definition: virtual_constructors.hh:19
Definition: plugin_factory.hh:59
Definition: plugin_factory.hh:52
BasePlugin * create(const std::string &name, A1 a1)
Definition: plugin_factory.hh:76
BasePlugin * create(const std::string &name)
Definition: plugin_factory.hh:65
Definition: plugin_factory.hh:111
dll m_dll
Definition: plugin_factory.hh:55
Definition: auto_flag.hh:6
plugin_factory(const dll &d)
Definition: plugin_factory.hh:117
BasePlugin * create(const std::string &name, A1 a1, A2 a2)
Definition: plugin_factory.hh:87