LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
ToolMacros.h
Go to the documentation of this file.
1 #ifndef art_Utilities_ToolMacros_h
2 #define art_Utilities_ToolMacros_h
3 
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 //
15 
16 #include "cetlib/PluginTypeDeducer.h"
17 #include "cetlib/ProvideFilePathMacro.h"
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 {
28  namespace detail {
29 
30  struct ToolConfig {
32  };
33  }
34 }
35 
36 #define ART_PROVIDE_ALLOWED_CONFIGURATION_FUNCTION_TOOL() \
37  std::unique_ptr<fhicl::ConfigurationTable> allowed_configuration( \
38  std::string const& name) \
39  { \
40  return std::make_unique<fhicl::WrappedTable<art::detail::ToolConfig>>( \
41  fhicl::Name{name}); \
42  }
43 
44 // Produce the injected functions
45 #define DEFINE_ART_CLASS_TOOL(tool) \
46  EXTERN_C_FUNC_DECLARE_START \
47  CET_PROVIDE_FILE_PATH() \
48  FHICL_PROVIDE_ALLOWED_CONFIGURATION(tool) \
49  std::string toolType() { return "class"; } \
50  std::enable_if_t<std::is_class<tool>::value, std::unique_ptr<tool>> \
51  makeTool(fhicl::ParameterSet const& pset) \
52  { \
53  return std::make_unique<tool>(pset); \
54  } \
55  EXTERN_C_FUNC_DECLARE_END
56 
57 #define DEFINE_ART_FUNCTION_TOOL(tool, type) \
58  EXTERN_C_FUNC_DECLARE_START \
59  CET_PROVIDE_FILE_PATH() \
60  ART_PROVIDE_ALLOWED_CONFIGURATION_FUNCTION_TOOL() \
61  std::string toolType() { return type; } \
62  auto toolFunction = tool; \
63  EXTERN_C_FUNC_DECLARE_END
64 
65 #endif /* art_Utilities_ToolMacros_h */
66 
67 // Local Variables:
68 // mode: c++
69 // End:
HLT enums.