1 // Created on: 1992-06-22
2 // Created by: Gilles DEBARBOUILLE
3 // Copyright (c) 1992-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _Units_Measurement_HeaderFile
18 #define _Units_Measurement_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <Standard_Real.hxx>
25 #include <Standard_Boolean.hxx>
26 #include <Standard_CString.hxx>
30 //! This class defines a measurement which is the
31 //! association of a real value and a unit.
32 class Units_Measurement
39 //! It is the empty constructor of the class.
40 Standard_EXPORT Units_Measurement();
42 //! Returns an instance of this class. <avalue> defines
43 //! the measurement, and <atoken> the token which defines
45 Standard_EXPORT Units_Measurement(const Standard_Real avalue, const Handle(Units_Token)& atoken);
47 //! Returns an instance of this class. <avalue> defines
48 //! the measurement, and <aunit> the unit used,
49 //! described in natural language.
50 Standard_EXPORT Units_Measurement(const Standard_Real avalue, const Standard_CString aunit);
52 //! Converts (if possible) the measurement object into
53 //! another unit. <aunit> must have the same
54 //! dimensionality as the unit contained in the token
56 Standard_EXPORT void Convert (const Standard_CString aunit);
58 //! Returns a Measurement object with the integer value of
59 //! the measurement contained in <me>.
60 Standard_EXPORT Units_Measurement Integer() const;
62 //! Returns a Measurement object with the fractional value
63 //! of the measurement contained in <me>.
64 Standard_EXPORT Units_Measurement Fractional() const;
66 //! Returns the value of the measurement.
67 Standard_EXPORT Standard_Real Measurement() const;
69 //! Returns the token contained in <me>.
70 Standard_EXPORT Handle(Units_Token) Token() const;
72 //! Returns (if it is possible) a measurement which is the
73 //! addition of <me> and <ameasurement>. The chosen
74 //! returned unit is the unit of <me>.
75 Standard_EXPORT Units_Measurement Add (const Units_Measurement& ameasurement) const;
76 Units_Measurement operator + (const Units_Measurement& ameasurement) const
78 return Add(ameasurement);
81 //! Returns (if it is possible) a measurement which is the
82 //! subtraction of <me> and <ameasurement>. The chosen
83 //! returned unit is the unit of <me>.
84 Standard_EXPORT Units_Measurement Subtract (const Units_Measurement& ameasurement) const;
85 Units_Measurement operator - (const Units_Measurement& ameasurement) const
87 return Subtract(ameasurement);
90 //! Returns a measurement which is the multiplication of
91 //! <me> and <ameasurement>.
92 Standard_EXPORT Units_Measurement Multiply (const Units_Measurement& ameasurement) const;
93 Units_Measurement operator * (const Units_Measurement& ameasurement) const
95 return Multiply(ameasurement);
98 //! Returns a measurement which is the multiplication of
99 //! <me> with the value <avalue>.
100 Standard_EXPORT Units_Measurement Multiply (const Standard_Real avalue) const;
101 Units_Measurement operator * (const Standard_Real avalue) const
103 return Multiply(avalue);
106 //! Returns a measurement which is the division of <me> by
108 Standard_EXPORT Units_Measurement Divide (const Units_Measurement& ameasurement) const;
109 Units_Measurement operator / (const Units_Measurement& ameasurement) const
111 return Divide(ameasurement);
114 //! Returns a measurement which is the division of <me> by
115 //! the constant <avalue>.
116 Standard_EXPORT Units_Measurement Divide (const Standard_Real avalue) const;
117 Units_Measurement operator / (const Standard_Real avalue) const
119 return Divide(avalue);
122 //! Returns a measurement which is <me> powered
124 Standard_EXPORT Units_Measurement Power (const Standard_Real anexponent) const;
126 Standard_EXPORT Standard_Boolean HasToken() const;
128 //! Useful for debugging.
129 Standard_EXPORT void Dump() const;
144 Standard_Real themeasurement;
145 Handle(Units_Token) thetoken;
146 Standard_Boolean myHasToken;
157 #endif // _Units_Measurement_HeaderFile