LOGO

RestFrames  v1.0.1
RestFrames HEP Event Analysis Software Library
RFCharge.hh
Go to the documentation of this file.
1 // RestFrames: particle physics event analysis library
3 // --------------------------------------------------------------------
4 // Copyright (c) 2014-2016, Christopher Rogan
14 // This file is part of RestFrames.
15 //
16 // RestFrames is free software; you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation; either version 2 of the License, or
19 // (at your option) any later version.
20 //
21 // RestFrames is distributed in the hope that it will be useful,
22 // but WITHOUT ANY WARRANTY; without even the implied warranty of
23 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 // GNU General Public License for more details.
25 //
26 // You should have received a copy of the GNU General Public License
27 // along with RestFrames. If not, see <http://www.gnu.org/licenses/>.
29 
30 #ifndef RFCharge_HH
31 #define RFCharge_HH
32 
33 #include <cstdlib>
34 
35 namespace RestFrames {
36 
38  // RFCharge class
40  class RFCharge {
41 
42  public:
43 
47  RFCharge(const RFCharge& charge);
48 
52  RFCharge(int charge = 0);
53 
58  RFCharge(int charge_num, int charge_den);
59  ~RFCharge();
60 
64  int GetNumerator() const;
65 
69  int GetDenominator() const;
70 
74  bool operator == (const RFCharge& val) const;
75 
79  bool operator == (int val) const;
80 
84  bool operator != (const RFCharge& val) const;
85 
89  bool operator != (int val) const;
90 
94  void operator = (const RFCharge& val);
95 
99  void operator = (int val);
100 
101 
102  RFCharge operator + (const RFCharge& val) const;
103  RFCharge operator + (int val) const;
104 
105  RFCharge operator - (const RFCharge& val) const;
106  RFCharge operator - (int val) const;
107 
108  RFCharge operator * (const RFCharge& val) const;
109  RFCharge operator * (int val) const;
110 
111  RFCharge operator / (const RFCharge& val) const;
112  RFCharge operator / (int val) const;
113 
114  RFCharge& operator += (const RFCharge& val);
115  RFCharge& operator += (int val);
116 
117  RFCharge& operator -= (const RFCharge& val);
118  RFCharge& operator -= (int val);
119 
120  RFCharge& operator *= (const RFCharge& val);
121  RFCharge& operator *= (int val);
122 
123  RFCharge& operator /= (const RFCharge& val);
124  RFCharge& operator /= (int val);
125 
126  RFCharge operator-();
127 
128  operator double() const;
129 
130  private:
131  bool m_Sign;
132  int m_ChargeNum;
133  int m_ChargeDen;
134 
135  void Simplify();
136 
137  };
138 
139  RFCharge operator * (int val1, const RFCharge& val2);
140  RFCharge operator / (int val1, const RFCharge& val2);
141 
142  int gcd(int x, int y);
143 }
144 
145 #endif
RestFrames::RFCharge::GetDenominator
int GetDenominator() const
Returns denominator.
Definition: RFCharge.cc:96
RestFrames::RFCharge
Definition: RFCharge.hh:40
RestFrames::RFCharge::GetNumerator
int GetNumerator() const
Returns numerator.
Definition: RFCharge.cc:89
RestFrames::RFCharge::operator=
void operator=(const RFCharge &val)
Tests whether val is the same as this object's charge.
Definition: RFCharge.cc:146
RestFrames::RFCharge::operator!=
bool operator!=(const RFCharge &val) const
Tests whether val is not the same as this object's charge.
Definition: RFCharge.cc:127
RestFrames::RFCharge::operator==
bool operator==(const RFCharge &val) const
Tests whether val is the same as this object's charge.
Definition: RFCharge.cc:108
RestFrames::RFCharge::RFCharge
RFCharge(const RFCharge &charge)
Standard constructor.
Definition: RFCharge.cc:34