#include <units.h>
Inheritance diagram for Unit:
Public Member Functions | |
Unit () | |
Default constructor for a unit. Adds the unit to the end of Unit::pUnitList. | |
~Unit () | |
Default destructor for a unit - does nothing. | |
BOOL | IsDefault () |
Find out if this is a default unit. | |
BOOL | SetDefaultState (BOOL State) |
Allows you to set/clear the default unit flag. Updated 4/9/95 to return the old state. | |
BOOL | IsPrefix () |
Find out whether unit specifier should be a prefix or suffix. | |
BOOL | SetPrefixState (BOOL State) |
Allows you to set/clear the Prefix flag Updated 4/9/95 to return the old state. | |
UnitType | GetUnitType () |
Returns the UnitType of this unit. | |
BOOL | SetUnitType (UnitType NewUnitType) |
Sets the UnitType for the unit. | |
double | GetMillipoints () |
Want the number of millipoints in a single instance of this unit? This is the call for you! | |
BOOL | SetMillipoints (double NewMillipoints) |
Lets you define exactly how big this unit is in the real world, not that we sad computer programmers have any idea what the "real world" is, even if it came up and generated pulses in a recognisable protocol on our ethernet cable. Updated 4/9/95 to return the True if can set the new state ok. | |
UnitType | GetBaseUnitType () |
Find out which unit this unit is based on. | |
BOOL | SetBaseUnitType (UnitType NewBaseUnitType) |
Lets you set that base unit type. Oh boy! Updated 4/9/95 to return the True if can set the new state ok. | |
double | GetBaseNumerator () |
Get the numerator of the fraction that defines how many BaseUnitTypes are in one of these units. Millipoints = (BaseNumerator/BaseDenominator)*BaseUnit->GetMillipoints();. | |
BOOL | SetBaseNumerator (double NewBaseNumerator) |
Sets the numerator of the fraction that defines how many BaseUnitTypes are in one of these units. Millipoints = (BaseNumerator/BaseDenominator)*BaseUnit->GetMillipoints(); Updated 4/9/95 to return the True if can set the new state ok. | |
double | GetBaseDenominator () |
Get the Denominator of the fraction that defines how many BaseUnitTypes are in one of these units. Millipoints = (BaseNumerator/BaseDenominator)*BaseUnit->GetMillipoints();. | |
BOOL | SetBaseDenominator (double NewBaseDenominator) |
Sets the Denominator of the fraction that defines how many BaseUnitTypes are in one of these units. Millipoints = (BaseNumerator/BaseDenominator)*BaseUnit->GetMillipoints(); Updated 4/9/95 to return the True if can set the new state ok. | |
String_32 | GetToken () |
Returns the token string which might be used in say a drop-down list of units. This is the full name of the unit in question E.g. "centimetres" specifies the default centimetres unit with the abbreviation or specifier of "cm". | |
BOOL | SetToken (const String_32 &NewToken) |
Sets the token string for the unit. This is the full name of the unit in question E.g. "centimetres" specifies the default centimetres unit with the abbreviation or specifier of "cm". This must not be blank and must not contain numbers as otherwise number parsing may be difficult. Hence, new units should be labelled with A, B .... Hence also, updated to return BOOL 4/9/95 so can return to the setter the fact that the new specifier cannot be allowed. | |
String_32 | GetSpecifier () |
Returns the Specifier string used in in ed fields when specifying units E.g. "cm" specifies centimetres. | |
BOOL | SetSpecifier (const String_32 &NewSpecifier) |
Sets the Specifier string for the unit. This is the abbreviation for the unit. E.g. "cm" specifies centimetres. Might be bad to allow blanks or duplicates of previosly defined specifiers. Hence, updated to return BOOL 4/9/95 so can return to the setter the fact that the new specifier cannot be allowed. | |
Static Public Member Functions | |
static BOOL | Init () |
Initialises the unit class MUST BE CALLED BEFORE ANY OTHER FUNCTION IN THIS CLASS Inits the list of units, defines all the default units and places them on the list. | |
static BOOL | Deinit () |
Deinitialises the unit class It scans Unit::pUnitList, removing and deleting all its members, then it destroys the list. | |
Private Attributes | |
UnitType | ThisUnitType |
double | Millipoints |
UnitFlagsType | Flags |
UnitType | BaseUnitType |
double | BaseNumerator |
double | BaseDenominator |
String_32 | Token |
String_32 | Specifier |
Definition at line 167 of file units.h.
|
Default constructor for a unit. Adds the unit to the end of Unit::pUnitList.
Definition at line 132 of file units.cpp.
|
|
Default destructor for a unit - does nothing.
Definition at line 149 of file units.cpp.
|
|
Deinitialises the unit class It scans Unit::pUnitList, removing and deleting all its members, then it destroys the list.
Definition at line 189 of file units.cpp. 00190 { 00191 return TRUE; 00192 }
|
|
Get the Denominator of the fraction that defines how many BaseUnitTypes are in one of these units. Millipoints = (BaseNumerator/BaseDenominator)*BaseUnit->GetMillipoints();.
Definition at line 430 of file units.cpp. 00431 { 00432 return BaseDenominator; 00433 }
|
|
Get the numerator of the fraction that defines how many BaseUnitTypes are in one of these units. Millipoints = (BaseNumerator/BaseDenominator)*BaseUnit->GetMillipoints();.
Definition at line 381 of file units.cpp. 00382 { 00383 return BaseNumerator; 00384 }
|
|
Find out which unit this unit is based on.
Definition at line 340 of file units.cpp. 00341 { 00342 return BaseUnitType; 00343 }
|
|
Want the number of millipoints in a single instance of this unit? This is the call for you!
Definition at line 293 of file units.cpp. 00294 { 00295 return Millipoints; 00296 }
|
|
Returns the Specifier string used in in ed fields when specifying units E.g. "cm" specifies centimetres.
Definition at line 535 of file units.cpp. 00536 { 00537 return Specifier; 00538 }
|
|
Returns the token string which might be used in say a drop-down list of units. This is the full name of the unit in question E.g. "centimetres" specifies the default centimetres unit with the abbreviation or specifier of "cm".
Definition at line 481 of file units.cpp. 00482 { 00483 return Token; 00484 }
|
|
Returns the UnitType of this unit.
Definition at line 614 of file units.cpp. 00615 { 00616 return ThisUnitType; 00617 }
|
|
Initialises the unit class MUST BE CALLED BEFORE ANY OTHER FUNCTION IN THIS CLASS Inits the list of units, defines all the default units and places them on the list.
Reimplemented from SimpleCCObject. Definition at line 169 of file units.cpp. 00170 { 00171 return TRUE; 00172 }
|
|
Find out if this is a default unit.
Definition at line 207 of file units.cpp. 00208 { 00209 // Cannot return the state of the flag directly as this is not BOOLEAN due to the 00210 // way bit arrays work. Only reliable test on this is FALSE == 0. 00211 return (Flags.DefaultUnit != 0); 00212 }
|
|
Find out whether unit specifier should be a prefix or suffix.
Definition at line 250 of file units.cpp. 00251 { 00252 // Cannot return the state of the flag directly as this is not BOOLEAN due to the 00253 // way bit arrays work. Only reliable test on this is FALSE == 0. 00254 return (Flags.Prefix != 0); 00255 }
|
|
Sets the Denominator of the fraction that defines how many BaseUnitTypes are in one of these units. Millipoints = (BaseNumerator/BaseDenominator)*BaseUnit->GetMillipoints(); Updated 4/9/95 to return the True if can set the new state ok.
Definition at line 451 of file units.cpp. 00452 { 00453 // Sanity checks 00454 // - ensure not zero otherwise just wait for those divide by zero errors! 00455 // - check for negative values as well as these will be bad 00456 if (NewBaseDenominator <= 0) 00457 return FALSE; 00458 00459 BaseDenominator = NewBaseDenominator; 00460 00461 return TRUE; 00462 }
|
|
Sets the numerator of the fraction that defines how many BaseUnitTypes are in one of these units. Millipoints = (BaseNumerator/BaseDenominator)*BaseUnit->GetMillipoints(); Updated 4/9/95 to return the True if can set the new state ok.
Definition at line 402 of file units.cpp. 00403 { 00404 // Sanity checks 00405 // - ensure not zero otherwise just wait for those divide by zero errors! 00406 // - check for negative values as well as these will be bad 00407 if (NewBaseNumerator <= 0) 00408 return FALSE; 00409 00410 BaseNumerator = NewBaseNumerator; 00411 00412 return TRUE; 00413 }
|
|
Lets you set that base unit type. Oh boy! Updated 4/9/95 to return the True if can set the new state ok.
Definition at line 359 of file units.cpp. 00360 { 00361 BaseUnitType = NewBaseUnitType; 00362 00363 return TRUE; 00364 }
|
|
Allows you to set/clear the default unit flag. Updated 4/9/95 to return the old state.
Definition at line 228 of file units.cpp. 00229 { 00230 BOOL OldState = (Flags.DefaultUnit != 0); 00231 Flags.DefaultUnit = State; 00232 00233 return OldState; 00234 }
|
|
Lets you define exactly how big this unit is in the real world, not that we sad computer programmers have any idea what the "real world" is, even if it came up and generated pulses in a recognisable protocol on our ethernet cable. Updated 4/9/95 to return the True if can set the new state ok.
Definition at line 314 of file units.cpp. 00315 { 00316 // Sanity checks 00317 // - ensure not zero otherwise just wait for those divide by zero errors! 00318 // - check for negative values as well as these will be bad 00319 if (NewMillipoints <= 0) 00320 return FALSE; 00321 00322 Millipoints = NewMillipoints; 00323 00324 return TRUE; 00325 }
|
|
Allows you to set/clear the Prefix flag Updated 4/9/95 to return the old state.
Definition at line 271 of file units.cpp. 00272 { 00273 BOOL OldState = (Flags.Prefix != 0); 00274 Flags.Prefix = State; 00275 00276 return OldState; 00277 }
|
|
Sets the Specifier string for the unit. This is the abbreviation for the unit. E.g. "cm" specifies centimetres. Might be bad to allow blanks or duplicates of previosly defined specifiers. Hence, updated to return BOOL 4/9/95 so can return to the setter the fact that the new specifier cannot be allowed.
Definition at line 558 of file units.cpp. 00559 { 00560 // Sanity checks 00561 // - ensure not zero length 00562 // - should really check for duplicates as unless we allow for overiding of preset units 00563 // - should check for dodgy characters such as numbers as these are very bad 00564 // - should check for the decimal point character and thousands separator 00565 INT32 LenNewSpecifier = NewSpecifier.Length(); 00566 if (LenNewSpecifier == 0) 00567 return FALSE; 00568 00569 // Check for the existance of numbers in the string. 00570 // At present, check for the prescence of the fixed decimal point and thousand separator 00571 // characters as no easy way of getting at the values in convert. 00572 String_32 CheckString( _T("0123456789.,") ); 00573 INT32 LenCheckString = CheckString.Length(); 00574 BOOL Found = FALSE; 00575 TCHAR CheckChar; 00576 // Now go through every character in the check string and see if it exists in 00577 // the required new specifier string 00578 for (INT32 i = 0; ( (i < LenNewSpecifier) && (!Found) ); i++) 00579 { 00580 // Get the next character to be checked in the new specifier string 00581 CheckChar = ((const TCHAR*)NewSpecifier)[i]; 00582 00583 // Now compare this against all the characters in the validation string 00584 for (INT32 j = 0; ( (j < LenCheckString) && (!Found) ); j++) 00585 { 00586 if (((TCHAR*)CheckString)[j] == CheckChar) 00587 { 00588 Found = TRUE; 00589 } 00590 } 00591 } 00592 // We found a problem character so return this result to the caller 00593 if (Found) 00594 return FALSE; 00595 00596 Specifier = NewSpecifier; 00597 00598 return TRUE; 00599 }
|
|
Sets the token string for the unit. This is the full name of the unit in question E.g. "centimetres" specifies the default centimetres unit with the abbreviation or specifier of "cm". This must not be blank and must not contain numbers as otherwise number parsing may be difficult. Hence, new units should be labelled with A, B .... Hence also, updated to return BOOL 4/9/95 so can return to the setter the fact that the new specifier cannot be allowed.
Definition at line 507 of file units.cpp. 00508 { 00509 // Sanity checks 00510 // - ensure not zero length 00511 // - should really check for duplicates as unless we allow for overiding of preset units 00512 // - should check for dodgy characters such as numbers as these may be very bad 00513 if (NewToken.Length() == 0) 00514 return FALSE; 00515 00516 Token = NewToken; 00517 00518 return TRUE; 00519 }
|
|
Sets the UnitType for the unit.
Definition at line 632 of file units.cpp. 00633 { 00634 ThisUnitType = NewUnitType; 00635 00636 return TRUE; 00637 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|