NestedFunctionInClassTool.h
Go to the documentation of this file.
1 #ifndef art_test_Utilities_tools_NestedFunctionInClassTool_h
2 #define art_test_Utilities_tools_NestedFunctionInClassTool_h
3 
6 
7 namespace arttest {
9  public:
11  : pset_{ps}
12  {}
13 
14  int
15  callThroughToAddOne(int const i)
16  {
17  // It is a bad idea to call make_tool for each function call, as
18  // is the case here. It would be much better to create a data
19  // member of type "std::function<int(int)>" that is initialized
20  // in the c'tor. However, to demonstrate that a tool CAN be
21  // constructed within a function call, we leave it as is. See
22  // the c'tor of AddIntsProducer for an example of better code
23  // practice.
24  auto addOne = art::make_tool<int(int)>(
25  pset_.get<fhicl::ParameterSet>("addOneTool"), "addOne");
26  return addOne(i);
27  }
28 
29  private:
31  };
32 } // namespace arttest
33 
34 #endif /* art_test_Utilities_tools_NestedFunctionInClassTool_h */
35 
36 // Local variables:
37 // mode: c++
38 // End:
int addOne(int const i)
Definition: FunctionTool.cc:5
NestedFunctionInClassTool(fhicl::ParameterSet const &ps)
T get(std::string const &key) const
Definition: ParameterSet.h:271
static constexpr double ps
Definition: Units.h:99