All Frameworks Class Hierarchy This Framework Previous Next Indexes
KnowledgeInterfaces Interface CATICkeUnit
System.IUnknown
|
+---System.IDispatch
|
+---System.CATBaseUnknown
|
+---CATICkeUnit
Usage: an implementation of this interface is supplied and you must use it as is. You should not reimplement it.
interface CATICkeUnit
Interface dedicated to unit management.
Role: This interface gives access to unit properties.
This interface is based on the International System Magnitude Management
called MKS.
Each magnitude has a default unit corresponding to the MKS System
for example : the default unit for length is meter
the default unit for weight is kilogram
etc...
All conversion methods are working with this MKS unit on one side
Usage :
#include "CATCkeParmFactory.h"
#include "CATICkeParmFactory.h"
#include "CATICkeUnit.h"
// imagine fact is the current parameter factory
// creation of a unit with multiplication factor between it and the
// MKS equal to 100
CATICkeUnit_var centimetre = fact->CreateUnit ("Centimetre","cm",100);
cout << centimetre->Name (); // returns "Centimetre"
cout << centimetre->Symbol (); // returns "cm"
cout << centimetre->Show (3); // returns "300 cm" as 3 is given in MKS
cout << centimetre->Convert (1); // returns 0.01 (m)
cout << centimetre->Value (1); // returns 100 (cm)
double d = 0;
Assume (centimetre->DecodeReal ("2 m",d) == CATCke::False); // returns 2
Assume (centimetre->DecodeReal ("203 cm",d) == CATCke::True); // returns 2.3
Assume (d == 2.3);
- See also:
- CATICkeMagnitude
Method Index
- o
Convert(double)
- Converts a real in this unit to MKS.
- o
DecodeReal(CATUnicodeString&,double&)
- Tries to decode a string (prefixed with unit or not) to a real.
- o
GetMagnitude()
- Returns the magnitude of the unit.
- o
InternalName()
- Returns the internal name of this unit.
- o
Name()
- Returns the NLS name of this unit.
- o
Show(double,int)
- Returns a string showing a real (in MKS) in this unit.
- o
ShowIso(double,int)
- Returns the value of the parameter in the current unit while respecting the ISO standard.
- o
Symbol()
- Returns the symbol of this unit.
- o
Value(double)
- Converts a real in MKS to this unit.
Methods
o Convert
public virtual double Convert( | const double | iValueInThisUnit) const =0 |
-
Converts a real in this unit to MKS.
- Parameters:
-
- const
- iValueInThisUnit value in this unit
- Returns:
- value converted in MKS
o DecodeReal
public virtual CATCke::Boolean DecodeReal( | const CATUnicodeString& | iStringToDecode, |
| double& | oValueInMKS) const =0 |
-
Tries to decode a string (prefixed with unit or not) to a real.
Example: Decode "3mm"
- Parameters:
-
- iStringToDecode
- string to be decoded.
- oValueInMKS
- the double in output is in MKS
- Returns:
-
Legal values: the test can be either 1 if successful in decoding.
0 if it isn't.
o GetMagnitude
-
Returns the magnitude of the unit. It may happen that a unit participate to several magnitudes.
In this case, only the first found will be returned.
- Returns:
- the magnitude of the unit
o InternalName
-
Returns the internal name of this unit.
Example: "Millimeter".
o Name
-
Returns the NLS name of this unit.
Example: "Millimeter".
o Show
public virtual CATUnicodeString Show( | const double | iValueInMKS, |
| const int | iNbDecimals | = 0) const =0 |
-
Returns a string showing a real (in MKS) in this unit.
Example: "2 cm".
- Parameters:
-
- iValueInMKS
- double in input is in MKS
- iNbDecimals
- number of decimals to use to show the number. If equal to zero, default nb of decimals
o ShowIso
public virtual CATUnicodeString ShowIso( | const double | iValue, |
| const int | iNbDecimals | = 0) const = 0 |
-
Returns the value of the parameter in the current unit while respecting the ISO standard.
- Parameters:
-
- iValue
- Value of the parameter.
- iNbDecimals
- Number of decimals to use to show the number. If equal to zero, the setting is used.
- Returns:
- The value of the parameter in the current unit while respecting the ISO standard,
i.e. : if the setting called "Decimal places for read/write numbers" (used for the display of units) = 3
and if the parameter's value in current unit (e.g. mm) = 0.001,
returns "0mm"
otherwise, if parameter's value in current unit (e.g. mm) = 0.001,
returns "0.001mm".
o Symbol
-
Returns the symbol of this unit.
Example: "mm"
o Value
public virtual double Value( | const double | iValueInMKS) const =0 |
-
Converts a real in MKS to this unit.
- Parameters:
-
- const
- iValueInMKS value in this unit
- Returns:
- value converted in this unit
This object is included in the file: CATICkeUnit.h
If needed, your Imakefile.mk should include the module: KnowledgeItf