thepeg
is hosted by
Hepforge
,
IPPP Durham
ThePEG
2.3.0
Utilities
HoldFlag.h
1
// -*- C++ -*-
2
//
3
// HoldFlag.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_HoldFlag_H
10
#define ThePEG_HoldFlag_H
11
// This is the declaration of the HoldFlag class.
12
13
namespace
ThePEG
{
14
15
template
<
typename
T =
bool
>
23
class
HoldFlag
{
24
25
public
:
26
32
HoldFlag
(T & newFlag,
const
T & holdFlag)
33
:
theFlag
(newFlag),
oldFlag
(holdFlag) {
std::swap
(
theFlag
,
oldFlag
); }
34
42
HoldFlag
(T & newFlag,
const
T & holdFlag,
const
T & finalFlag)
43
:
theFlag
(newFlag),
oldFlag
(holdFlag)
44
{
45
std::swap
(
theFlag
,
oldFlag
);
46
oldFlag
= finalFlag;
47
}
48
53
~HoldFlag
() {
std::swap
(
theFlag
,
oldFlag
); }
54
55
private
:
56
60
T &
theFlag
;
61
65
T
oldFlag
;
66
70
HoldFlag
();
71
75
HoldFlag
(
const
HoldFlag
&);
76
80
HoldFlag
&
operator=
(
const
HoldFlag
&) =
delete
;
81
82
};
83
87
template
<>
88
class
HoldFlag
<bool> {
89
90
public
:
91
97
HoldFlag
(
bool
& newFlag,
bool
holdFlag =
true
)
98
:
theFlag
(newFlag),
oldFlag
(newFlag) {
theFlag
= holdFlag; }
99
107
HoldFlag
(
bool
& newFlag,
bool
holdFlag,
bool
finalFlag)
108
:
theFlag
(newFlag),
oldFlag
(finalFlag) {
theFlag
= holdFlag; }
109
114
~HoldFlag
() {
theFlag
=
oldFlag
; }
115
116
private
:
117
121
bool
&
theFlag
;
122
126
bool
oldFlag
;
127
131
HoldFlag
();
132
136
HoldFlag
(
const
HoldFlag
&);
137
141
HoldFlag
&
operator=
(
const
HoldFlag
&) =
delete
;
142
143
};
144
145
}
146
147
#endif
/* ThePEG_HoldFlag_H */
ThePEG::HoldFlag< bool >::HoldFlag
HoldFlag(bool &newFlag, bool holdFlag, bool finalFlag)
Constructor setting the a temporary value for the bool variable.
Definition:
HoldFlag.h:107
ThePEG::HoldFlag< bool >::theFlag
bool & theFlag
The variable to be changed.
Definition:
HoldFlag.h:121
ThePEG::HoldFlag< bool >::HoldFlag
HoldFlag(const HoldFlag &)
Copy constructor is private and not implemented.
ThePEG::HoldFlag< bool >::HoldFlag
HoldFlag(bool &newFlag, bool holdFlag=true)
Constructor setting the a temporary value for the bool variable.
Definition:
HoldFlag.h:97
ThePEG::HoldFlag< bool >::HoldFlag
HoldFlag()
Default constructor is private and not implemented.
ThePEG::HoldFlag< bool >::oldFlag
bool oldFlag
The value which will be restored when this is destroyed.
Definition:
HoldFlag.h:126
ThePEG::HoldFlag< bool >::~HoldFlag
~HoldFlag()
Destructor.
Definition:
HoldFlag.h:114
ThePEG::HoldFlag< bool >::operator=
HoldFlag & operator=(const HoldFlag &)=delete
Assignment is private and not implemented.
ThePEG::HoldFlag
HoldFlag objects are used to temporarily change the value of an object, restoring the original value ...
Definition:
HoldFlag.h:23
ThePEG::HoldFlag::theFlag
T & theFlag
The object to be changed.
Definition:
HoldFlag.h:60
ThePEG::HoldFlag::operator=
HoldFlag & operator=(const HoldFlag &)=delete
Assignment is private and not implemented.
ThePEG::HoldFlag::oldFlag
T oldFlag
The value which will be restored when this is destroyed.
Definition:
HoldFlag.h:65
ThePEG::HoldFlag::~HoldFlag
~HoldFlag()
Destructor.
Definition:
HoldFlag.h:53
ThePEG::HoldFlag::HoldFlag
HoldFlag(const HoldFlag &)
Copy constructor is private and not implemented.
ThePEG::HoldFlag::HoldFlag
HoldFlag()
Default constructor is private and not implemented.
ThePEG::HoldFlag::HoldFlag
HoldFlag(T &newFlag, const T &holdFlag)
Constructor setting a temporary value for the given object.
Definition:
HoldFlag.h:32
ThePEG::HoldFlag::HoldFlag
HoldFlag(T &newFlag, const T &holdFlag, const T &finalFlag)
Constructor setting the a temporary value for the given object.
Definition:
HoldFlag.h:42
ThePEG
This is the main namespace within which all identifiers in ThePEG are declared.
Definition:
FactoryBase.h:28
std::swap
void swap(ThePEG::Pointer::RCPtr< T > &t1, ThePEG::Pointer::RCPtr< T > &t2)
Specialization of std::swap to avoid unnecessary (in/de)crements of the reference count.
Definition:
RCPtr.h:1154
Generated on Thu Jun 20 2024 14:47:02 for ThePEG by
1.9.6