antioch-0.4.0
List of all members | Public Member Functions | Private Attributes | Friends
Antioch::InSI Class Reference

Seven integers to characterize the power vector. More...

#include <insi.h>

Public Member Functions

 InSI (int i0=0, int i1=0, int i2=0, int i3=0, int i4=0, int i5=0, int i6=0, int i7=0)
 Building constructor, fully descriptive, with zeros as default values to simplify coder's interface. More...
 
bool operator== (const InSI &rhs) const
 Bool equalize operator, true if all the powers are equal. More...
 
bool operator!= (const InSI &rhs) const
 Not bool const operator==(const InSI&) More...
 
InSIoperator= (const InSI &rhs)
 Assignement operator, equalize all the powers. More...
 
InSIoperator+= (const InSI &rhs)
 Adding operator, add all the powers. More...
 
InSIoperator-= (const InSI &rhs)
 Substracting operator, substract all the powers. More...
 
InSIoperator*= (int rhs)
 Multiplying operator, multiply all the powers. More...
 
InSIoperator/= (int rhs)
 Dividing operator. More...
 
InSI operator+ (const InSI &rhs) const
 Adding operator, add all the powers. More...
 
InSI operator- (const InSI &rhs) const
 Substracting operator, substract all the powers. More...
 
InSI operator* (int rhs) const
 Multiplying operator, multiply all the powers. More...
 
InSI operator/ (int rhs) const
 Dividing operator, see InSi & operator/=(int) for details. More...
 
void clear ()
 Set all the powers to zeros. More...
 
int get_m () const
 meter power getter More...
 
int get_kg () const
 kilogramme power getter More...
 
int get_s () const
 second power getter More...
 
int get_A () const
 ampere power getter More...
 
int get_K () const
 kelvin power getter More...
 
int get_mol () const
 mol power getter More...
 
int get_cd () const
 candela power getter More...
 
int get_rad () const
 radian power getter More...
 
bool empty () const
 Check if empty (all values to zero) More...
 

Private Attributes

int m
 
int kg
 
int s
 
int A
 
int K
 
int mol
 
int cd
 
int rad
 

Friends

std::ostream & operator<< (std::ostream &out, const InSI &rhs)
 << operator, to format the power vector More...
 

Detailed Description

Seven integers to characterize the power vector.

A unit is caracterize by the power associated to every base unit, this class stores those power.

Definition at line 43 of file insi.h.

Constructor & Destructor Documentation

Antioch::InSI::InSI ( int  i0 = 0,
int  i1 = 0,
int  i2 = 0,
int  i3 = 0,
int  i4 = 0,
int  i5 = 0,
int  i6 = 0,
int  i7 = 0 
)
inline

Building constructor, fully descriptive, with zeros as default values to simplify coder's interface.

Definition at line 48 of file insi.h.

Referenced by operator*(), operator+(), operator-(), and operator/().

48  :
49  m(i0),kg(i1),s(i2),A(i3),K(i4),mol(i5),cd(i6),rad(i7){}
int cd
Definition: insi.h:120
int mol
Definition: insi.h:120
int kg
Definition: insi.h:120
int rad
Definition: insi.h:120

Member Function Documentation

void Antioch::InSI::clear ( )
inline

Set all the powers to zeros.

Definition at line 276 of file insi.h.

References A, cd, K, kg, m, mol, rad, and s.

Referenced by Antioch::Units< T >::clear().

277 {
278  m = 0;
279  kg = 0;
280  s = 0;
281  A = 0;
282  K = 0;
283  mol = 0;
284  cd = 0;
285  rad = 0;
286 }
int cd
Definition: insi.h:120
int mol
Definition: insi.h:120
int kg
Definition: insi.h:120
int rad
Definition: insi.h:120
bool Antioch::InSI::empty ( ) const
inline

Check if empty (all values to zero)

Definition at line 289 of file insi.h.

References A, cd, K, kg, m, mol, rad, and s.

Referenced by Antioch::Units< T >::is_united().

290 {
291  return (m == 0 &&
292  kg == 0 &&
293  s == 0 &&
294  A == 0 &&
295  K == 0 &&
296  mol == 0 &&
297  cd == 0 &&
298  rad == 0);
299 }
int cd
Definition: insi.h:120
int mol
Definition: insi.h:120
int kg
Definition: insi.h:120
int rad
Definition: insi.h:120
int Antioch::InSI::get_A ( ) const
inline

ampere power getter

Definition at line 106 of file insi.h.

References A.

Referenced by operator+(), operator+=(), operator-(), operator-=(), operator=(), and operator==().

106 {return A;}
int Antioch::InSI::get_cd ( ) const
inline

candela power getter

Definition at line 112 of file insi.h.

References cd.

Referenced by operator+(), operator+=(), operator-(), operator-=(), operator=(), and operator==().

112 {return cd;}
int cd
Definition: insi.h:120
int Antioch::InSI::get_K ( ) const
inline

kelvin power getter

Definition at line 108 of file insi.h.

References K.

Referenced by operator+(), operator+=(), operator-(), operator-=(), operator=(), and operator==().

108 {return K;}
int Antioch::InSI::get_kg ( ) const
inline

kilogramme power getter

Definition at line 102 of file insi.h.

References kg.

Referenced by operator+(), operator+=(), operator-(), operator-=(), operator=(), and operator==().

102 {return kg;}
int kg
Definition: insi.h:120
int Antioch::InSI::get_m ( ) const
inline

meter power getter

Definition at line 100 of file insi.h.

References m.

Referenced by operator+(), operator+=(), operator-(), operator-=(), operator=(), and operator==().

100 {return m;}
int Antioch::InSI::get_mol ( ) const
inline

mol power getter

Definition at line 110 of file insi.h.

References mol.

Referenced by operator+(), operator+=(), operator-(), operator-=(), operator=(), and operator==().

110 {return mol;}
int mol
Definition: insi.h:120
int Antioch::InSI::get_rad ( ) const
inline

radian power getter

Definition at line 114 of file insi.h.

References rad.

Referenced by operator+(), operator+=(), operator-(), operator-=(), operator=(), and operator==().

114 {return rad;}
int rad
Definition: insi.h:120
int Antioch::InSI::get_s ( ) const
inline

second power getter

Definition at line 104 of file insi.h.

References s.

Referenced by operator+(), operator+=(), operator-(), operator-=(), operator=(), and operator==().

104 {return s;}
bool Antioch::InSI::operator!= ( const InSI rhs) const
inline

Not bool const operator==(const InSI&)

Definition at line 139 of file insi.h.

140 {
141  return (!(*this == rhs));
142 }
InSI Antioch::InSI::operator* ( int  rhs) const
inline

Multiplying operator, multiply all the powers.

Definition at line 255 of file insi.h.

References A, cd, InSI(), K, kg, m, mol, rad, and s.

256 {
257  return InSI(
258  m * rhs,
259  kg * rhs,
260  s * rhs,
261  A * rhs,
262  K * rhs,
263  mol * rhs,
264  cd * rhs,
265  rad * rhs
266  );
267 }
InSI(int i0=0, int i1=0, int i2=0, int i3=0, int i4=0, int i5=0, int i6=0, int i7=0)
Building constructor, fully descriptive, with zeros as default values to simplify coder's interface...
Definition: insi.h:48
int cd
Definition: insi.h:120
int mol
Definition: insi.h:120
int kg
Definition: insi.h:120
int rad
Definition: insi.h:120
InSI & Antioch::InSI::operator*= ( int  rhs)
inline

Multiplying operator, multiply all the powers.

Definition at line 218 of file insi.h.

References A, cd, K, kg, m, mol, rad, and s.

219 {
220  m *= rhs;
221  kg *= rhs;
222  s *= rhs;
223  A *= rhs;
224  K *= rhs;
225  mol *= rhs;
226  cd *= rhs;
227  rad *= rhs;
228  return *this;
229 }
int cd
Definition: insi.h:120
int mol
Definition: insi.h:120
int kg
Definition: insi.h:120
int rad
Definition: insi.h:120
InSI Antioch::InSI::operator+ ( const InSI rhs) const
inline

Adding operator, add all the powers.

Definition at line 160 of file insi.h.

References A, cd, get_A(), get_cd(), get_K(), get_kg(), get_m(), get_mol(), get_rad(), get_s(), InSI(), K, kg, m, mol, rad, and s.

161 {
162  return InSI(
163  m + rhs.get_m() ,
164  kg + rhs.get_kg() ,
165  s + rhs.get_s() ,
166  A + rhs.get_A() ,
167  K + rhs.get_K() ,
168  mol + rhs.get_mol(),
169  cd + rhs.get_cd() ,
170  rad + rhs.get_rad()
171  );
172 }
InSI(int i0=0, int i1=0, int i2=0, int i3=0, int i4=0, int i5=0, int i6=0, int i7=0)
Building constructor, fully descriptive, with zeros as default values to simplify coder's interface...
Definition: insi.h:48
int cd
Definition: insi.h:120
int mol
Definition: insi.h:120
int kg
Definition: insi.h:120
int rad
Definition: insi.h:120
InSI & Antioch::InSI::operator+= ( const InSI rhs)
inline

Adding operator, add all the powers.

Definition at line 190 of file insi.h.

References A, cd, get_A(), get_cd(), get_K(), get_kg(), get_m(), get_mol(), get_rad(), get_s(), K, kg, m, mol, rad, and s.

191 {
192  m += rhs.get_m();
193  kg += rhs.get_kg();
194  s += rhs.get_s();
195  A += rhs.get_A();
196  K += rhs.get_K();
197  mol += rhs.get_mol();
198  cd += rhs.get_cd();
199  rad += rhs.get_rad();
200  return *this;
201 }
int cd
Definition: insi.h:120
int mol
Definition: insi.h:120
int kg
Definition: insi.h:120
int rad
Definition: insi.h:120
InSI Antioch::InSI::operator- ( const InSI rhs) const
inline

Substracting operator, substract all the powers.

Definition at line 175 of file insi.h.

References A, cd, get_A(), get_cd(), get_K(), get_kg(), get_m(), get_mol(), get_rad(), get_s(), InSI(), K, kg, m, mol, rad, and s.

176 {
177  return InSI(
178  m - rhs.get_m() ,
179  kg - rhs.get_kg() ,
180  s - rhs.get_s() ,
181  A - rhs.get_A() ,
182  K - rhs.get_K() ,
183  mol - rhs.get_mol(),
184  cd - rhs.get_cd() ,
185  rad - rhs.get_rad()
186  );
187 }
InSI(int i0=0, int i1=0, int i2=0, int i3=0, int i4=0, int i5=0, int i6=0, int i7=0)
Building constructor, fully descriptive, with zeros as default values to simplify coder's interface...
Definition: insi.h:48
int cd
Definition: insi.h:120
int mol
Definition: insi.h:120
int kg
Definition: insi.h:120
int rad
Definition: insi.h:120
InSI & Antioch::InSI::operator-= ( const InSI rhs)
inline

Substracting operator, substract all the powers.

Definition at line 204 of file insi.h.

References A, cd, get_A(), get_cd(), get_K(), get_kg(), get_m(), get_mol(), get_rad(), get_s(), K, kg, m, mol, rad, and s.

205 {
206  m -= rhs.get_m();
207  kg -= rhs.get_kg();
208  s -= rhs.get_s();
209  A -= rhs.get_A();
210  K -= rhs.get_K();
211  mol -= rhs.get_mol();
212  cd -= rhs.get_cd();
213  rad -= rhs.get_rad();
214  return *this;
215 }
int cd
Definition: insi.h:120
int mol
Definition: insi.h:120
int kg
Definition: insi.h:120
int rad
Definition: insi.h:120
InSI Antioch::InSI::operator/ ( int  rhs) const
inline

Dividing operator, see InSi & operator/=(int) for details.

Definition at line 270 of file insi.h.

References InSI().

271 {
272  return (InSI(*this) /= rhs);
273 }
InSI(int i0=0, int i1=0, int i2=0, int i3=0, int i4=0, int i5=0, int i6=0, int i7=0)
Building constructor, fully descriptive, with zeros as default values to simplify coder's interface...
Definition: insi.h:48
InSI & Antioch::InSI::operator/= ( int  rhs)
inline

Dividing operator.

Dividing a power needs first to check that the division is possible, i.e. if the power is not null, it must be a multiple of the divider. If not it sends back an error and stops. This division exist for root purposes.

Definition at line 232 of file insi.h.

References A, antioch_unit_error, cd, K, kg, m, mol, rad, and s.

233 {
234  if(m %rhs != 0)antioch_unit_error("Cannot have non integer power (m).");
235  if(kg %rhs != 0)antioch_unit_error("Cannot have non integer power (kg).");
236  if(s %rhs != 0)antioch_unit_error("Cannot have non integer power (s).");
237  if(A %rhs != 0)antioch_unit_error("Cannot have non integer power (A).");
238  if(K %rhs != 0)antioch_unit_error("Cannot have non integer power (K).");
239  if(mol%rhs != 0)antioch_unit_error("Cannot have non integer power (mol).");
240  if(cd %rhs != 0)antioch_unit_error("Cannot have non integer power (cd).");
241  if(rad%rhs != 0)antioch_unit_error("Cannot have non integer power (rad).");
242  m /= rhs;
243  kg /= rhs;
244  s /= rhs;
245  A /= rhs;
246  K /= rhs;
247  mol /= rhs;
248  cd /= rhs;
249  rad /= rhs;
250 
251  return *this;
252 }
#define antioch_unit_error(description)
int cd
Definition: insi.h:120
int mol
Definition: insi.h:120
int kg
Definition: insi.h:120
int rad
Definition: insi.h:120
InSI & Antioch::InSI::operator= ( const InSI rhs)
inline

Assignement operator, equalize all the powers.

Definition at line 145 of file insi.h.

References A, cd, get_A(), get_cd(), get_K(), get_kg(), get_m(), get_mol(), get_rad(), get_s(), K, kg, m, mol, rad, and s.

146 {
147  if(this == &rhs){return *this;}
148  m = rhs.get_m();
149  kg = rhs.get_kg();
150  s = rhs.get_s();
151  A = rhs.get_A();
152  K = rhs.get_K();
153  mol = rhs.get_mol();
154  cd = rhs.get_cd();
155  rad = rhs.get_rad();
156  return *this;
157 }
int cd
Definition: insi.h:120
int mol
Definition: insi.h:120
int kg
Definition: insi.h:120
int rad
Definition: insi.h:120
bool Antioch::InSI::operator== ( const InSI rhs) const
inline

Bool equalize operator, true if all the powers are equal.

Definition at line 124 of file insi.h.

References A, cd, get_A(), get_cd(), get_K(), get_kg(), get_m(), get_mol(), get_rad(), get_s(), K, kg, m, mol, rad, and s.

125 {
126  return (
127  m == rhs.get_m() &&
128  kg == rhs.get_kg() &&
129  s == rhs.get_s() &&
130  A == rhs.get_A() &&
131  K == rhs.get_K() &&
132  mol == rhs.get_mol() &&
133  cd == rhs.get_cd() &&
134  rad == rhs.get_rad()
135  );
136 }
int cd
Definition: insi.h:120
int mol
Definition: insi.h:120
int kg
Definition: insi.h:120
int rad
Definition: insi.h:120

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const InSI rhs 
)
friend

<< operator, to format the power vector

Definition at line 52 of file insi.h.

53  {
54  out << "["
55  << rhs.get_m() << "(m),"
56  << rhs.get_kg() << "(kg),"
57  << rhs.get_s() << "(s),"
58  << rhs.get_A() << "(A),"
59  << rhs.get_K() << "(K),"
60  << rhs.get_mol() << "(mol),"
61  << rhs.get_cd() << "(cd),"
62  << rhs.get_rad() << "(rad)]";
63  return out;
64  }

Member Data Documentation

int Antioch::InSI::A
private
int Antioch::InSI::cd
private
int Antioch::InSI::K
private
int Antioch::InSI::kg
private
int Antioch::InSI::m
private
int Antioch::InSI::mol
private
int Antioch::InSI::rad
private
int Antioch::InSI::s
private

The documentation for this class was generated from the following file:

Generated on Thu Jul 7 2016 11:09:49 for antioch-0.4.0 by  doxygen 1.8.8