Changeset 104 for trunk/include
- Timestamp:
- Oct 14, 2005, 9:43:27 AM (19 years ago)
- Location:
- trunk/include
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/cee/RpUnitsCInterface.h
r93 r104 17 17 18 18 // unit definition functions 19 RpUnits* rpDefineUnit ( const char* unitSymbol, RpUnits* basis ); 19 const RpUnits* rpDefineUnit ( const char* unitSymbol, 20 const RpUnits* basis ); 20 21 21 22 // conversion definition functions 22 RpUnits* rpDefineConv (RpUnits* fromUnit,23 RpUnits* toUnit,23 const RpUnits* rpDefineConv ( const RpUnits* fromUnit, 24 const RpUnits* toUnit, 24 25 double (*convForwFxnPtr)(double), 25 26 double (*convBackFxnPtr)(double) ); 26 27 27 28 // unit attribute access functions 28 const char* rpGetUnits ( RpUnits* unit );29 const char* rpGetUnits ( const RpUnits* unit ); 29 30 30 const char* rpGetUnitsName ( RpUnits* unit );31 const char* rpGetUnitsName ( const RpUnits* unit ); 31 32 32 double rpGetExponent ( RpUnits* unit );33 double rpGetExponent ( const RpUnits* unit ); 33 34 34 RpUnits* rpGetBasis (RpUnits* unit);35 const RpUnits* rpGetBasis ( const RpUnits* unit); 35 36 36 RpUnits* rpFind( const char* unitSymbol);37 const RpUnits* rpFind ( const char* unitSymbol); 37 38 38 int rpMakeMetric ( RpUnits* basis );39 int rpMakeMetric ( const RpUnits* basis ); 39 40 40 41 // convert functions … … 50 51 int* result ); 51 52 52 const char* rpConvert_ObjStr ( RpUnits* fromUnits,53 RpUnits* toUnits,53 const char* rpConvert_ObjStr ( const RpUnits* fromUnits, 54 const RpUnits* toUnits, 54 55 double val, 55 56 int showUnits, … … 60 61 int* result ); 61 62 62 double rpConvert_ObjDbl ( RpUnits* fromUnits,63 RpUnits* toUnits,63 double rpConvert_ObjDbl ( const RpUnits* fromUnits, 64 const RpUnits* toUnits, 64 65 double val, 65 66 int* result ); -
trunk/include/core/RpBindingsDict.h
r97 r104 41 41 42 42 RpLibrary* getObject_Lib(int objKey); 43 RpUnits* getObject_UnitsStr(int objKey);43 const RpUnits* getObject_UnitsStr(int objKey); 44 44 45 45 void cleanLibDict(); -
trunk/include/core/RpNumber.h
r38 r104 22 22 { 23 23 public: 24 24 25 25 // users member fxns 26 26 … … 51 51 int* result = NULL ); 52 52 double convert(std::string toUnitStr, int* result = NULL); 53 double convert( RpUnits* toUnit, int* result = NULL);54 53 double convert(const RpUnits* toUnit, int* result = NULL); 54 55 55 // place the information from this object into the xml library 'lib' 56 56 // virtual RpNumber& put(RpLibrary lib); 57 57 // RpNumber& put() const; 58 58 59 60 59 61 /* 60 61 /* 62 62 * user provides a 'path' for where this object lives in xml file 63 63 * user calls define with standard hints as described in Number docs … … 78 78 * 79 79 * 80 * 80 * 81 81 */ 82 82 83 83 /* what about unit-less numbers */ 84 84 RpNumber ( … … 135 135 136 136 } 137 137 138 138 // copy constructor 139 139 RpNumber ( const RpNumber& myRpNumber ) … … 155 155 156 156 // std::string units; 157 RpUnits* units;157 const RpUnits* units; 158 158 double min; 159 159 double max; -
trunk/include/core/RpUnits.h
r83 r104 36 36 const std::string getUnits(){ return units; }; 37 37 double getExponent() {return exponent;}; 38 RpUnits * getBasis() {return basis;};38 const RpUnits * getBasis() {return basis;}; 39 39 40 40 friend class RpUnits; … … 43 43 const std::string units; 44 44 double exponent; 45 RpUnits* basis;45 const RpUnits* basis; 46 46 47 47 unit* prev; … … 52 52 const std::string& units, 53 53 double& exponent, 54 RpUnits*basis,54 const RpUnits* basis, 55 55 unit* next 56 56 ) … … 109 109 private: 110 110 111 RpUnits* fromPtr;112 RpUnits* toPtr;111 const RpUnits* fromPtr; 112 const RpUnits* toPtr; 113 113 double (*convForwFxnPtr)(double); 114 114 double (*convBackFxnPtr)(double); 115 double (*convForwFxnPtrDD)(double,double); 116 double (*convBackFxnPtrDD)(double,double); 115 117 void* (*convForwFxnPtrVoid)(void*, void*); 116 118 void* convForwData; … … 125 127 // create a conversion 126 128 conversion ( 127 RpUnits* fromPtr,128 RpUnits* toPtr,129 const RpUnits* fromPtr, 130 const RpUnits* toPtr, 129 131 double (*convForwFxnPtr)(double), 130 132 double (*convBackFxnPtr)(double), … … 136 138 convForwFxnPtr (convForwFxnPtr), 137 139 convBackFxnPtr (convBackFxnPtr), 140 convForwFxnPtrDD (NULL), 141 convBackFxnPtrDD (NULL), 138 142 convForwFxnPtrVoid (NULL), 139 143 convForwData (NULL), … … 145 149 146 150 conversion ( 147 RpUnits* fromPtr, 148 RpUnits* toPtr, 151 const RpUnits* fromPtr, 152 const RpUnits* toPtr, 153 double (*convForwFxnPtr)(double,double), 154 double (*convBackFxnPtr)(double,double), 155 conversion* prev, 156 conversion* next 157 ) 158 : fromPtr (fromPtr), 159 toPtr (toPtr), 160 convForwFxnPtr (NULL), 161 convBackFxnPtr (NULL), 162 convForwFxnPtrDD (convForwFxnPtr), 163 convBackFxnPtrDD (convBackFxnPtr), 164 convForwFxnPtrVoid (NULL), 165 convForwData (NULL), 166 convBackFxnPtrVoid (NULL), 167 convBackData (NULL), 168 prev (prev), 169 next (next) 170 {}; 171 172 conversion ( 173 const RpUnits* fromPtr, 174 const RpUnits* toPtr, 149 175 void* (*convForwFxnPtrVoid)(void*, void*), 150 176 void* convForwData, … … 158 184 convForwFxnPtr (NULL), 159 185 convBackFxnPtr (NULL), 186 convForwFxnPtrDD (NULL), 187 convBackFxnPtrDD (NULL), 160 188 convForwFxnPtrVoid (convForwFxnPtrVoid), 161 189 convForwData (convForwData), … … 218 246 219 247 // users member fxns 220 std::string getUnits() ;221 std::string getUnitsName() ;222 double getExponent() ;223 RpUnits* getBasis();248 std::string getUnits() const; 249 std::string getUnitsName() const; 250 double getExponent() const; 251 const RpUnits* getBasis() const; 224 252 225 253 // convert from one RpUnits to another if the conversion is defined 226 double convert(RpUnits* toUnits, double val, int* result = NULL); 254 double convert( const RpUnits* toUnits, 255 double val, 256 int* result=NULL ) const; 227 257 // convert from one RpUnits to another if the conversion is defined 228 void* convert(RpUnits* toUnits, void* val, int* result = NULL); 258 void* convert( const RpUnits* toUnits, 259 void* val, 260 int* result=NULL) const; 229 261 // convert from one RpUnits to another if the conversion is defined 230 double convert(std::string, double val);262 // double convert(std::string, double val); 231 263 // convert from one RpUnits to another if the conversion is defined 232 std::string convert ( RpUnits* toUnits,264 std::string convert ( const RpUnits* toUnits, 233 265 double val, 234 266 int showUnits = 0, 235 int* result = NULL ) ;267 int* result = NULL ) const; 236 268 237 269 static std::string convert ( std::string val, … … 246 278 // this should only be used for units that are part of the 247 279 // metric system. doesnt deal with exponents, just prefixes 248 double makeBasis(double value, int* result = NULL) ;249 RpUnits & makeBasis(double* value, int* result = NULL);250 251 static int makeMetric( RpUnits * basis);280 double makeBasis(double value, int* result = NULL) const; 281 const RpUnits & makeBasis(double* value, int* result = NULL) const; 282 283 static int makeMetric(const RpUnits * basis); 252 284 253 285 // find a RpUnits object that should exist in RpUnitsTable 254 286 // returns 0 on success (object was found) 255 287 // returns !0 on failure (object not found) 256 static RpUnits* find(std::string key) 257 { 258 // dict.find seems to return a (RpUnits* const) so i had to 259 // cast it as a (RpUnits*) 260 261 // dict pointer 262 RpUnits* unitEntry = (RpUnits*) *(dict->find(key).getValue()); 263 264 // dict pointer 265 if (unitEntry == (RpUnits*)dict->getNullEntry().getValue()) { 266 unitEntry = NULL; 267 } 268 269 return unitEntry; 270 }; 288 static const RpUnits* find(std::string key); 271 289 272 290 // user calls define to add a RpUnits object or to add a relation rule 273 291 // 274 292 // add RpUnits Object 275 static RpUnits * define(const std::string units, RpUnits * basis); 276 static RpUnits * defineCmplx(const std::string units,RpUnits * basis); 293 static RpUnits * define(const std::string units, 294 const RpUnits* basis); 295 static RpUnits * defineCmplx( const std::string units, 296 const RpUnits* basis); 277 297 // 278 298 // add relation rule 279 299 280 static RpUnits * define( RpUnits* from,281 RpUnits* to,300 static RpUnits * define(const RpUnits* from, 301 const RpUnits* to, 282 302 double (*convForwFxnPtr)(double), 283 303 double (*convBackFxnPtr)(double)); 284 304 285 static RpUnits * define(RpUnits* from, 286 RpUnits* to, 305 static RpUnits * define(const RpUnits* from, 306 const RpUnits* to, 307 double (*convForwFxnPtr)(double,double), 308 double (*convBackFxnPtr)(double,double)); 309 310 static RpUnits * define(const RpUnits* from, 311 const RpUnits* to, 287 312 void* (*convForwFxnPtr)(void*, void*), 288 313 void* convForwData, … … 297 322 // "temp" load units related to temperature 298 323 // "time" load units related to time 324 // "volume" load units related to volume 299 325 // (no other groups have been created) 300 326 … … 384 410 385 411 // linked list of units this RpUnit can convert to 386 convEntry* convList; 412 // its mutable because the connectConversion function takes in a 413 // const RpUnits* and attempts to change the convList variable 414 // within the RpUnits Object 415 mutable convEntry* convList; 387 416 388 417 // used by the RpUnits when defining conversion elements … … 405 434 const std::string& units, 406 435 double& exponent, 407 RpUnits* basis436 const RpUnits* basis 408 437 ) 409 438 : head ( new unit( units, exponent, basis, NULL) ), … … 418 447 419 448 RpUnits ( 420 RpUnits* from,421 RpUnits* to,449 const RpUnits* from, 450 const RpUnits* to, 422 451 double (*convForwFxnPtr)(double), 423 452 double (*convBackFxnPtr)(double), … … 435 464 436 465 437 438 439 440 466 RpUnits ( 441 RpUnits* from, 442 RpUnits* to, 467 const RpUnits* from, 468 const RpUnits* to, 469 double (*convForwFxnPtr)(double,double), 470 double (*convBackFxnPtr)(double,double), 471 conversion* prev, 472 conversion* next 473 ) 474 : head (NULL), 475 convList (NULL), 476 conv (new conversion 477 (from,to,convForwFxnPtr,convBackFxnPtr,prev,next)) 478 { 479 connectConversion(from); 480 connectConversion(to); 481 }; 482 483 484 485 RpUnits ( 486 const RpUnits* from, 487 const RpUnits* to, 443 488 void* (*convForwFxnPtr)(void*, void*), 444 489 void* convForwData, … … 475 520 } 476 521 477 void RpUnits::connectConversion( RpUnits* myRpUnit);522 void RpUnits::connectConversion(const RpUnits* myRpUnit); 478 523 479 524 void RpUnits::fillMetricMap(); … … 495 540 496 541 497 static int pre_compare( std::string& units, RpUnits* basis = NULL); 542 static int pre_compare( std::string& units, 543 const RpUnits* basis = NULL); 544 498 545 void addUnit( const std::string& units, 499 546 double & exponent, 500 RpUnits * basis547 const RpUnits * basis 501 548 ); 502 549 … … 506 553 static int addPresetTemp(); 507 554 static int addPresetTime(); 555 static int addPresetVolume(); 508 556 509 557 -
trunk/include/core/RpUnitsStd.h
r68 r104 4 4 #endif 5 5 6 double centi2base (double centi); 7 double milli2base (double milli); 8 double micro2base (double micro); 9 double nano2base (double nano); 10 double pico2base (double pico); 11 double femto2base (double femto); 12 double atto2base (double atto); 13 double kilo2base (double kilo); 14 double mega2base (double mega); 15 double giga2base (double giga); 16 double tera2base (double tera); 17 double peta2base (double peta); 18 19 20 double base2centi (double base); 21 double base2milli (double base); 22 double base2micro (double base); 23 double base2nano (double base); 24 double base2pico (double base); 25 double base2femto (double base); 26 double base2atto (double base); 27 double base2kilo (double base); 28 double base2mega (double base); 29 double base2giga (double base); 30 double base2tera (double base); 31 double base2peta (double base); 6 double centi2base (double centi, double power); 7 double milli2base (double milli, double power); 8 double micro2base (double micro, double power); 9 double nano2base (double nano, double power); 10 double pico2base (double pico, double power); 11 double femto2base (double femto, double power); 12 double atto2base (double atto, double power); 13 double kilo2base (double kilo, double power); 14 double mega2base (double mega, double power); 15 double giga2base (double giga, double power); 16 double tera2base (double tera, double power); 17 double peta2base (double peta, double power); 32 18 33 19 34 20 35 double angstrom2meter (double angstrom); 36 double meter2angstrom (double meters); 37 double meter2inch (double m); 38 double inch2meter (double in); 39 double meter2feet (double m); 40 double feet2meter (double ft); 41 double meter2yard (double m); 42 double yard2meter (double yd); 21 double base2centi (double base, double power); 22 double base2milli (double base, double power); 23 double base2micro (double base, double power); 24 double base2nano (double base, double power); 25 double base2pico (double base, double power); 26 double base2femto (double base, double power); 27 double base2atto (double base, double power); 28 double base2kilo (double base, double power); 29 double base2mega (double base, double power); 30 double base2giga (double base, double power); 31 double base2tera (double base, double power); 32 double base2peta (double base, double power); 33 34 35 36 double angstrom2meter (double angstrom, double power); 37 double meter2angstrom (double meters, double power); 38 double meter2inch (double m, double power); 39 double inch2meter (double in, double power); 40 double meter2feet (double m, double power); 41 double feet2meter (double ft, double power); 42 double meter2yard (double m, double power); 43 double yard2meter (double yd, double power); 43 44 44 45 … … 62 63 63 64 65 double cubicMeter2usGallon (double m3, double none); 66 double usGallon2cubicMeter (double g, double none); 67 double cubicFeet2usGallon (double ft3, double none); 68 double usGallon2cubicFeet (double g, double none); 64 69 65 70
Note: See TracChangeset
for help on using the changeset viewer.