ToolMacros.h
Go to the documentation of this file.
1 #ifndef art_Utilities_ToolMacros_h
2 #define art_Utilities_ToolMacros_h
3 
4 ////////////////////////////////////////////////////////////////////////
5 // ToolMacros
6 //
7 // Defines the macro DEFINE_ART_TOOL(<tool_classname>) to be used in
8 // XXX_tool.cc to declare art tools.
9 //
10 // Note: Libraries that include these symbol definitions cannot be
11 // linked into a main program as other libraries are. This is because
12 // the "one definition" rule would be violated.
13 //
14 ////////////////////////////////////////////////////////////////////////
15 
18 #include "cetlib/compiler_macros.h"
19 #include "fhiclcpp/ParameterSet.h"
21 #include "fhiclcpp/types/Atom.h"
22 
23 #include <memory>
24 #include <string>
25 #include <type_traits>
26 
27 namespace art::detail {
28  struct ToolConfig {
30  };
31 }
32 
33 #define ART_PROVIDE_ALLOWED_CONFIGURATION_FUNCTION_TOOL() \
34  std::unique_ptr<fhicl::ConfigurationTable> allowed_configuration( \
35  std::string const& name) \
36  { \
37  return std::make_unique<fhicl::WrappedTable<art::detail::ToolConfig>>( \
38  fhicl::Name{name}); \
39  }
40 
41 // Produce the injected functions
42 #define DEFINE_ART_CLASS_TOOL(tool) \
43  EXTERN_C_FUNC_DECLARE_START \
44  CET_PROVIDE_FILE_PATH() \
45  FHICL_PROVIDE_ALLOWED_CONFIGURATION(tool) \
46  std::string toolType() { return "class"; } \
47  std::enable_if_t<std::is_class<tool>::value, std::unique_ptr<tool>> \
48  makeTool(fhicl::ParameterSet const& pset) \
49  { \
50  return std::make_unique<tool>(pset); \
51  } \
52  EXTERN_C_FUNC_DECLARE_END
53 
54 #define DEFINE_ART_FUNCTION_TOOL(tool, type) \
55  EXTERN_C_FUNC_DECLARE_START \
56  CET_PROVIDE_FILE_PATH() \
57  ART_PROVIDE_ALLOWED_CONFIGURATION_FUNCTION_TOOL() \
58  std::string toolType() { return type; } \
59  auto toolFunction = tool; \
60  EXTERN_C_FUNC_DECLARE_END
61 
62 #endif /* art_Utilities_ToolMacros_h */
63 
64 // Local Variables:
65 // mode: c++
66 // End:
ChannelGroupService::Name Name