vcsl_unit.h
Go to the documentation of this file.
1 #ifndef vcsl_unit_h_
2 #define vcsl_unit_h_
3 //:
4 // \file
5 // \brief Abstract unit associated to a dimension
6 // \author Francois BERTEL
7 //
8 // \verbatim
9 // Modifications
10 // 2000/06/28 Francois BERTEL Creation. Adapted from IUE
11 // 2001/04/10 Ian Scott (Manchester) Converted perceps header to doxygen
12 // 2004/09/10 Peter Vanroose Inlined all 1-line methods in class decl
13 // 2004/09/17 Peter Vanroose do not pass vcsl_unit objects; use vcsl_unit_sptr instead
14 // \endverbatim
15 
16 #include <vcsl/vcsl_unit_sptr.h>
17 #include <vbl/vbl_ref_count.h>
18 
19 class vcsl_acceleration_unit;
20 class vcsl_angle_unit;
21 class vcsl_charge_unit;
22 class vcsl_length_unit;
23 class vcsl_mass_unit;
24 class vcsl_temperature_unit;
25 class vcsl_time_unit;
26 class vcsl_velocity_unit;
27 
28 //: Abstract unit associated to a dimension
29 // A unit specifies how the quantity is measured--effectively, it specifies
30 // what is amount is to be defined as 1
31 //
32 // This is a pure virtual class.
33 
34 class vcsl_unit
35  : public vbl_ref_count
36 {
37  //***************************************************************************
38  // Constructors/Destructor
39  //***************************************************************************
40 
41  protected:
42  // Default constructor
43  vcsl_unit() = default;
44 
45  public:
46  // Copy constructor
48 
49  // Destructor
50  ~vcsl_unit() override = default;
51 
52  //***************************************************************************
53  // Status report
54  //***************************************************************************
55 
56  //: Are `this' and `other' compatible units ?
57  // (Are they associated to the same dimension ?)
58  virtual bool compatible_units(vcsl_unit_sptr const& other) const=0;
59 
60  //: Return the standard unit associated to the dimension of `this'
61  virtual vcsl_unit_sptr standard_unit() const=0;
62 
63  //: Returns the number of units of `this' equal of the standard_unit for the dimension
64  virtual double units_per_standard_unit() const=0;
65 
66  //***************************************************************************
67  // Because VXL does not necessarily use dynamic_cast<>
68  //***************************************************************************
69 
70  virtual const vcsl_acceleration_unit *cast_to_acceleration_unit() const { return nullptr; }
71  virtual const vcsl_angle_unit *cast_to_angle_unit() const { return nullptr; }
72  virtual const vcsl_charge_unit *cast_to_charge_unit() const { return nullptr; }
73  virtual const vcsl_length_unit *cast_to_length_unit() const { return nullptr; }
74  virtual const vcsl_mass_unit *cast_to_mass_unit() const { return nullptr; }
75  virtual const vcsl_temperature_unit *cast_to_temperature_unit() const { return nullptr; }
76  virtual const vcsl_time_unit *cast_to_time_unit() const { return nullptr; }
77  virtual const vcsl_velocity_unit *cast_to_velocity_unit() const { return nullptr; }
78 };
79 
80 #endif // vcsl_unit_h_
~vcsl_unit() override=default
virtual const vcsl_velocity_unit * cast_to_velocity_unit() const
Definition: vcsl_unit.h:77
virtual const vcsl_mass_unit * cast_to_mass_unit() const
Definition: vcsl_unit.h:74
virtual vcsl_unit_sptr standard_unit() const =0
Return the standard unit associated to the dimension of ‘this’.
virtual const vcsl_acceleration_unit * cast_to_acceleration_unit() const
Definition: vcsl_unit.h:70
virtual bool compatible_units(vcsl_unit_sptr const &other) const =0
Are ‘this’ and ‘other’ compatible units ?.
virtual const vcsl_length_unit * cast_to_length_unit() const
Definition: vcsl_unit.h:73
virtual const vcsl_temperature_unit * cast_to_temperature_unit() const
Definition: vcsl_unit.h:75
virtual double units_per_standard_unit() const =0
Returns the number of units of ‘this’ equal of the standard_unit for the dimension.
Abstract unit associated to the length dimension.
Abstract unit associated to the angle dimension.
Abstract unit associated to a dimension.
Definition: vcsl_unit.h:34
vcsl_unit()=default
virtual const vcsl_angle_unit * cast_to_angle_unit() const
Definition: vcsl_unit.h:71
vcsl_unit(vcsl_unit const &)
Definition: vcsl_unit.h:47
virtual const vcsl_charge_unit * cast_to_charge_unit() const
Definition: vcsl_unit.h:72
virtual const vcsl_time_unit * cast_to_time_unit() const
Definition: vcsl_unit.h:76