BasicPluginFactory.h
Go to the documentation of this file.
1 #ifndef cetlib_BasicPluginFactory_h
2 #define cetlib_BasicPluginFactory_h
3 ////////////////////////////////////////////////////////////////////////
4 // BasicPluginFactory
5 //
6 // Refinement of PluginFactory for a common class of plugins featuring a
7 // "pluginType" function and a "makePlugin" function. The pluginType
8 // function must be compatible with the following signature:
9 //
10 // std::string ()
11 //
12 // For a useful class template / macro combination to formalize the
13 // pluginType, see cetlib/PluginTypeDeducer.h
14 //
15 // The make function is arbitrary in signature: the result type must be
16 // specified but the arguments (if any) may be deduced.
17 //
18 ////////////////////////////////////////////////////////////////////////
19 
20 #include "cetlib/PluginFactory.h"
21 
22 namespace cet {
23  class BasicPluginFactory;
24 }
25 
27 public:
28  explicit BasicPluginFactory(
30  std::string const& suffix = "plugin",
31  std::string const& makerName = "makePlugin",
32  std::string const& pluginTypeFuncName = "pluginType");
33 
34  explicit BasicPluginFactory(
35  std::string const& suffix = "plugin",
36  std::string const& makerName = "makePlugin",
37  std::string const& pluginTypeFuncName = "pluginType");
38 
39  // Find and call the makePlugin() function in the plugin library.
40  template <typename RESULT_TYPE, typename... ARGS>
42  makePlugin(std::string const& libspec, ARGS&&... args);
43 
44  template <typename FUNCTION_TYPE>
46  std::function<FUNCTION_TYPE>>
47  makePlugin(std::string const& libspec);
48 
49  // Find and call the pluginType() function in the plugin library.
50  std::string pluginType(std::string const& libspec);
51 
52 private:
55 };
56 
57 inline std::string
59 {
60  return call<std::string>(libspec, pluginTypeFuncName_);
61 }
62 
63 template <typename RESULT_TYPE, typename... ARGS>
66 {
67  return call<RESULT_TYPE>(libspec, makerName_, std::forward<ARGS>(args)...);
68 }
69 
70 template <typename FUNCTION_TYPE>
72  std::function<FUNCTION_TYPE>>
74 {
75  return find<FUNCTION_TYPE>(libspec, makerName_);
76 }
77 
78 #endif /* cetlib_BasicPluginFactory_h */
79 
80 // Local Variables:
81 // mode: c++
82 // End:
std::string const pluginTypeFuncName_
std::string pluginType(std::string const &libspec)
std::string const makerName_
const XML_Char int const XML_Char * value
Definition: expat.h:331
BasicPluginFactory(cet::search_path const &search_path, std::string const &suffix="plugin", std::string const &makerName="makePlugin", std::string const &pluginTypeFuncName="pluginType")
std::enable_if_t<!std::is_function< RESULT_TYPE >::value, RESULT_TYPE > makePlugin(std::string const &libspec, ARGS &&...args)
enum BeamMode string