ThePEG
1.8.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
Utilities
Current.h
1
// -*- C++ -*-
2
//
3
// Current.h is a part of ThePEG - Toolkit for HEP Event Generation
4
// Copyright (C) 1999-2011 Leif Lonnblad
5
//
6
// ThePEG is licenced under version 2 of the GPL, see COPYING for details.
7
// Please respect the MCnet academic guidelines, see GUIDELINES for details.
8
//
9
#ifndef ThePEG_Current_H
10
#define ThePEG_Current_H
11
// This is the declaration of the Current class.
12
13
namespace
ThePEG {
14
38
template
<
typename
T>
39
class
Current
{
40
41
public
:
42
46
Current
() :
pushed
(false) {}
47
51
Current
(
const
Current<T>
&)
52
:
pushed
(false) {}
53
59
Current
(T * t) :
pushed
(false) {
60
if
( t ) {
61
theStack
.push_back(t);
62
pushed
=
true
;
63
}
64
}
65
70
~Current
() {
71
if
(
pushed
)
theStack
.pop_back();
72
}
73
74
public
:
75
79
static
bool
isVoid
() {
80
return
theStack
.empty() || !(
theStack
.back());
81
}
82
86
static
T &
current
() {
87
return
*
theStack
.back();
88
}
89
93
T &
operator*
()
const
{
94
return
*
theStack
.back();
95
}
96
100
T *
operator->
()
const
{
101
return
theStack
.back();
102
}
103
107
static
T *
ptr
() {
108
return
theStack
.back();
109
}
110
114
operator
bool()
const
{
115
return
ptr
();
116
}
117
121
bool
operator!
()
const
{
122
return
!
ptr
();
123
}
124
125
private
:
126
130
static
vector<T *>
theStack
;
131
136
bool
pushed
;
137
138
private
:
139
143
Current<T>
&
operator=
(
const
Current<T>
&);
144
145
};
146
147
template
<
typename
T>
148
std::vector<T *>
ThePEG::Current<T>::theStack
;
149
150
}
151
152
#endif
/* ThePEG_Current_H */
Generated on Sat Jun 16 2012 16:51:03 for ThePEG by
1.8.1.1