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  RFCharge(const RFCharge& charge);
44  RFCharge(int charge = 0);
45  RFCharge(int charge_num, int charge_den);
46  ~RFCharge();
47 
48  int GetNumerator() const;
49  int GetDenominator() const;
50 
51  bool operator == (const RFCharge& val) const;
52  bool operator == (int val) const;
53 
54  bool operator != (const RFCharge& val) const;
55  bool operator != (int val) const;
56 
57  void operator = (const RFCharge& val);
58  void operator = (int val);
59 
60  RFCharge operator + (const RFCharge& val) const;
61  RFCharge operator + (int val) const;
62 
63  RFCharge operator - (const RFCharge& val) const;
64  RFCharge operator - (int val) const;
65 
66  RFCharge operator * (const RFCharge& val) const;
67  RFCharge operator * (int val) const;
68 
69  RFCharge operator / (const RFCharge& val) const;
70  RFCharge operator / (int val) const;
71 
72  RFCharge& operator += (const RFCharge& val);
73  RFCharge& operator += (int val);
74 
75  RFCharge& operator -= (const RFCharge& val);
76  RFCharge& operator -= (int val);
77 
78  RFCharge& operator *= (const RFCharge& val);
79  RFCharge& operator *= (int val);
80 
81  RFCharge& operator /= (const RFCharge& val);
82  RFCharge& operator /= (int val);
83 
84  RFCharge operator-();
85 
86  operator double() const;
87 
88  private:
89  bool m_Sign;
90  int m_ChargeNum;
91  int m_ChargeDen;
92 
93  void Simplify();
94 
95  };
96 
97  RFCharge operator * (int val1, const RFCharge& val2);
98  RFCharge operator / (int val1, const RFCharge& val2);
99 
100  int gcd(int x, int y);
101 }
102 
103 #endif