14 #ifndef DD4HEP_DDG4_GEANT4ACTIONPHASE_H
15 #define DD4HEP_DDG4_GEANT4ACTIONPHASE_H
28 namespace Simulation {
71 typedef std::vector<std::pair<Geant4Action*, Callback> >
Members;
81 const std::type_info& arg_type1,
const std::type_info& arg_type2);
89 const std::type_info*
const *
argTypes()
const {
99 template <
typename TYPE,
typename IF_TYPE,
typename A0,
typename R>
100 bool add(TYPE* member, R (IF_TYPE::*callback)(A0 arg)) {
102 if (dynamic_cast<IF_TYPE*>(member)) {
103 return add(member,
Callback(member).make(callback));
108 template <
typename TYPE,
typename IF_TYPE,
typename A0,
typename A1,
typename R>
109 bool add(TYPE* member, R (IF_TYPE::*callback)(A0 arg0, A1 arg1)) {
112 if (dynamic_cast<IF_TYPE*>(member)) {
113 return add(member,
Callback(member).make(callback));
118 template <
typename TYPE,
typename IF_TYPE,
typename A0,
typename A1,
typename A2,
typename R>
119 bool add(TYPE* member, R (IF_TYPE::*callback)(A0 arg0, A1 arg1)) {
123 if (dynamic_cast<IF_TYPE*>(member)) {
125 return add(member,
Callback(member).make(callback));
130 template <
typename TYPE,
typename PMF>
bool remove(TYPE* member) {
131 return remove(member,
Callback(member));
134 template <
typename TYPE,
typename PMF>
bool remove(TYPE* member, PMF callback) {
136 return remove(member,cb.
make(callback));
140 template <
typename A0>
void call(A0 a0);
141 template <
typename A0,
typename A1>
void call(A0 a0, A1 a1);
142 template <
typename A0,
typename A1,
typename A2>
void call(A0 a0, A1 a1, A2 a2);
148 #endif // DD4HEP_DDG4_GEANT4ACTIONPHASE_H
const std::type_info * m_argTypes[3]
Type information of the argument type of the callback.
const std::type_info *const * argTypes() const
Type of the first phase callback-argument.
Geant4PhaseAction(Geant4Context *context, const std::string &name)
Standard constructor.
Generic action for Geant4 phases.
Members m_members
Phase members (actions) being called for a particular phase.
void execute(void *argument)
Execute all members in the phase context.
Geant4Context * context() const
Access the context.
const std::string & name() const
Access name of the action.
virtual Callback callback()
Create bound callback to operator()()
bool add(TYPE *member, R(IF_TYPE::*callback)(A0 arg0, A1 arg1))
Add a new member to the phase.
virtual ~Geant4ActionPhase()
Default destructor.
const Callback & make(R(T::*pmf)())
Callback setup function for Callbacks with member functions with explicit return type taking no argum...
Definition of the generic callback structure for member functions.
bool add(TYPE *member, R(IF_TYPE::*callback)(A0 arg))
Add a new member to the phase.
void call()
Create action to execute phase members.
const Members & members() const
Access phase members.
Geant4ActionPhase(Geant4Context *context, const std::string &name, const std::type_info &arg_type0, const std::type_info &arg_type1, const std::type_info &arg_type2)
Standard constructor.
virtual void operator()()
Callback to generate primary particles.
virtual ~Geant4PhaseAction()
Default destructor.
Generic context to extend user, run and event information.
Action phase definition. Client callback at various stage of the simulation processing.
bool add(TYPE *member, R(IF_TYPE::*callback)(A0 arg0, A1 arg1))
Add a new member to the phase.
void typeinfoCheck(const std::type_info &typ1, const std::type_info &typ2, const std::string &text="")
Check type infos for equivalence (dynamic casts) using ABI information.
virtual bool add(Geant4Action *action, Callback callback)
Add a new member to the phase.
Default base class for all Geant 4 actions and derivates thereof.
std::vector< std::pair< Geant4Action *, Callback > > Members