thepeg
is hosted by
Hepforge
,
IPPP Durham
ThePEG
2.3.0
Repository
CurrentGenerator.h
1
// -*- C++ -*-
2
//
3
// CurrentGenerator.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_CurrentGenerator_H
10
#define ThePEG_CurrentGenerator_H
11
// This is the declaration of the CurrentGenerator class.
12
13
#include "ThePEG/Repository/EventGenerator.h"
14
#include "CurrentGenerator.fh"
15
16
namespace
ThePEG
{
17
33
class
CurrentGenerator
{
34
35
public
:
36
40
CurrentGenerator
() :
generatorPushed
(false) {}
41
45
CurrentGenerator
(
const
CurrentGenerator
&)
46
:
generatorPushed
(false) {}
47
52
CurrentGenerator
(
const
EGPtr
& eg) :
generatorPushed
(false) {
53
if
( eg ) {
54
theGeneratorStack
.push_back(eg);
55
generatorPushed
=
true
;
56
}
57
}
58
63
~CurrentGenerator
() {
64
if
(
generatorPushed
)
theGeneratorStack
.pop_back();
65
}
66
67
public
:
68
73
static
bool
isVoid
() {
74
return
theGeneratorStack
.empty() || !(
theGeneratorStack
.back());
75
}
76
80
static
EventGenerator
&
current
() {
81
return
*
theGeneratorStack
.back();
82
}
83
87
EventGenerator
&
operator*
()
const
{
88
return
*
theGeneratorStack
.back();
89
}
90
94
EventGenerator
*
operator->
()
const
{
95
return
theGeneratorStack
.back();
96
}
97
101
static
EventGenerator
*
ptr
() {
102
return
theGeneratorStack
.back();
103
}
104
108
operator
bool()
const
{
109
return
ptr
();
110
}
111
115
bool
operator!
()
const
{
116
return
!
ptr
();
117
}
118
123
static
tSMPtr
standardModel
() {
124
return
current
().
standardModel
();
125
}
126
131
static
tStrategyPtr
strategy
() {
return
current
().
strategy
(); }
132
139
static
ostream &
out
() {
return
current
().
out
(); }
140
147
static
ostream &
log
() {
return
current
().
log
(); }
148
155
static
ostream &
ref
() {
return
current
().
ref
(); }
156
162
template
<
typename
T>
163
static
typename
Ptr<T>::pointer
getPtr
(
const
T & t) {
164
return
current
().
getPtr
(t);
165
}
166
172
static
IBPtr
getPointer
(
string
name) {
173
return
current
().
getPointer
(name);
174
}
175
181
template
<
typename
T>
182
static
typename
Ptr<T>::pointer
getObject
(
string
name) {
183
return
current
().
getObject
<T>(name);
184
}
185
190
template
<
typename
T>
191
static
typename
Ptr<T>::pointer
getDefault
() {
192
return
current
().
getDefault
<T>();
193
}
194
195
public
:
196
201
class
Redirect
{
202
203
public
:
204
213
Redirect
(ostream & os,
bool
internal =
false
)
214
:
theStream
(&os),
theBuffer
(os.rdbuf()) {
215
if
( internal )
theStream
->rdbuf(
intStream
.rdbuf());
216
else
if
( !
current
().useStdOut() )
217
theStream
->rdbuf(
current
().misc().rdbuf());
218
}
219
224
~Redirect
() {
225
theStream
->rdbuf(
theBuffer
);
226
}
227
232
string
str
()
const
{
233
return
intStream
.str();
234
}
235
239
ostream *
theStream
;
240
244
std::streambuf *
theBuffer
;
245
250
ostringstream
intStream
;
251
252
};
253
254
private
:
255
259
static
vector<EGPtr>
theGeneratorStack
;
260
265
bool
generatorPushed
;
266
267
private
:
268
272
CurrentGenerator
&
operator=
(
const
CurrentGenerator
&) =
delete
;
273
274
};
275
276
}
277
278
#endif
/* ThePEG_CurrentGenerator_H */
ThePEG::CurrentGenerator::Redirect
Class used to temporarily redirect a given ostream to the misc() stream of the current EventGenerator...
Definition:
CurrentGenerator.h:201
ThePEG::CurrentGenerator::Redirect::intStream
ostringstream intStream
An internal buffer, the content of which will be discarded when the this object is destructed.
Definition:
CurrentGenerator.h:250
ThePEG::CurrentGenerator::Redirect::theStream
ostream * theStream
The stream which is redirected.
Definition:
CurrentGenerator.h:239
ThePEG::CurrentGenerator::Redirect::~Redirect
~Redirect()
The destructor which restores the original destination of the stream.
Definition:
CurrentGenerator.h:224
ThePEG::CurrentGenerator::Redirect::str
string str() const
If output is stored internally, acces what has been written so far.
Definition:
CurrentGenerator.h:232
ThePEG::CurrentGenerator::Redirect::theBuffer
std::streambuf * theBuffer
The original buffer of the redirected stream.
Definition:
CurrentGenerator.h:244
ThePEG::CurrentGenerator::Redirect::Redirect
Redirect(ostream &os, bool internal=false)
Constructor taking the stream to be redirected as input.
Definition:
CurrentGenerator.h:213
ThePEG::CurrentGenerator
This CurrentGenerator class keeps a static stack of EventGenerators which can be used anywhere by any...
Definition:
CurrentGenerator.h:33
ThePEG::CurrentGenerator::getPointer
static IBPtr getPointer(string name)
Get object.
Definition:
CurrentGenerator.h:172
ThePEG::CurrentGenerator::theGeneratorStack
static vector< EGPtr > theGeneratorStack
The stack of EventGenerators requested.
Definition:
CurrentGenerator.h:259
ThePEG::CurrentGenerator::generatorPushed
bool generatorPushed
True if this object is responsible for pushing a EventGenerator onto the stack.
Definition:
CurrentGenerator.h:265
ThePEG::CurrentGenerator::operator*
EventGenerator & operator*() const
Return a reference to the currently chosen object.
Definition:
CurrentGenerator.h:87
ThePEG::CurrentGenerator::strategy
static tStrategyPtr strategy()
Return a pointer to the strategy object containing eg.
Definition:
CurrentGenerator.h:131
ThePEG::CurrentGenerator::ptr
static EventGenerator * ptr()
Pointer to the stack.
Definition:
CurrentGenerator.h:101
ThePEG::CurrentGenerator::operator->
EventGenerator * operator->() const
Return a pointer to the currently chosen object.
Definition:
CurrentGenerator.h:94
ThePEG::CurrentGenerator::ref
static ostream & ref()
Get the current standard ref stream.
Definition:
CurrentGenerator.h:155
ThePEG::CurrentGenerator::operator!
bool operator!() const
Test for existance.
Definition:
CurrentGenerator.h:115
ThePEG::CurrentGenerator::~CurrentGenerator
~CurrentGenerator()
The destructor removing the EventGenerator specified in the constructor from the stack.
Definition:
CurrentGenerator.h:63
ThePEG::CurrentGenerator::isVoid
static bool isVoid()
Returns true if there is no currently chosen EventGenerator object.
Definition:
CurrentGenerator.h:73
ThePEG::CurrentGenerator::standardModel
static tSMPtr standardModel()
Return a pointer to the standard model parameters used by the current generator.
Definition:
CurrentGenerator.h:123
ThePEG::CurrentGenerator::getPtr
static Ptr< T >::pointer getPtr(const T &t)
Get object.
Definition:
CurrentGenerator.h:163
ThePEG::CurrentGenerator::log
static ostream & log()
Get the current standard log stream.
Definition:
CurrentGenerator.h:147
ThePEG::CurrentGenerator::CurrentGenerator
CurrentGenerator(const CurrentGenerator &)
Copy-constructor does nothing.
Definition:
CurrentGenerator.h:45
ThePEG::CurrentGenerator::CurrentGenerator
CurrentGenerator()
Default constructor does nothing.
Definition:
CurrentGenerator.h:40
ThePEG::CurrentGenerator::current
static EventGenerator & current()
Return a reference to the currently chosen EventGenerator object.
Definition:
CurrentGenerator.h:80
ThePEG::CurrentGenerator::getDefault
static Ptr< T >::pointer getDefault()
Get default object.
Definition:
CurrentGenerator.h:191
ThePEG::CurrentGenerator::getObject
static Ptr< T >::pointer getObject(string name)
Get object.
Definition:
CurrentGenerator.h:182
ThePEG::CurrentGenerator::CurrentGenerator
CurrentGenerator(const EGPtr &eg)
Construct a new object specifying a new EventGenerator, eg, to be used during this objects lifetime.
Definition:
CurrentGenerator.h:52
ThePEG::CurrentGenerator::operator=
CurrentGenerator & operator=(const CurrentGenerator &)=delete
Private and non-existent assignment operator.
ThePEG::CurrentGenerator::out
static ostream & out()
Get the current standard output stream.
Definition:
CurrentGenerator.h:139
ThePEG::EventGenerator
The EventGenerator class manages a whole event generator run.
Definition:
EventGenerator.h:68
ThePEG::EventGenerator::getPtr
Ptr< T >::pointer getPtr(const T &) const
Return a garbage collected pointer to a given object.
ThePEG::EventGenerator::getObject
Ptr< T >::pointer getObject(string name) const
Return a pointer to an object of type T present in this run given its full name.
Definition:
EventGenerator.h:416
ThePEG::EventGenerator::out
ostream & out()
This stream should be used for output of information and statistics of an EventGenerator run in the f...
ThePEG::EventGenerator::ref
ostream & ref()
Return a reference to the stream connected to the filea for references from used objects.
ThePEG::EventGenerator::strategy
tStrategyPtr strategy() const
Return a pointer to the strategy object containing a set of non-default particles to use.
Definition:
EventGenerator.h:114
ThePEG::EventGenerator::getPointer
IBPtr getPointer(string name) const
Return a pointer to an object present in this run given its full name.
ThePEG::EventGenerator::standardModel
tSMPtr standardModel() const
Return a pointer to the standard model parameters.
Definition:
EventGenerator.h:108
ThePEG::EventGenerator::getDefault
Ptr< T >::pointer getDefault() const
Return the default object for class T.
ThePEG::EventGenerator::log
ostream & log()
Return a reference to the stream connected to the file for logging information.
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
This is the main namespace within which all identifiers in ThePEG are declared.
Definition:
FactoryBase.h:28
Generated on Thu Jun 20 2024 14:47:00 for ThePEG by
1.9.6