42cf5bc1 |
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 |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
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. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _Units_HeaderFile |
18 | #define _Units_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <Standard_CString.hxx> |
25 | #include <Standard_Boolean.hxx> |
26 | #include <Standard_Real.hxx> |
27 | class Units_UnitsDictionary; |
28 | class Units_Quantity; |
29 | class Units_Lexicon; |
30 | class Units_Dimensions; |
31 | class Units_Dimensions; |
32 | class Units_Unit; |
33 | class Units_ShiftedUnit; |
34 | class Units_Token; |
35 | class Units_ShiftedToken; |
36 | class Units_Quantity; |
37 | class Units_UnitsDictionary; |
38 | class Units_UnitsSystem; |
39 | class Units_Explorer; |
40 | class Units_Sentence; |
41 | class Units_MathSentence; |
42 | class Units_UnitSentence; |
43 | class Units_Lexicon; |
44 | class Units_UnitsLexicon; |
45 | class Units_Measurement; |
46 | |
47 | |
48 | //! This package provides all the facilities to create |
49 | //! and question a dictionary of units, and also to |
50 | //! manipulate measurements which are real values with |
51 | //! units. |
52 | class Units |
53 | { |
54 | public: |
55 | |
56 | DEFINE_STANDARD_ALLOC |
57 | |
58 | |
59 | //! Defines the location of the file containing all the |
60 | //! information useful in creating the dictionary of all |
61 | //! the units known to the system. |
62 | Standard_EXPORT static void UnitsFile (const Standard_CString afile); |
63 | |
64 | //! Defines the location of the file containing the lexicon |
65 | //! useful in manipulating composite units. |
66 | Standard_EXPORT static void LexiconFile (const Standard_CString afile); |
67 | |
68 | //! Returns a unique instance of the dictionary of units. |
69 | //! If <amode> is True, then it forces the recomputation of |
70 | //! the dictionary of units. |
71 | Standard_EXPORT static Handle(Units_UnitsDictionary) DictionaryOfUnits (const Standard_Boolean amode = Standard_False); |
72 | |
73 | //! Returns a unique quantity instance corresponding to <aquantity>. |
74 | Standard_EXPORT static Handle(Units_Quantity) Quantity (const Standard_CString aquantity); |
75 | |
76 | //! Returns the first quantity string founded from the unit <aUnit>. |
77 | Standard_EXPORT static Standard_CString FirstQuantity (const Standard_CString aunit); |
78 | |
79 | //! Returns a unique instance of the Units_Lexicon. |
80 | //! If <amode> is True, it forces the recomputation of |
81 | //! the dictionary of units, and by consequence the |
82 | //! completion of the Units_Lexicon. |
83 | Standard_EXPORT static Handle(Units_Lexicon) LexiconUnits (const Standard_Boolean amode = Standard_True); |
84 | |
85 | //! Return a unique instance of LexiconFormula. |
86 | Standard_EXPORT static Handle(Units_Lexicon) LexiconFormula(); |
87 | |
88 | //! Returns always the same instance of Dimensions. |
89 | Standard_EXPORT static Handle(Units_Dimensions) NullDimensions(); |
90 | |
91 | //! Converts <avalue> expressed in <afirstunit> into the <asecondunit>. |
92 | Standard_EXPORT static Standard_Real Convert (const Standard_Real avalue, const Standard_CString afirstunit, const Standard_CString asecondunit); |
93 | |
94 | Standard_EXPORT static Standard_Real ToSI (const Standard_Real aData, const Standard_CString aUnit); |
95 | |
96 | Standard_EXPORT static Standard_Real ToSI (const Standard_Real aData, const Standard_CString aUnit, Handle(Units_Dimensions)& aDim); |
97 | |
98 | Standard_EXPORT static Standard_Real FromSI (const Standard_Real aData, const Standard_CString aUnit); |
99 | |
100 | Standard_EXPORT static Standard_Real FromSI (const Standard_Real aData, const Standard_CString aUnit, Handle(Units_Dimensions)& aDim); |
101 | |
102 | //! return the dimension associated to the Type |
103 | Standard_EXPORT static Handle(Units_Dimensions) Dimensions (const Standard_CString aType); |
104 | |
105 | |
106 | |
107 | |
108 | protected: |
109 | |
110 | |
111 | |
112 | |
113 | |
114 | private: |
115 | |
116 | |
117 | |
118 | |
119 | friend class Units_Dimensions; |
120 | friend class Units_Unit; |
121 | friend class Units_ShiftedUnit; |
122 | friend class Units_Token; |
123 | friend class Units_ShiftedToken; |
124 | friend class Units_Quantity; |
125 | friend class Units_UnitsDictionary; |
126 | friend class Units_UnitsSystem; |
127 | friend class Units_Explorer; |
128 | friend class Units_Sentence; |
129 | friend class Units_MathSentence; |
130 | friend class Units_UnitSentence; |
131 | friend class Units_Lexicon; |
132 | friend class Units_UnitsLexicon; |
133 | friend class Units_Measurement; |
134 | |
135 | }; |
136 | |
137 | |
138 | |
139 | |
140 | |
141 | |
142 | |
143 | #endif // _Units_HeaderFile |