thepeg
is hosted by
Hepforge
,
IPPP Durham
ThePEG
2.3.0
Utilities
Direction.h
1
// -*- C++ -*-
2
//
3
// Direction.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_Direction_H
10
#define ThePEG_Direction_H
11
// This is the declaration of the Direction class.
12
13
#include "
ThePEG/Config/ThePEG.h
"
14
#include "Direction.xh"
15
16
namespace
ThePEG
{
17
18
template
<
int
I>
41
class
Direction
{
42
43
public
:
44
46
enum
Dir
{
Neg
= -1,
47
Negative
= -1,
48
Undefined
= 0,
49
Pos
= 1,
50
Positive
= 1
51
};
52
53
public
:
54
58
Direction
(
Dir
newDirection)
59
60
{
61
if
(
theDirection
!=
Undefined
)
throw
MultipleDirectionException(I);
62
if
( newDirection ==
Positive
)
theDirection
=
Positive
;
63
else
if
( newDirection ==
Negative
)
theDirection
=
Negative
;
64
else
throw
UndefinedDirectionException(I);
65
}
66
71
Direction
(
double
rnd)
72
{
73
if
(
theDirection
!=
Undefined
)
throw
MultipleDirectionException(I);
74
theDirection
= rnd > 0 ?
Positive
:
Negative
;
75
}
76
81
Direction
(
bool
p)
82
{
83
if
(
theDirection
!=
Undefined
)
throw
MultipleDirectionException(I);
84
theDirection
= p ?
Positive
:
Negative
;
85
}
86
90
~Direction
() {
theDirection
=
Undefined
; }
91
92
public
:
93
97
static
void
set
(
Dir
newDirection) {
98
if
( newDirection ==
Positive
)
theDirection
=
Positive
;
99
else
if
( newDirection ==
Negative
)
theDirection
=
Negative
;
100
else
throw
UndefinedDirectionException(I);
101
}
102
106
static
void
reverse
() {
107
theDirection
=
pos
() ?
Negative
:
Positive
;
108
}
109
113
static
bool
pos
() {
114
return
dir
() ==
Positive
;
115
}
116
120
static
bool
neg
() {
121
return
dir
() ==
Negative
;
122
}
123
127
static
Dir
dir
() {
128
if
(
theDirection
==
Undefined
)
throw
UndefinedDirectionException(I);
129
return
theDirection
;
130
}
131
132
private
:
133
137
static
Dir
theDirection
;
138
139
private
:
140
144
Direction
();
148
Direction
(
const
Direction
&);
152
Direction
&
operator=
(
const
Direction
&) =
delete
;
153
154
};
155
156
template
<
int
I>
157
typename
Direction<I>::Dir
Direction<I>::theDirection
=
Direction<I>::Undefined
;
158
159
}
160
161
#endif
/* ThePEG_Direction_H */
ThePEG.h
This is the main config header file for ThePEG.
ThePEG::Direction
A Direction object can be used to specify that some following operations should be assumed to be perf...
Definition:
Direction.h:41
ThePEG::Direction::theDirection
static Dir theDirection
The direction.
Definition:
Direction.h:137
ThePEG::Direction::neg
static bool neg()
Return true if the direction is negative (reversed).
Definition:
Direction.h:120
ThePEG::Direction::Direction
Direction(bool p)
Create an object with a positive direction if p is true, otherwise set the negative direction.
Definition:
Direction.h:81
ThePEG::Direction::Direction
Direction()
Default ctors and assignment is private and not implemented.
ThePEG::Direction::set
static void set(Dir newDirection)
Set the direction.
Definition:
Direction.h:97
ThePEG::Direction::Direction
Direction(const Direction &)
Default ctors and assignment is private and not implemented.
ThePEG::Direction::dir
static Dir dir()
Return the direction.
Definition:
Direction.h:127
ThePEG::Direction::pos
static bool pos()
Return true if the direction is positive.
Definition:
Direction.h:113
ThePEG::Direction::Direction
Direction(Dir newDirection)
Create an object with a given direction.
Definition:
Direction.h:58
ThePEG::Direction::Dir
Dir
The enum defining the directions.
Definition:
Direction.h:46
ThePEG::Direction::Undefined
@ Undefined
No direction has been defined.
Definition:
Direction.h:48
ThePEG::Direction::Negative
@ Negative
Reversed direction.
Definition:
Direction.h:47
ThePEG::Direction::Neg
@ Neg
Reversed direction.
Definition:
Direction.h:46
ThePEG::Direction::Pos
@ Pos
Standard (positive) direction.
Definition:
Direction.h:49
ThePEG::Direction::Positive
@ Positive
Standard (positive) direction.
Definition:
Direction.h:50
ThePEG::Direction::operator=
Direction & operator=(const Direction &)=delete
Default ctors and assignment is private and not implemented.
ThePEG::Direction::~Direction
~Direction()
Destructure makeing the static variable undefined.
Definition:
Direction.h:90
ThePEG::Direction::reverse
static void reverse()
Reverse the direction.
Definition:
Direction.h:106
ThePEG::Direction::Direction
Direction(double rnd)
Create an object with a positive direction if rnd > 0.5, otherwise set the negative direction.
Definition:
Direction.h:71
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:02 for ThePEG by
1.9.6