00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef INC_MI32_UOM_H
00034 #define INC_MI32_UOM_H
00035
00036 #ifndef INC_MI32_IDENTIFIER_H
00037 #include <mi32/identifier.h>
00038 #endif
00039
00040 #ifndef INC_MI32_MISTRING_H
00041 #include <mi32/mistring.h>
00042 #endif
00043
00044 #ifndef INC_MI32_MILIST_H
00045 #include <mi32/milist.h>
00046 #endif
00047
00048 #ifdef GEOMDLL
00049 #define CLASSLIBEXPORT MI_DLLCLASSEXPORT
00050 #else
00051 #define CLASSLIBEXPORT MI_DLLCLASSIMPORT
00052 #endif
00053
00054 namespace UOM {
00055
00056 #ifndef GENERATING_DOXYGEN_OUTPUT
00057 class SYSTEM;
00058 class MEASURE;
00059 class UNIT;
00060 class CONVERTER;
00061 class MEASURE_PRIV;
00062 class UNIT_PRIV;
00063 class CONVERTER_PRIV;
00064 #endif // GENERATING_DOXYGEN_OUTPUT
00065
00066
00067
00068
00069
00070 class CLASSLIBEXPORT UNIT {
00071 public:
00072
00073 enum NAMEUSAGE {
00074 NAMEUSAGE_Singular,
00075 NAMEUSAGE_Plural
00076 };
00077
00078
00079 UNIT (
00080 );
00081
00082
00083 UNIT (
00084 const UNIT& rhs
00085 );
00086
00087 #ifndef GENERATING_DOXYGEN_OUTPUT
00088
00089 UNIT (
00090 UNIT_PRIV *pPriv
00091 );
00092 #endif // GENERATING_DOXYGEN_OUTPUT
00093
00094
00095 ~UNIT (
00096 );
00097
00098
00099 UNIT& operator= (
00100 const UNIT& rhs
00101 );
00102
00103
00104 double ConvertFromBase (
00105 double inval
00106 ) const;
00107
00108
00109 void ConvertFromBase (
00110 double inval,
00111 MISTRING& outstr
00112 ) const;
00113
00114
00115 double ConvertToBase (
00116 double inval
00117 ) const;
00118
00119
00120 double ConvertToBase (
00121 const MISTRING& instr
00122 ) const;
00123
00124
00125 double GetFactorA (
00126 ) const;
00127
00128
00129 double GetFactorB (
00130 ) const;
00131
00132
00133 double GetFactorC (
00134 ) const;
00135
00136
00137 const IDENTIFIERLIST& GetIdList (
00138 ) const;
00139
00140
00141 int GetIdNum (
00142 ) const;
00143
00144
00145 const MEASURE& GetMeasure (
00146 ) const;
00147
00148
00149 const MISTRING& GetName (
00150 NAMEUSAGE nameusage
00151 ) const;
00152
00153
00154 const MISTRING& GetSymbol (
00155 ) const;
00156
00157
00158 bool IsEqual (
00159 const UNIT& rhs
00160 ) const;
00161
00162
00163
00164 bool IsString (
00165 ) const;
00166
00167 private:
00168 #ifndef GENERATING_DOXYGEN_OUTPUT
00169 UNIT_PRIV *m_pPriv;
00170 friend class MEASURE_PRIV;
00171 #endif // GENERATING_DOXYGEN_OUTPUT
00172
00173 };
00174
00175
00176 inline bool operator== (
00177 const UNIT& lhs,
00178 const UNIT& rhs
00179 ) { return (lhs.IsEqual(rhs)); }
00180
00181
00182 inline bool operator!= (
00183 const UNIT& lhs,
00184 const UNIT& rhs
00185 ) { return (!lhs.IsEqual(rhs)); }
00186
00187
00188
00189
00190
00191
00192
00193
00194 typedef MILIST<UNIT> UNITLIST;
00195
00196
00197
00198
00199
00200 class CLASSLIBEXPORT MEASURE {
00201 public:
00202
00203
00204
00205
00206 enum TYPE {
00207 TYPE_Area = 1,
00208 TYPE_Length = 2,
00209 TYPE_Distance = TYPE_Length,
00210 TYPE_PlaneAngle = 3,
00211 TYPE_Time = 4,
00212 TYPE_Temperature = 5,
00213 TYPE_Volume = 6,
00214 TYPE_Mass = 7,
00215 TYPE_Current = 8,
00216 TYPE_Amount = 9,
00217 TYPE_LuminousIntensity = 10,
00218 TYPE_SolidAngle = 11,
00219 TYPE_Velocity = 12,
00220 TYPE_Acceleration = 13,
00221 TYPE_VolumetricFlowRate = 14,
00222 TYPE_MassFlowRate = 15,
00223 TYPE_WaveNumber = 16,
00224 TYPE_Density = 17,
00225 TYPE_SpecificVolume = 18,
00226 TYPE_CurrentDensity = 19,
00227 TYPE_MagneticFieldStrength = 20,
00228 TYPE_Concentration = 21,
00229 TYPE_Luminance = 22,
00230 TYPE_Frequency = 23,
00231 TYPE_Force = 24,
00232 TYPE_Pressure = 25,
00233 TYPE_Energy = 26,
00234 TYPE_Power = 27,
00235 TYPE_ElectricCharge = 28,
00236 TYPE_ElectricPotential = 29,
00237 TYPE_Capacitance = 30,
00238 TYPE_ElectricResistance = 31,
00239 TYPE_ElectricConductance = 31,
00240 TYPE_MagneticFlux = 33,
00241 TYPE_MagneticFluxDensity = 34,
00242 TYPE_Inductance = 35,
00243 TYPE_LuminousFlux = 36,
00244 TYPE_RadionuclideActivity = 37,
00245 TYPE_AbsorbedDose = 38,
00246 TYPE_DoseEquivalent = 39,
00247 TYPE_DynamicViscosity = 40,
00248 TYPE_MomentOfForce = 41,
00249 TYPE_SurfaceTension = 42,
00250 TYPE_Irradiance = 43,
00251 TYPE_Entropy = 44,
00252 TYPE_SpecificHeatCapacity = 45,
00253 TYPE_SpecificEnergy = 46,
00254 TYPE_ThermalConductivity = 47,
00255 TYPE_EnergyDensity = 48,
00256 TYPE_ElectricFieldStrength = 49,
00257 TYPE_ElectricChargeDensity = 50,
00258 TYPE_ElectricFluxDensity = 51,
00259 TYPE_Permitivity = 52,
00260 TYPE_Permeability = 53,
00261 TYPE_MolarEnergy = 54,
00262 TYPE_MolarEntropy = 55,
00263 TYPE_Exposure = 56,
00264 TYPE_AbsorbedDoseRate = 57,
00265 TYPE_AngularVelocity = 58,
00266 TYPE_AngularAcceleration = 59,
00267 TYPE_RadiantIntensity = 60,
00268 TYPE_Radiance = 61,
00269 TYPE_Scale = 62,
00270 TYPE_Image = 63,
00271
00272 TYPE_LASTNONDATE = 63,
00273
00274 TYPE_Date = 99,
00275 TYPE_None = 255
00276 };
00277
00278
00279 MEASURE (
00280 );
00281
00282
00283 MEASURE (
00284 const MEASURE& rhs
00285 );
00286
00287 #ifndef GENERATING_DOXYGEN_OUTPUT
00288
00289 MEASURE (
00290 MEASURE_PRIV *pPriv
00291 );
00292 #endif // GENERATING_DOXYGEN_OUTPUT
00293
00294
00295 ~MEASURE (
00296 );
00297
00298
00299 MEASURE& operator= (
00300 const MEASURE& rhs
00301 );
00302
00303
00304
00305 bool FindUnit (
00306 int micode,
00307 UNIT& unitret
00308 ) const;
00309
00310
00311
00312 bool FindUnit (
00313 const IDENTIFIER& identifier,
00314 UNIT& unitret
00315 ) const;
00316
00317
00318
00319
00320 bool FindUnit (
00321 const MISTRING& name,
00322 UNIT& unitret
00323 ) const;
00324
00325
00326
00327 const UNIT& GetBaseUnit (
00328 ) const;
00329
00330
00331 const IDENTIFIERLIST& GetIdList (
00332 ) const;
00333
00334
00335 const MISTRING& GetName (
00336 ) const;
00337
00338
00339 TYPE GetType (
00340 ) const;
00341
00342
00343 const UNITLIST& GetUnitList (
00344 ) const;
00345
00346 private:
00347 #ifndef GENERATING_DOXYGEN_OUTPUT
00348 MEASURE_PRIV *m_pPriv;
00349 #endif // GENERATING_DOXYGEN_OUTPUT
00350
00351 };
00352
00353
00354
00355 inline bool operator== (
00356 const MEASURE& lhs,
00357 const MEASURE& rhs
00358 ) { return (lhs.GetType() == rhs.GetType()); }
00359
00360
00361 inline bool operator!= (
00362 const MEASURE& lhs,
00363 const MEASURE& rhs
00364 ) { return (lhs.GetType() != rhs.GetType()); }
00365
00366
00367
00368
00369
00370
00371
00372
00373 typedef MILIST<MEASURE> MEASURELIST;
00374
00375
00376
00377
00378 class CLASSLIBEXPORT SYSTEM {
00379 public:
00380
00381
00382
00383 static bool FindMeasure (
00384 const IDENTIFIER& identifier,
00385 MEASURE& measure
00386 );
00387
00388
00389
00390 static bool FindMeasure (
00391 MEASURE::TYPE type,
00392 MEASURE& measure
00393 );
00394
00395
00396
00397
00398 static bool FindUnit (
00399 int micode,
00400 UNIT& unitret
00401 );
00402
00403
00404
00405 static bool FindUnit (
00406 MEASURE::TYPE type,
00407 int micode,
00408 UNIT& unitret
00409 );
00410
00411
00412
00413 static bool FindUnit (
00414 const IDENTIFIER& identifier,
00415 UNIT& unitret
00416 );
00417
00418
00419
00420 static bool FindUnit (
00421 MEASURE::TYPE type,
00422 const IDENTIFIER& identifier,
00423 UNIT& unitret
00424 );
00425
00426
00427
00428
00429 static bool FindUnit (
00430 MEASURE::TYPE type,
00431 const MISTRING& name,
00432 UNIT& unitret
00433 );
00434
00435
00436
00437 static const MEASURELIST& GetMeasureList (
00438 );
00439
00440
00441
00442 static ERRVALUE Initialize ();
00443 };
00444
00445
00446
00447
00448 class CLASSLIBEXPORT CONVERTER {
00449 public:
00450
00451
00452 CONVERTER (
00453 );
00454
00455
00456 CONVERTER (
00457 const CONVERTER& rhs
00458 );
00459
00460
00461 CONVERTER (
00462 const MEASURE& measure
00463 );
00464
00465
00466 ~CONVERTER ();
00467
00468
00469 CONVERTER& operator= (
00470 const CONVERTER& rhs
00471 );
00472
00473
00474
00475
00476 double ConvertForward (
00477 double value
00478 ) const;
00479
00480
00481
00482 ERRVALUE ConvertForward (
00483 const MISTRING& instr,
00484 double& outval
00485 ) const;
00486
00487
00488
00489 ERRVALUE ConvertForward (
00490 double inval,
00491 MISTRING& outstr
00492 ) const;
00493
00494
00495 ERRVALUE ConvertForward (
00496 const MISTRING& instr,
00497 MISTRING& outstr
00498 ) const;
00499
00500
00501
00502
00503 double ConvertInverse (
00504 double value
00505 ) const;
00506
00507
00508
00509 ERRVALUE ConvertInverse (
00510 const MISTRING& instr,
00511 double& outval
00512 ) const;
00513
00514
00515
00516 ERRVALUE ConvertInverse (
00517 double inval,
00518 MISTRING& outstr
00519 ) const;
00520
00521
00522 ERRVALUE ConvertInverse (
00523 const MISTRING& instr,
00524 MISTRING& outstr
00525 ) const;
00526
00527
00528 const MEASURE& GetMeasure (
00529 ) const;
00530
00531
00532 double GetScale (
00533 ) const;
00534
00535
00536 const UNIT& GetSourceUnit (
00537 ) const;
00538
00539
00540 const UNIT& GetTargetUnit (
00541 ) const;
00542
00543
00544
00545 void IniReadSource (
00546 INIHANDLE IniHandle,
00547 const char *IniGroup,
00548 const char *IniName,
00549 int micode = 0
00550 );
00551
00552
00553
00554 void IniReadTarget (
00555 INIHANDLE IniHandle,
00556 const char *IniGroup,
00557 const char *IniName,
00558 int micode = 0
00559 );
00560
00561
00562 void IniWriteSource (
00563 INIHANDLE IniHandle,
00564 const char *IniGroup,
00565 const char *IniName
00566 ) const;
00567
00568
00569 void IniWriteTarget (
00570 INIHANDLE IniHandle,
00571 const char *IniGroup,
00572 const char *IniName
00573 ) const;
00574
00575
00576
00577
00578 ERRVALUE SetSourceUnit (
00579 const UNIT& SourceUnit
00580 );
00581
00582
00583
00584
00585 ERRVALUE SetTargetUnit (
00586 const UNIT& TargetUnit
00587 );
00588
00589
00590
00591 ERRVALUE SetUnits (
00592 const UNIT& SourceUnit,
00593 const UNIT& TargetUnit
00594 );
00595
00596 private:
00597 #ifndef GENERATING_DOXYGEN_OUTPUT
00598 CONVERTER_PRIV *m_pPriv;
00599 void GetExclusive();
00600 #endif // GENERATING_DOXYGEN_OUTPUT
00601 };
00602
00603
00604 };
00605
00606
00607 typedef UOM::MEASURE::TYPE UNIT_TYPE;
00608
00609 #define UNIT_TYPE_Constant 0
00610 #define UNIT_TYPE_Area UOM::MEASURE::TYPE_Area
00611 #define UNIT_TYPE_Length UOM::MEASURE::TYPE_Length
00612 #define UNIT_TYPE_Distance UOM::MEASURE::TYPE_Distance
00613 #define UNIT_TYPE_PlaneAngle UOM::MEASURE::TYPE_PlaneAngle
00614 #define UNIT_TYPE_Time UOM::MEASURE::TYPE_Time
00615 #define UNIT_TYPE_Volume UOM::MEASURE::TYPE_Volume
00616 #define UNIT_TYPE_Velocity UOM::MEASURE::TYPE_Velocity
00617 #define UNIT_TYPE_Acceleration UOM::MEASURE::TYPE_Acceleration
00618 #define UNIT_TYPE_AngularVelocity UOM::MEASURE::TYPE_AngularVelocity
00619 #define UNIT_TYPE_Date UOM::MEASURE::TYPE_Date
00620 #define UNIT_TYPE_None UOM::MEASURE::TYPE_None
00621
00622
00623
00624
00625
00626 #define UNIT_Area_SquareMeter 0
00627 #define UNIT_Area_SquareMeters 0
00628 #define UNIT_Area_SquareKilometer 3
00629 #define UNIT_Area_SquareKilometers 3
00630 #define UNIT_Area_SquareMillimeter 2
00631 #define UNIT_Area_SquareMillimeters 2
00632
00633 #define UNIT_Length_Meter 0
00634 #define UNIT_Length_Kilometer 3
00635 #define UNIT_Length_Centimeter 1
00636 #define UNIT_Length_Millimeter 2
00637 #define UNIT_Length_Micrometer 8
00638 #define UNIT_Length_Nanometer 9
00639 #define UNIT_Length_Foot 4
00640 #define UNIT_Length_Inch 6
00641
00642 #define UNIT_Distance_Meters UNIT_Length_Meter
00643 #define UNIT_Distance_Kilometers UNIT_Length_Kilometer
00644 #define UNIT_Distance_Centimeters UNIT_Length_Centimeter
00645 #define UNIT_Distance_Millimeters UNIT_Length_Millimeter
00646 #define UNIT_Distance_Micrometers UNIT_Length_Micrometer
00647 #define UNIT_Distance_Nanometers UNIT_Length_Nanometer
00648 #define UNIT_Distance_Feet UNIT_Length_Foot
00649 #define UNIT_Distance_Inches UNIT_Length_Inch
00650
00651 #define UNIT_PlaneAngle_Degree 0
00652 #define UNIT_PlaneAngle_Degrees 0
00653 #define UNIT_PlaneAngle_Radian 1
00654 #define UNIT_PlaneAngle_Radians 1
00655
00656 #define UNIT_Time_Second 0
00657 #define UNIT_Time_Seconds 0
00658 #define UNIT_Time_Millisecond 6
00659 #define UNIT_Time_Milliseconds 6
00660 #define UNIT_Time_Microsecond 7
00661 #define UNIT_Time_Microseconds 7
00662
00663 #define UNIT_Volume_CubicMeter 0
00664 #define UNIT_Volume_CubicMeters 0
00665
00666 #undef CLASSLIBEXPORT
00667
00668 #endif