core/vcsl/vcsl_unit.h
Go to the documentation of this file.
00001 #ifndef vcsl_unit_h_
00002 #define vcsl_unit_h_
00003 //:
00004 // \file
00005 // \brief Abstract unit associated to a dimension
00006 // \author François BERTEL
00007 //
00008 // \verbatim
00009 //  Modifications
00010 //   2000/06/28 François BERTEL Creation. Adapted from IUE
00011 //   2001/04/10 Ian Scott (Manchester) Converted perceps header to doxygen
00012 //   2004/09/10 Peter Vanroose  Inlined all 1-line methods in class decl
00013 //   2004/09/17 Peter Vanroose  do not pass vcsl_unit objects; use vcsl_unit_sptr instead
00014 // \endverbatim
00015 
00016 #include <vcsl/vcsl_unit_sptr.h>
00017 #include <vbl/vbl_ref_count.h>
00018 
00019 class vcsl_acceleration_unit;
00020 class vcsl_angle_unit;
00021 class vcsl_charge_unit;
00022 class vcsl_length_unit;
00023 class vcsl_mass_unit;
00024 class vcsl_temperature_unit;
00025 class vcsl_time_unit;
00026 class vcsl_velocity_unit;
00027 
00028 //: Abstract unit associated to a dimension
00029 // A unit specifies how the quantity is measured--effectively, it specifies
00030 // what is amount is to be defined as 1
00031 //
00032 // This is a pure virtual class.
00033 
00034 class vcsl_unit
00035   : public vbl_ref_count
00036 {
00037   //***************************************************************************
00038   // Constructors/Destructor
00039   //***************************************************************************
00040 
00041  protected:
00042   // Default constructor
00043   vcsl_unit() {}
00044 
00045  public:
00046   // Copy constructor
00047   vcsl_unit(vcsl_unit const&) : vbl_ref_count() {}
00048 
00049   // Destructor
00050   virtual ~vcsl_unit() {}
00051 
00052   //***************************************************************************
00053   // Status report
00054   //***************************************************************************
00055 
00056   //: Are `this' and `other' compatible units ?
00057   // (Are they associated to the same dimension ?)
00058   virtual bool compatible_units(vcsl_unit_sptr const& other) const=0;
00059 
00060   //: Return the standard unit associated to the dimension of `this'
00061   virtual vcsl_unit_sptr standard_unit() const=0;
00062 
00063   //: Returns the number of units of `this' equal of the standard_unit for the dimension
00064   virtual double units_per_standard_unit() const=0;
00065 
00066   //***************************************************************************
00067   // Because VXL does not necessarily use dynamic_cast<>
00068   //***************************************************************************
00069 
00070   virtual const vcsl_acceleration_unit *cast_to_acceleration_unit() const { return 0; }
00071   virtual const vcsl_angle_unit *cast_to_angle_unit() const { return 0; }
00072   virtual const vcsl_charge_unit *cast_to_charge_unit() const { return 0; }
00073   virtual const vcsl_length_unit *cast_to_length_unit() const { return 0; }
00074   virtual const vcsl_mass_unit *cast_to_mass_unit() const { return 0; }
00075   virtual const vcsl_temperature_unit *cast_to_temperature_unit() const { return 0; }
00076   virtual const vcsl_time_unit *cast_to_time_unit() const { return 0; }
00077   virtual const vcsl_velocity_unit *cast_to_velocity_unit() const { return 0; }
00078 };
00079 
00080 #endif // vcsl_unit_h_