ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
G4Atlas
G4AtlasTools
G4AtlasTools
ActionToolBase.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef G4ATLASTOOLS__G4UA__ACTIONTOOLBASE_H
6
#define G4ATLASTOOLS__G4UA__ACTIONTOOLBASE_H
7
8
// System includes
9
#include <memory>
10
11
// Framework includes
12
#include "
AthenaBaseComps/AthAlgTool.h
"
13
14
// Local includes
15
#include "
ThreadActionHolder.h
"
16
17
namespace
G4UA
18
{
19
33
template
<
class
ActionType>
34
class
ActionToolBase
:
public
AthAlgTool
35
{
36
37
public
:
38
40
ActionToolBase
(
const
std::string&
type
,
const
std::string& name,
41
const
IInterface* parent)
42
:
AthAlgTool
(
type
, name, parent)
43
{}
44
48
ActionType*
getAction
()
49
{
50
ActionType* action =
m_actions
.get();
51
if
(!action){
52
auto
uniqueAction =
makeAction
();
53
action = uniqueAction.get();
54
m_actions
.set( std::move(uniqueAction) );
55
}
56
return
action;
57
}
58
59
protected
:
60
63
virtual
std::unique_ptr<ActionType>
makeAction
() = 0;
64
66
const
ThreadActionHolder<ActionType>
&
actions
()
67
{
return
m_actions
; }
68
69
private
:
70
72
ThreadActionHolder<ActionType>
m_actions
;
73
74
};
// class ActionToolBase
75
76
86
template
<
class
ActionType>
87
class
ActionToolBaseReport
:
public
ActionToolBase
<ActionType>
88
{
89
90
public
:
91
93
ActionToolBaseReport
(
const
std::string&
type
,
const
std::string& name,
94
const
IInterface* parent)
95
:
ActionToolBase
<ActionType>(
type
, name, parent)
96
{}
97
98
protected
:
99
103
void
mergeReports
(){
104
for
(
auto
tidAction : this->
actions
()) {
105
auto
& rep = tidAction.second->getReport();
106
m_report
.merge(rep);
107
}
108
}
109
111
typename
ActionType::Report
m_report
;
112
113
};
// class ActionToolBaseReport
114
115
}
// namespace G4UA
116
117
#endif
AthAlgTool.h
ThreadActionHolder.h
AthAlgTool::AthAlgTool
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Definition
AthAlgTool.cxx:16
G4UA::ActionToolBaseReport::m_report
ActionType::Report m_report
This type must be defined in the concrete tool subclass.
Definition
ActionToolBase.h:111
G4UA::ActionToolBaseReport::ActionToolBaseReport
ActionToolBaseReport(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
Definition
ActionToolBase.h:93
G4UA::ActionToolBaseReport::mergeReports
void mergeReports()
Loop over per-thread actions and merge the results.
Definition
ActionToolBase.h:103
G4UA::ActionToolBase::m_actions
ThreadActionHolder< ActionType > m_actions
Thread-local storage of my user actions.
Definition
ActionToolBase.h:72
G4UA::ActionToolBase::makeAction
virtual std::unique_ptr< ActionType > makeAction()=0
Abstract method to create a custom action on demand.
G4UA::ActionToolBase::ActionToolBase
ActionToolBase(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
Definition
ActionToolBase.h:40
G4UA::ActionToolBase::actions
const ThreadActionHolder< ActionType > & actions()
Retrieve const-ref to the action holder.
Definition
ActionToolBase.h:66
G4UA::ActionToolBase::getAction
ActionType * getAction()
Helper method for retrieving an action interface.
Definition
ActionToolBase.h:48
G4UA::ThreadActionHolder
A thread-local storage wrapper for the user actions.
Definition
ThreadActionHolder.h:31
G4UA
for nSW
Definition
CalibrationDefaultProcessing.h:19
type
Generated on
for ATLAS Offline Software by
1.17.0