ThePEG
1.8.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
Utilities
EnumIO.h
1
// -*- C++ -*-
2
//
3
// EnumIO.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_EnumIO_H
10
#define ThePEG_EnumIO_H
11
// This is the declaration of the IEnum and OEnum classes and
12
// associated templated functions.
13
14
// #include "ThePEG/Config/ThePEG.h"
15
// #include "EnumIO.fh"
16
// #include "EnumIO.xh"
17
18
namespace
ThePEG {
19
20
template
<
typename
T>
30
struct
OEnum
{
31
33
OEnum
(
const
T & t):
theT
(t) {}
34
36
OEnum
(
const
OEnum
& oe):
theT
(oe.
theT
) {}
37
39
const
T &
theT
;
40
41
};
42
52
template
<
typename
T>
53
struct
IEnum
{
54
56
IEnum
(T & t):
theT
(t) {}
57
59
IEnum
(
const
IEnum
& ie):
theT
(ie.
theT
) {}
60
62
T &
theT
;
63
64
};
65
67
template
<
typename
T>
68
inline
OEnum<T>
oenum
(
const
T & t) {
69
return
OEnum<T>
(t);
70
}
71
73
template
<
typename
T>
74
inline
IEnum<T>
ienum
(T & t) {
75
return
IEnum<T>
(t);
76
}
77
79
template
<
typename
OStream,
typename
T>
80
OStream & operator<<(OStream & os, const OEnum<T> & e) {
81
os << long(e.theT);
82
return
os;
83
}
84
86
template
<
typename
IStream,
typename
T>
87
IStream &
operator>>
(IStream & is,
const
IEnum<T>
& e) {
88
long
l = 0;
89
is >> l;
90
e.
theT
= T(l);
91
return
is;
92
}
93
94
}
95
96
#endif
/* ThePEG_EnumIO_H */
Generated on Mon Jul 2 2012 16:06:46 for ThePEG by
1.8.1.1