thepeg
is hosted by
Hepforge
,
IPPP Durham
ThePEG
2.3.0
Handlers
HandlerGroup.h
1
// -*- C++ -*-
2
//
3
// HandlerGroup.h is a part of ThePEG - Toolkit for HEP Event Generation
4
// Copyright (C) 1999-2019 Leif Lonnblad
5
//
6
// ThePEG is licenced under version 3 of the GPL, see COPYING for details.
7
// Please respect the MCnet academic guidelines, see GUIDELINES for details.
8
//
9
#ifndef ThePEG_HandlerGroup_H
10
#define ThePEG_HandlerGroup_H
11
// This is the declaration of the HandlerGroup class.
12
13
#include "
ThePEG/Config/ThePEG.h
"
14
// #include "HandlerGroup.fh"
15
// #include "HandlerGroup.xh"
16
17
namespace
ThePEG
{
18
44
class
HandlerGroupBase
{
45
46
public
:
47
49
typedef
pair<StepHdlPtr, HintPtr>
StepWithHint
;
50
52
typedef
vector<StepHdlPtr>
StepVector
;
53
55
typedef
vector<StepWithHint>
StepHintVector
;
56
58
typedef
deque<HintPtr>
HintVector
;
59
60
public
:
61
65
HandlerGroupBase
();
66
70
virtual
~HandlerGroupBase
();
71
75
bool
empty
()
const
{
return
isEmpty
; }
76
82
void
init
(
const
HandlerGroupBase
& ext) {
83
clear
();
84
refillDefaults
(ext);
85
}
86
90
StepWithHint
next
();
91
98
void
addPreHandler
(
tStepHdlPtr
sh,
tHintPtr
hint,
99
const
HandlerGroupBase
& ext);
100
107
void
addPostHandler
(
tStepHdlPtr
sh,
tHintPtr
hint,
108
const
HandlerGroupBase
&);
109
115
void
addHint
(
tHintPtr
hint,
const
HandlerGroupBase
& ext);
116
120
StepVector
&
preHandlers
() {
return
theDefaultPreHandlers
; }
121
125
const
StepVector
&
preHandlers
()
const
{
return
theDefaultPreHandlers
; }
126
130
virtual
tStepHdlPtr
defaultHandler
()
const
= 0;
131
135
StepVector
&
postHandlers
() {
return
theDefaultPostHandlers
; }
136
140
const
StepVector
&
postHandlers
()
const
{
return
theDefaultPostHandlers
; }
141
145
virtual
tStepHdlPtr
handler
()
const
= 0;
146
150
virtual
void
setHandler
() = 0;
151
156
virtual
bool
setHandler
(
tStepHdlPtr
,
const
HandlerGroupBase
& ext) = 0;
157
162
virtual
void
refillDefaultHandler
(
tStepHdlPtr
) = 0;
163
168
void
refillDefaults
(
const
HandlerGroupBase
&);
169
173
virtual
void
clear
();
174
178
virtual
string
handlerClass
()
const
= 0;
179
183
void
interfaceSetPrehandler
(
StepHdlPtr
p,
int
i);
184
188
void
interfaceInsertPrehandler
(
StepHdlPtr
p,
int
i);
189
193
void
interfaceErasePrehandler
(
int
i);
194
198
vector<StepHdlPtr>
interfaceGetPrehandlers
()
const
;
199
203
void
interfaceSetPosthandler
(
StepHdlPtr
p,
int
i);
204
208
void
interfaceInsertPosthandler
(
StepHdlPtr
p,
int
i);
209
213
void
interfaceErasePosthandler
(
int
i);
214
218
vector<StepHdlPtr>
interfaceGetPosthandlers
()
const
;
219
223
virtual
void
write
(
PersistentOStream
&)
const
;
224
228
virtual
void
read
(
PersistentIStream
&);
229
230
protected
:
231
235
HandlerGroupBase
(
const
HandlerGroupBase
&);
236
240
bool
isEmpty
;
241
242
private
:
243
248
void
checkInsert
(
StepHintVector
& current,
const
StepVector
& def);
249
250
protected
:
251
255
StepVector
theDefaultPreHandlers
;
256
260
StepVector
theDefaultPostHandlers
;
261
265
StepHintVector
thePreHandlers
;
266
270
HintVector
theHints
;
271
275
StepHintVector
thePostHandlers
;
276
277
private
:
278
282
HandlerGroupBase
&
operator=
(
const
HandlerGroupBase
&) =
delete
;
283
284
};
285
320
template
<
typename
HDLR>
321
class
HandlerGroup
:
public
HandlerGroupBase
{
322
323
public
:
324
326
typedef
typename
Ptr<HDLR>::pointer
HdlPtr
;
327
329
typedef
typename
Ptr<HDLR>::transient_pointer
tHdlPtr
;
330
331
public
:
332
336
virtual
~HandlerGroup
();
337
342
virtual
bool
setHandler
(
tStepHdlPtr
,
const
HandlerGroupBase
& ext);
343
347
virtual
void
setHandler
() {
theHandler
=
HdlPtr
(); }
348
352
virtual
tStepHdlPtr
handler
()
const
{
353
return
dynamic_ptr_cast<tStepHdlPtr>(
theHandler
);
354
}
355
359
virtual
tStepHdlPtr
defaultHandler
()
const
{
360
return
dynamic_ptr_cast<tStepHdlPtr>(
theDefaultHandler
);
361
}
362
367
virtual
void
refillDefaultHandler
(
tStepHdlPtr
);
368
372
virtual
void
clear
();
373
377
virtual
string
handlerClass
()
const
;
378
382
void
interfaceSetHandler
(
HdlPtr
);
383
387
HdlPtr
interfaceGetHandler
()
const
;
388
392
virtual
void
write
(
PersistentOStream
& os)
const
{
393
os <<
theDefaultHandler
<<
theHandler
;
394
HandlerGroupBase::write
(os);
395
}
396
400
virtual
void
read
(
PersistentIStream
& is) {
401
is >>
theDefaultHandler
>>
theHandler
;
402
HandlerGroupBase::read
(is);
403
}
404
405
private
:
406
407
411
HdlPtr
theDefaultHandler
;
412
416
HdlPtr
theHandler
;
417
418
private
:
419
423
HandlerGroup<HDLR>
&
operator=
(
const
HandlerGroup<HDLR>
&) =
delete
;
424
425
};
426
428
namespace
Group {
429
433
enum
Handler
{
434
subproc
,
435
cascade
,
436
multi
,
437
hadron
,
438
decay
439
};
440
442
enum
Level
{
443
before
,
444
main
,
445
after
446
};
447
}
448
450
template
<
typename
HDLR>
451
inline
PersistentOStream
&
operator<<
(
PersistentOStream
& os,
452
const
HandlerGroup<HDLR>
& hg) {
453
hg.
write
(os);
454
return
os;
455
}
456
458
template
<
typename
HDLR>
459
inline
PersistentIStream
&
operator>>
(
PersistentIStream
& is,
460
HandlerGroup<HDLR>
& hg) {
461
hg.
read
(is);
462
return
is;
463
}
464
465
}
466
468
#define ThePEG_DECLARE_PREPOST_GROUP(HandlerClass,prepost) \
469
\
470
void interfaceSet##prepost##HandlerClass(StepHdlPtr, int); \
471
\
472
void interfaceInsert##prepost##HandlerClass(StepHdlPtr, int); \
473
\
474
void interfaceErase##prepost##HandlerClass(int); \
475
\
476
vector<StepHdlPtr> interfaceGet##prepost##HandlerClass() const
477
479
#define ThePEG_DECLARE_GROUPINTERFACE(HandlerClass,ptr) \
480
ThePEG_DECLARE_PREPOST_GROUP(HandlerClass,Pre); \
481
\
482
void interfaceSet##HandlerClass(ptr); \
483
\
484
ptr interfaceGet##HandlerClass() const; \
485
ThePEG_DECLARE_PREPOST_GROUP(HandlerClass,Post)
486
488
#define ThePEG_IMPLEMENT_PREPOST_GROUP(ThisClass,HandlerClass,member,pp) \
489
void ThisClass::interfaceSet##pp##HandlerClass(StepHdlPtr p , int i) { \
490
member.interfaceSet##pp##handler(p,i); \
491
} \
492
void ThisClass::interfaceInsert##pp##HandlerClass(StepHdlPtr p, int i) { \
493
member.interfaceInsert##pp##handler(p,i); \
494
} \
495
void ThisClass::interfaceErase##pp##HandlerClass(int i) { \
496
member.interfaceErase##pp##handler(i); \
497
} \
498
vector<StepHdlPtr> ThisClass::interfaceGet##pp##HandlerClass() const { \
499
return member.interfaceGet##pp##handlers(); \
500
}
501
503
#define ThePEG_IMPLEMENT_GROUPINTERFACE(ThisClass,HandlerClass,member,ptr) \
504
ThePEG_IMPLEMENT_PREPOST_GROUP(ThisClass,HandlerClass,member,Pre) \
505
void ThisClass::interfaceSet##HandlerClass(ptr p) { \
506
member.interfaceSetHandler(p); \
507
} \
508
ptr ThisClass::interfaceGet##HandlerClass() const { \
509
return member.interfaceGetHandler(); \
510
} \
511
ThePEG_IMPLEMENT_PREPOST_GROUP(ThisClass,HandlerClass,member,Post) \
512
514
#define ThePEG_DECLARE_PREPOST_OBJECTS(ThisClass,HandlerClass,pp,ba) \
515
static RefVector<ThisClass,StepHandler> interface##pp##HandlerClass \
516
(#pp #HandlerClass "s"
, \
517
"A list of handlers to be called " #ba " the " #HandlerClass ". " \
518
"If handler objects are specified in a EventHandler and " \
519
"the SubProcessHandler chosen in a given collision also specifies some, " \
520
"the latter will caled first.", \
521
0, 0, false, false, true, false, \
522
&ThisClass::interfaceSet##pp##HandlerClass, \
523
&ThisClass::interfaceInsert##pp##HandlerClass, \
524
&ThisClass::interfaceErase##pp##HandlerClass, \
525
&ThisClass::interfaceGet##pp##HandlerClass)
526
528
#define ThePEG_DECLARE_GROUPINTERFACE_OBJECTS(ThisClass,HandlerClass) \
529
ThePEG_DECLARE_PREPOST_OBJECTS(ThisClass,HandlerClass,Pre, before); \
530
static Reference<ThisClass,HandlerClass> interface ## HandlerClass \
531
(#HandlerClass, \
532
"The "
#HandlerClass " object used in this " #ThisClass ". " \
533
"If a " #HandlerClass " object is specified in a EventHandler and " \
534
"the SubProcessHandler chosen in a given collision also specifies one," \
535
"the latter will be used.", \
536
0, false, false, true, true, \
537
&ThisClass::interfaceSet ## HandlerClass, \
538
&ThisClass::interfaceGet ## HandlerClass); \
539
ThePEG_DECLARE_PREPOST_OBJECTS(ThisClass,HandlerClass,Post, after)
540
541
#ifndef ThePEG_TEMPLATES_IN_CC_FILE
542
#include "HandlerGroup.tcc"
543
#endif
544
545
#endif
/* ThePEG_HandlerGroup_H */
ThePEG.h
This is the main config header file for ThePEG.
ThePEG::HandlerGroupBase
HandlerGroupBase is the base class for the templated HandlerGroup utility class to manage a group of ...
Definition:
HandlerGroup.h:44
ThePEG::HandlerGroupBase::interfaceErasePrehandler
void interfaceErasePrehandler(int i)
Utility function used for the interface.
ThePEG::HandlerGroupBase::refillDefaults
void refillDefaults(const HandlerGroupBase &)
Fill main, pre- and post- handlers with the default ones.
ThePEG::HandlerGroupBase::postHandlers
StepVector & postHandlers()
Return a reference to the list of default post-handlers.
Definition:
HandlerGroup.h:135
ThePEG::HandlerGroupBase::theDefaultPreHandlers
StepVector theDefaultPreHandlers
The default pre-handlers with hints.
Definition:
HandlerGroup.h:255
ThePEG::HandlerGroupBase::read
virtual void read(PersistentIStream &)
Read from persistent streams.
ThePEG::HandlerGroupBase::addHint
void addHint(tHintPtr hint, const HandlerGroupBase &ext)
Add a hint to the currently selected main handler.
ThePEG::HandlerGroupBase::next
StepWithHint next()
Return the next step;.
ThePEG::HandlerGroupBase::isEmpty
bool isEmpty
True if the current handlers are empty.
Definition:
HandlerGroup.h:240
ThePEG::HandlerGroupBase::StepVector
vector< StepHdlPtr > StepVector
A vector of StepHandler objects.
Definition:
HandlerGroup.h:52
ThePEG::HandlerGroupBase::interfaceSetPrehandler
void interfaceSetPrehandler(StepHdlPtr p, int i)
Utility function used for the interface.
ThePEG::HandlerGroupBase::init
void init(const HandlerGroupBase &ext)
Initialize, taking the default StepHandlers as the current ones, possibly overridden by the default o...
Definition:
HandlerGroup.h:82
ThePEG::HandlerGroupBase::thePostHandlers
StepHintVector thePostHandlers
The current post-handlers with hints.
Definition:
HandlerGroup.h:275
ThePEG::HandlerGroupBase::interfaceSetPosthandler
void interfaceSetPosthandler(StepHdlPtr p, int i)
Utility function used for the interface.
ThePEG::HandlerGroupBase::clear
virtual void clear()
Clear all current handlers, but don't touch the default ones.
ThePEG::HandlerGroupBase::handler
virtual tStepHdlPtr handler() const =0
Return a pointer to the current main handler.
ThePEG::HandlerGroupBase::checkInsert
void checkInsert(StepHintVector ¤t, const StepVector &def)
Add handlers from the def vector to the current, supplying them with default hints.
ThePEG::HandlerGroupBase::HandlerGroupBase
HandlerGroupBase(const HandlerGroupBase &)
The copy constructor is only used via subclasses.
ThePEG::HandlerGroupBase::HintVector
deque< HintPtr > HintVector
A vector of Hint objects.
Definition:
HandlerGroup.h:58
ThePEG::HandlerGroupBase::setHandler
virtual void setHandler()=0
Unset the current main handler.
ThePEG::HandlerGroupBase::empty
bool empty() const
Returns true if current selections in this group is empty.
Definition:
HandlerGroup.h:75
ThePEG::HandlerGroupBase::setHandler
virtual bool setHandler(tStepHdlPtr, const HandlerGroupBase &ext)=0
Set the current main handler, but also refill the current pre- and post- handlers with the defaults f...
ThePEG::HandlerGroupBase::preHandlers
StepVector & preHandlers()
Return a reference to the list of default pre-handlers.
Definition:
HandlerGroup.h:120
ThePEG::HandlerGroupBase::preHandlers
const StepVector & preHandlers() const
Return a reference to the list of default pre-handlers.
Definition:
HandlerGroup.h:125
ThePEG::HandlerGroupBase::theHints
HintVector theHints
The current hints for the main handler.
Definition:
HandlerGroup.h:270
ThePEG::HandlerGroupBase::write
virtual void write(PersistentOStream &) const
Write to persistent streams.
ThePEG::HandlerGroupBase::postHandlers
const StepVector & postHandlers() const
Return a reference to the list of default post-handlers.
Definition:
HandlerGroup.h:140
ThePEG::HandlerGroupBase::StepHintVector
vector< StepWithHint > StepHintVector
A vector of StepHandler objects associated with Hint objects.
Definition:
HandlerGroup.h:55
ThePEG::HandlerGroupBase::addPreHandler
void addPreHandler(tStepHdlPtr sh, tHintPtr hint, const HandlerGroupBase &ext)
Add a step handler, sh to the current list of pre-handlers.
ThePEG::HandlerGroupBase::HandlerGroupBase
HandlerGroupBase()
Default constructor.
ThePEG::HandlerGroupBase::interfaceInsertPosthandler
void interfaceInsertPosthandler(StepHdlPtr p, int i)
Utility function used for the interface.
ThePEG::HandlerGroupBase::handlerClass
virtual string handlerClass() const =0
Return the base class name of the main handler type.
ThePEG::HandlerGroupBase::operator=
HandlerGroupBase & operator=(const HandlerGroupBase &)=delete
Assignment is private.
ThePEG::HandlerGroupBase::interfaceGetPrehandlers
vector< StepHdlPtr > interfaceGetPrehandlers() const
Utility function used for the interface.
ThePEG::HandlerGroupBase::thePreHandlers
StepHintVector thePreHandlers
The current pre-handlers with hints.
Definition:
HandlerGroup.h:265
ThePEG::HandlerGroupBase::defaultHandler
virtual tStepHdlPtr defaultHandler() const =0
Return a pointer to the default main handler.
ThePEG::HandlerGroupBase::refillDefaultHandler
virtual void refillDefaultHandler(tStepHdlPtr)=0
Set the current main handler.
ThePEG::HandlerGroupBase::interfaceInsertPrehandler
void interfaceInsertPrehandler(StepHdlPtr p, int i)
Utility function used for the interface.
ThePEG::HandlerGroupBase::StepWithHint
pair< StepHdlPtr, HintPtr > StepWithHint
Associate a StepHandler with a Hint object.
Definition:
HandlerGroup.h:49
ThePEG::HandlerGroupBase::interfaceErasePosthandler
void interfaceErasePosthandler(int i)
Utility function used for the interface.
ThePEG::HandlerGroupBase::addPostHandler
void addPostHandler(tStepHdlPtr sh, tHintPtr hint, const HandlerGroupBase &)
Add a step handler, sh, to the current list of post-handlers.
ThePEG::HandlerGroupBase::~HandlerGroupBase
virtual ~HandlerGroupBase()
Destructor.
ThePEG::HandlerGroupBase::interfaceGetPosthandlers
vector< StepHdlPtr > interfaceGetPosthandlers() const
Utility function used for the interface.
ThePEG::HandlerGroupBase::theDefaultPostHandlers
StepVector theDefaultPostHandlers
The default post-handlers with hints.
Definition:
HandlerGroup.h:260
ThePEG::HandlerGroup
HandlerGroup is a templated utility class to manage a group of StepHandlers.
Definition:
HandlerGroup.h:321
ThePEG::HandlerGroup::theHandler
HdlPtr theHandler
The current main handler.
Definition:
HandlerGroup.h:416
ThePEG::HandlerGroup::read
virtual void read(PersistentIStream &is)
Read from persistent streams.
Definition:
HandlerGroup.h:400
ThePEG::HandlerGroup::defaultHandler
virtual tStepHdlPtr defaultHandler() const
Return a pointer to the default main handler.
Definition:
HandlerGroup.h:359
ThePEG::HandlerGroup::interfaceGetHandler
HdlPtr interfaceGetHandler() const
Utility function used for the interface.
ThePEG::HandlerGroup::handler
virtual tStepHdlPtr handler() const
Return a pointer to the current main handler.
Definition:
HandlerGroup.h:352
ThePEG::HandlerGroup::setHandler
virtual bool setHandler(tStepHdlPtr, const HandlerGroupBase &ext)
Set the current main handler.
ThePEG::HandlerGroup::HdlPtr
Ptr< HDLR >::pointer HdlPtr
A pointer to the template argument class.
Definition:
HandlerGroup.h:326
ThePEG::HandlerGroup::setHandler
virtual void setHandler()
Unset the current main handler.
Definition:
HandlerGroup.h:347
ThePEG::HandlerGroup::tHdlPtr
Ptr< HDLR >::transient_pointer tHdlPtr
A transient pointer to the template argument class.
Definition:
HandlerGroup.h:329
ThePEG::HandlerGroup::clear
virtual void clear()
Clear all current handlers, but don't touch the default ones.
ThePEG::HandlerGroup::~HandlerGroup
virtual ~HandlerGroup()
Destructor.
ThePEG::HandlerGroup::operator=
HandlerGroup< HDLR > & operator=(const HandlerGroup< HDLR > &)=delete
Assignment is private.
ThePEG::HandlerGroup::theDefaultHandler
HdlPtr theDefaultHandler
The default main handler.
Definition:
HandlerGroup.h:411
ThePEG::HandlerGroup::handlerClass
virtual string handlerClass() const
Return the base class name of the main handler type.
ThePEG::HandlerGroup::interfaceSetHandler
void interfaceSetHandler(HdlPtr)
Utility function used for the interface.
ThePEG::HandlerGroup::refillDefaultHandler
virtual void refillDefaultHandler(tStepHdlPtr)
Set the current main handler.
ThePEG::HandlerGroup::write
virtual void write(PersistentOStream &os) const
Write to persistent streams.
Definition:
HandlerGroup.h:392
ThePEG::PersistentIStream
PersistentIStream is used to read persistent objects from a stream where they were previously written...
Definition:
PersistentIStream.h:48
ThePEG::PersistentOStream
PersistentOStream is used to write objects persistently to a stream from which they can be read in ag...
Definition:
PersistentOStream.h:51
ThePEG::Pointer::RCPtr
RCPtr is a reference counted (smart) pointer.
Definition:
RCPtr.h:60
ThePEG::Pointer::TransientRCPtr
TransientRCPtr is a simple wrapper around a bare pointer which can be assigned to and from an RCPtr a...
Definition:
RCPtr.h:519
ThePEG::Group::Handler
Handler
Enumeration for the type of HandlerGroups.
Definition:
HandlerGroup.h:433
ThePEG::Group::multi
@ multi
The MultipleInteractionHandler group.
Definition:
HandlerGroup.h:436
ThePEG::Group::decay
@ decay
The DecayHandler group.
Definition:
HandlerGroup.h:438
ThePEG::Group::hadron
@ hadron
The HadronizationHandler group.
Definition:
HandlerGroup.h:437
ThePEG::Group::cascade
@ cascade
The CascadeHandler group.
Definition:
HandlerGroup.h:435
ThePEG::Group::subproc
@ subproc
The sub-process group.
Definition:
HandlerGroup.h:434
ThePEG::Group::Level
Level
Enumeration for the type of step handler.
Definition:
HandlerGroup.h:442
ThePEG::Group::after
@ after
A post-handler.
Definition:
HandlerGroup.h:445
ThePEG::Group::main
@ main
The mainhandler.
Definition:
HandlerGroup.h:444
ThePEG::Group::before
@ before
A pre-handler.
Definition:
HandlerGroup.h:443
ThePEG
This is the main namespace within which all identifiers in ThePEG are declared.
Definition:
FactoryBase.h:28
ThePEG::operator>>
vector< T > & operator>>(vector< T > &tv, U &u)
Overload the right shift operator for vector to pop objects from a vector.
Definition:
Containers.h:192
ThePEG::operator<<
vector< T > & operator<<(vector< T > &tv, const U &u)
Overload the left shift operator for vector to push_back objects to a vector.
Definition:
Containers.h:179
Generated on Thu Jun 20 2024 14:47:00 for ThePEG by
1.9.6