Jpp 20.0.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JGeometry3D/JEnergy.hh
Go to the documentation of this file.
1#ifndef __JGEOMETRY3D_JENERGY__
2#define __JGEOMETRY3D_JENERGY__
3
4#include <istream>
5#include <ostream>
6
8
9#include "JLang/JManip.hh"
10
11
12/**
13 * \author mdejong
14 */
15
16namespace JGEOMETRY3D {}
17namespace JPP { using namespace JGEOMETRY3D; }
18
19namespace JGEOMETRY3D {
20
21 using JIO::JReader;
22 using JIO::JWriter;
23
24
25 /**
26 * Energy.
27 */
28 class JEnergy
29 {
30 public:
31 /**
32 * Default constructor.
33 */
35 __E(0.0)
36 {}
37
38
39 /**
40 * Constructor.
41 *
42 * \param E energy
43 */
44 JEnergy(const double E) :
45 __E(E)
46 {}
47
48
49 /**
50 * Set energy.
51 *
52 * \param energy energy
53 */
54 inline void setE(const double energy)
55 {
56 __E = energy;
57 }
58
59
60 /**
61 * Get energy.
62 *
63 * \return energy
64 */
65 inline double getE() const
66 {
67 return __E;
68 }
69
70
71 /**
72 * Read energy from input.
73 *
74 * \param in input stream
75 * \param energy energy
76 * \return input stream
77 */
78 friend inline std::istream& operator>>(std::istream& in, JEnergy& energy)
79 {
80 in >> energy.__E;
81
82 return in;
83 }
84
85
86 /**
87 * Write energy to output.
88 *
89 * \param out output stream
90 * \param energy energy
91 * \return output stream
92 */
93 friend inline std::ostream& operator<<(std::ostream& out, const JEnergy& energy)
94 {
95 const JFormat format(out, getFormat<JEnergy>(JFormat_t(12, 3, std::ios::scientific)));
96
97 out << energy.__E;
98
99 return out;
100 }
101
102
103 /**
104 * Read energy from input.
105 *
106 * \param in reader
107 * \param energy energy
108 * \return reader
109 */
110 friend inline JReader& operator>>(JReader& in, JEnergy& energy)
111 {
112 in >> energy.__E;
113
114 return in;
115 }
116
117
118 /**
119 * Write energy to output.
120 *
121 * \param out writer
122 * \param energy energy
123 * \return writer
124 */
125 friend inline JWriter& operator<<(JWriter& out, const JEnergy& energy)
126 {
127 out << energy.__E;
128
129 return out;
130 }
131
132
133 protected:
134 double __E;
135 };
136}
137
138#endif
I/O manipulators.
JFormat_t & getFormat()
Get format for given type.
Definition JManip.hh:682
friend JReader & operator>>(JReader &in, JEnergy &energy)
Read energy from input.
JEnergy(const double E)
Constructor.
JEnergy()
Default constructor.
void setE(const double energy)
Set energy.
friend JWriter & operator<<(JWriter &out, const JEnergy &energy)
Write energy to output.
double getE() const
Get energy.
friend std::ostream & operator<<(std::ostream &out, const JEnergy &energy)
Write energy to output.
friend std::istream & operator>>(std::istream &in, JEnergy &energy)
Read energy from input.
Interface for binary input.
Interface for binary output.
Auxiliary classes and methods for 3D geometrical objects and operations.
Definition JAngle3D.hh:19
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Data structure for format specifications.
Definition JManip.hh:524
Auxiliary class to temporarily define format specifications.
Definition JManip.hh:636