Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
art
art
test
Utilities
tools
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
4
#include "
art/Utilities/make_tool.h
"
5
#include "
fhiclcpp/ParameterSet.h
"
6
7
namespace
arttest
{
8
class
NestedFunctionInClassTool
{
9
public
:
10
explicit
NestedFunctionInClassTool
(
fhicl::ParameterSet
const
&
ps
)
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
:
30
fhicl::ParameterSet
pset_
;
31
};
32
}
// namespace arttest
33
34
#endif
/* art_test_Utilities_tools_NestedFunctionInClassTool_h */
35
36
// Local variables:
37
// mode: c++
38
// End:
arttest::NestedFunctionInClassTool::pset_
fhicl::ParameterSet pset_
Definition:
NestedFunctionInClassTool.h:30
arttest::NestedFunctionInClassTool
Definition:
NestedFunctionInClassTool.h:8
arttest::addOne
int addOne(int const i)
Definition:
FunctionTool.cc:5
ParameterSet.h
arttest::NestedFunctionInClassTool::NestedFunctionInClassTool
NestedFunctionInClassTool(fhicl::ParameterSet const &ps)
Definition:
NestedFunctionInClassTool.h:10
fhicl::ParameterSet::get
T get(std::string const &key) const
Definition:
ParameterSet.h:271
arttest
Definition:
GroupSelector_t.h:4
genie::units::ps
static constexpr double ps
Definition:
Units.h:99
make_tool.h
arttest::NestedFunctionInClassTool::callThroughToAddOne
int callThroughToAddOne(int const i)
Definition:
NestedFunctionInClassTool.h:15
fhicl::ParameterSet
Definition:
ParameterSet.h:36
Generated by
1.8.11