Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:29

0001 // Created on: 1992-06-22
0002 // Created by: Gilles DEBARBOUILLE
0003 // Copyright (c) 1992-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _Units_Measurement_HeaderFile
0018 #define _Units_Measurement_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 class Units_Token;
0025 
0026 
0027 //! This class  defines  a measurement which is the
0028 //! association of a real value and a unit.
0029 class Units_Measurement 
0030 {
0031 public:
0032 
0033   DEFINE_STANDARD_ALLOC
0034 
0035   
0036   //! It is the empty constructor of the class.
0037   Standard_EXPORT Units_Measurement();
0038   
0039   //! Returns an instance  of this class.   <avalue> defines
0040   //! the measurement, and <atoken>  the token which defines
0041   //! the unit used.
0042   Standard_EXPORT Units_Measurement(const Standard_Real avalue, const Handle(Units_Token)& atoken);
0043   
0044   //! Returns an  instance of this  class.  <avalue> defines
0045   //! the  measurement, and <aunit> the   unit used,
0046   //! described in natural language.
0047   Standard_EXPORT Units_Measurement(const Standard_Real avalue, const Standard_CString aunit);
0048   
0049   //! Converts (if   possible)  the  measurement   object into
0050   //! another   unit.      <aunit>   must  have    the  same
0051   //! dimensionality as  the  unit  contained in   the token
0052   //! <thetoken>.
0053   Standard_EXPORT void Convert (const Standard_CString aunit);
0054   
0055   //! Returns a Measurement object with the integer value of
0056   //! the measurement contained in <me>.
0057   Standard_EXPORT Units_Measurement Integer() const;
0058   
0059   //! Returns a Measurement object with the fractional value
0060   //! of the measurement contained in <me>.
0061   Standard_EXPORT Units_Measurement Fractional() const;
0062   
0063   //! Returns the value of the measurement.
0064   Standard_EXPORT Standard_Real Measurement() const;
0065   
0066   //! Returns the token contained in <me>.
0067   Standard_EXPORT Handle(Units_Token) Token() const;
0068   
0069   //! Returns (if it is possible) a measurement which is the
0070   //! addition  of  <me>  and  <ameasurement>.  The   chosen
0071   //! returned unit is the unit of <me>.
0072   Standard_EXPORT Units_Measurement Add (const Units_Measurement& ameasurement) const;
0073 Units_Measurement operator + (const Units_Measurement& ameasurement) const
0074 {
0075   return Add(ameasurement);
0076 }
0077   
0078   //! Returns (if it is possible) a measurement which is the
0079   //! subtraction of  <me>  and <ameasurement>.   The chosen
0080   //! returned unit is the unit of <me>.
0081   Standard_EXPORT Units_Measurement Subtract (const Units_Measurement& ameasurement) const;
0082 Units_Measurement operator - (const Units_Measurement& ameasurement) const
0083 {
0084   return Subtract(ameasurement);
0085 }
0086   
0087   //! Returns  a measurement which  is the multiplication of
0088   //! <me> and <ameasurement>.
0089   Standard_EXPORT Units_Measurement Multiply (const Units_Measurement& ameasurement) const;
0090 Units_Measurement operator * (const Units_Measurement& ameasurement) const
0091 {
0092   return Multiply(ameasurement);
0093 }
0094   
0095   //! Returns  a measurement which  is the multiplication of
0096   //! <me> with the value  <avalue>.
0097   Standard_EXPORT Units_Measurement Multiply (const Standard_Real avalue) const;
0098 Units_Measurement operator * (const Standard_Real avalue) const
0099 {
0100   return Multiply(avalue);
0101 }
0102   
0103   //! Returns a measurement which  is the division of  <me> by
0104   //! <ameasurement>.
0105   Standard_EXPORT Units_Measurement Divide (const Units_Measurement& ameasurement) const;
0106 Units_Measurement operator / (const Units_Measurement& ameasurement) const
0107 {
0108   return Divide(ameasurement);
0109 }
0110   
0111   //! Returns  a measurement which  is the division of <me> by
0112   //! the constant <avalue>.
0113   Standard_EXPORT Units_Measurement Divide (const Standard_Real avalue) const;
0114 Units_Measurement operator / (const Standard_Real avalue) const
0115 {
0116   return Divide(avalue);
0117 }
0118   
0119   //! Returns   a    measurement  which   is <me>    powered
0120   //! <anexponent>.
0121   Standard_EXPORT Units_Measurement Power (const Standard_Real anexponent) const;
0122   
0123   Standard_EXPORT Standard_Boolean HasToken() const;
0124   
0125   //! Useful for debugging.
0126   Standard_EXPORT void Dump() const;
0127 
0128 
0129 
0130 
0131 protected:
0132 
0133 
0134 
0135 
0136 
0137 private:
0138 
0139 
0140 
0141   Standard_Real themeasurement;
0142   Handle(Units_Token) thetoken;
0143   Standard_Boolean myHasToken;
0144 
0145 
0146 };
0147 
0148 
0149 
0150 
0151 
0152 
0153 
0154 #endif // _Units_Measurement_HeaderFile