Changeset 104


Ignore:
Timestamp:
Oct 14, 2005 9:43:27 AM (19 years ago)
Author:
dkearney
Message:

This update brings us one step closer to being const correct in the RpUnits
class. Added a few more comments. All other files touched were made to
comply with the new const correct RpUnits.[h,cc]

Location:
trunk
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/examples/c-example/Makefile

    r92 r104  
    1818INCL_RP_DEPS    = -I $(RP_BASE)/include
    1919
     20INCL_FILES      = $(INCL_CEE) $(INCL_CORE) $(INCL_RP_DEPS)
     21
    2022LIB_DIR         = $(RP_BASE)/lib
    2123LIB_INC_PREFIX  = -Wl,-rpath,$(LIB_DIR) -L$(LIB_DIR)
     
    2527
    2628plot: plot.cc
    27         $(CXX) $(DEBUG) -DDEBUG $(INCL_CEE) $(INCL_CORE) $(INCL_RP_DEPS) -o $@ $< $(LIB_RAPPTURE)
     29        $(CXX) $(DEBUG) -DDEBUG $(INCL_FILES) -o $@ $< $(LIB_RAPPTURE)
    2830
    2931plotc: plotc.c
    30         $(CC) $(DEBUG) -DDEBUG $(INCL_CEE) $(INCL_CORE) $(INCL_RP_DEPS) -o $@ $< $(LIB_RAPPTURE)
     32        $(CC) $(DEBUG) -DDEBUG $(INCL_FILES) -o $@ $< $(LIB_RAPPTURE) -lm
    3133
    3234#### CLEAN UP ############################################################
  • trunk/examples/c-example/plotc.c

    r93 r104  
    11#include "RpLibraryCInterface.h"
    22
    3 //#include <stdlib.h>
     3#include <stdlib.h>
    44#include <string.h>
    55#include <stdio.h>
     6#include <math.h>
    67
    78int main(int argc, char * argv[])
     
    1011    RpLibrary* lib = NULL;
    1112
    12     char* filePath;
    13     char* xmltext = NULL;
     13    const char* filePath;
     14    const char* xmltext = NULL;
    1415    double fmin, fmax;
    1516    char strFormula[100];
     
    4243        // cannot open file or out of memory
    4344        printf("FAILED creating Rappture Library\n");
    44         exit(1);
     45        return(1);
    4546    }
    4647
     
    5455    else {
    5556        printf("xml(lib) failed\n");
    56         exit(1);
     57        return(1);
    5758    }
    5859
     
    6263    if (! (xmltext) ) {
    6364        printf("getString(lib,input.number(xmin).current) returns null\n");
    64         exit(1);
     65        return(1);
    6566    }
    6667
  • trunk/examples/fermi_fortran/Makefile

    r73 r104  
    4949#### CLEAN UP ############################################################
    5050clean:
    51         - rm -f ${PROGS}
     51        - rm -f ${PROGS} run*.xml
  • trunk/include/cee/RpUnitsCInterface.h

    r93 r104  
    1717
    1818    // unit definition functions
    19     RpUnits* rpDefineUnit        ( const char* unitSymbol, RpUnits* basis );
     19    const RpUnits* rpDefineUnit  ( const char* unitSymbol,
     20                                   const RpUnits* basis );
    2021
    2122    // conversion definition functions
    22     RpUnits* rpDefineConv        ( RpUnits* fromUnit,
    23                                    RpUnits* toUnit,
     23    const RpUnits* rpDefineConv  ( const RpUnits* fromUnit,
     24                                   const RpUnits* toUnit,
    2425                                   double (*convForwFxnPtr)(double),
    2526                                   double (*convBackFxnPtr)(double)    );
    2627
    2728    // unit attribute access functions
    28     const char* rpGetUnits       ( RpUnits* unit );
     29    const char* rpGetUnits       ( const RpUnits* unit );
    2930
    30     const char* rpGetUnitsName   ( RpUnits* unit );
     31    const char* rpGetUnitsName   ( const RpUnits* unit );
    3132
    32     double rpGetExponent         ( RpUnits* unit );
     33    double rpGetExponent         ( const RpUnits* unit );
    3334
    34     RpUnits* rpGetBasis          ( RpUnits* unit);
     35    const RpUnits* rpGetBasis    ( const RpUnits* unit);
    3536
    36     RpUnits* rpFind              ( const char* unitSymbol);
     37    const RpUnits* rpFind        ( const char* unitSymbol);
    3738
    38     int rpMakeMetric             ( RpUnits* basis );
     39    int rpMakeMetric             ( const RpUnits* basis );
    3940
    4041    // convert functions
     
    5051                                   int* result );
    5152
    52     const char* rpConvert_ObjStr ( RpUnits* fromUnits,
    53                                    RpUnits* toUnits,
     53    const char* rpConvert_ObjStr ( const RpUnits* fromUnits,
     54                                   const RpUnits* toUnits,
    5455                                   double val,
    5556                                   int showUnits,
     
    6061                                   int* result );
    6162
    62     double rpConvert_ObjDbl      ( RpUnits* fromUnits,
    63                                    RpUnits* toUnits,
     63    double rpConvert_ObjDbl      ( const RpUnits* fromUnits,
     64                                   const RpUnits* toUnits,
    6465                                   double val,
    6566                                   int* result );
  • trunk/include/core/RpBindingsDict.h

    r97 r104  
    4141
    4242RpLibrary* getObject_Lib(int objKey);
    43 RpUnits* getObject_UnitsStr(int objKey);
     43const RpUnits* getObject_UnitsStr(int objKey);
    4444
    4545void cleanLibDict();
  • trunk/include/core/RpNumber.h

    r38 r104  
    2222{
    2323    public:
    24        
     24
    2525        // users member fxns
    2626
     
    5151                        int* result = NULL  );
    5252        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
    5555        // place the information from this object into the xml library 'lib'
    5656        // virtual RpNumber& put(RpLibrary lib);
    5757        // RpNumber& put() const;
    5858
    59        
    6059
    61         /*
     60
     61        /*
    6262         * user provides a 'path' for where this object lives in xml file
    6363         * user calls define with standard hints as described in Number docs
     
    7878         *
    7979         *
    80          *         
     80         *
    8181         */
    82        
     82
    8383        /* what about unit-less numbers */
    8484        RpNumber (
     
    135135
    136136        }
    137        
     137
    138138        // copy constructor
    139139        RpNumber ( const RpNumber& myRpNumber )
     
    155155
    156156        // std::string units;
    157         RpUnits* units;
     157        const RpUnits* units;
    158158        double min;
    159159        double max;
  • trunk/include/core/RpUnits.h

    r83 r104  
    3636        const std::string getUnits(){ return units; };
    3737        double getExponent() {return exponent;};
    38         RpUnits * getBasis() {return basis;};
     38        const RpUnits * getBasis() {return basis;};
    3939
    4040        friend class RpUnits;
     
    4343        const std::string units;
    4444        double exponent;
    45         RpUnits* basis;
     45        const RpUnits* basis;
    4646
    4747        unit* prev;
     
    5252                const std::string& units,
    5353                double&            exponent,
    54                 RpUnits*           basis,
     54                const RpUnits*     basis,
    5555                unit*              next
    5656             )
     
    109109    private:
    110110
    111         RpUnits* fromPtr;
    112         RpUnits* toPtr;
     111        const RpUnits* fromPtr;
     112        const RpUnits* toPtr;
    113113        double (*convForwFxnPtr)(double);
    114114        double (*convBackFxnPtr)(double);
     115        double (*convForwFxnPtrDD)(double,double);
     116        double (*convBackFxnPtrDD)(double,double);
    115117        void* (*convForwFxnPtrVoid)(void*, void*);
    116118        void* convForwData;
     
    125127        // create a conversion
    126128        conversion (
    127                 RpUnits* fromPtr,
    128                 RpUnits* toPtr,
     129                const RpUnits* fromPtr,
     130                const RpUnits* toPtr,
    129131                double (*convForwFxnPtr)(double),
    130132                double (*convBackFxnPtr)(double),
     
    136138                convForwFxnPtr      (convForwFxnPtr),
    137139                convBackFxnPtr      (convBackFxnPtr),
     140                convForwFxnPtrDD    (NULL),
     141                convBackFxnPtrDD    (NULL),
    138142                convForwFxnPtrVoid  (NULL),
    139143                convForwData        (NULL),
     
    145149
    146150        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,
    149175                void* (*convForwFxnPtrVoid)(void*, void*),
    150176                void* convForwData,
     
    158184                convForwFxnPtr      (NULL),
    159185                convBackFxnPtr      (NULL),
     186                convForwFxnPtrDD    (NULL),
     187                convBackFxnPtrDD    (NULL),
    160188                convForwFxnPtrVoid  (convForwFxnPtrVoid),
    161189                convForwData        (convForwData),
     
    218246
    219247        // 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;
    224252
    225253        // 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;
    227257        // 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;
    229261        // 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);
    231263        // convert from one RpUnits to another if the conversion is defined
    232         std::string convert (   RpUnits* toUnits,
     264        std::string convert (   const RpUnits* toUnits,
    233265                                double val,
    234266                                int showUnits = 0,
    235                                 int* result = NULL  );
     267                                int* result = NULL  ) const;
    236268
    237269        static std::string convert ( std::string val,
     
    246278        // this should only be used for units that are part of the
    247279        // 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);
    252284
    253285        // find a RpUnits object that should exist in RpUnitsTable
    254286        // returns 0 on success (object was found)
    255287        // 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);
    271289
    272290        // user calls define to add a RpUnits object or to add a relation rule
    273291        //
    274292        // 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);
    277297        //
    278298        // add relation rule
    279299
    280         static RpUnits * define(RpUnits* from,
    281                                 RpUnits* to,
     300        static RpUnits * define(const RpUnits* from,
     301                                const RpUnits* to,
    282302                                double (*convForwFxnPtr)(double),
    283303                                double (*convBackFxnPtr)(double));
    284304
    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,
    287312                                void* (*convForwFxnPtr)(void*, void*),
    288313                                void* convForwData,
     
    297322        //      "temp"                      load units related to temperature
    298323        //      "time"                      load units related to time
     324        //      "volume"                    load units related to volume
    299325        //  (no other groups have been created)
    300326
     
    384410
    385411        // 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;
    387416
    388417        // used by the RpUnits when defining conversion elements
     
    405434                    const std::string& units,
    406435                    double& exponent,
    407                     RpUnits* basis
     436                    const RpUnits* basis
    408437                )
    409438            :   head        ( new unit( units, exponent, basis, NULL) ),
     
    418447
    419448        RpUnits (
    420                     RpUnits* from,
    421                     RpUnits* to,
     449                    const RpUnits* from,
     450                    const RpUnits* to,
    422451                    double (*convForwFxnPtr)(double),
    423452                    double (*convBackFxnPtr)(double),
     
    435464
    436465
    437 
    438 
    439 
    440466        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,
    443488                    void* (*convForwFxnPtr)(void*, void*),
    444489                    void* convForwData,
     
    475520        }
    476521
    477         void RpUnits::connectConversion(RpUnits* myRpUnit);
     522        void RpUnits::connectConversion(const RpUnits* myRpUnit);
    478523
    479524        void RpUnits::fillMetricMap();
     
    495540
    496541
    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
    498545        void addUnit( const std::string& units,
    499546                      double &  exponent,
    500                       RpUnits * basis
     547                      const RpUnits * basis
    501548                     );
    502549
     
    506553        static int addPresetTemp();
    507554        static int addPresetTime();
     555        static int addPresetVolume();
    508556
    509557
  • trunk/include/core/RpUnitsStd.h

    r68 r104  
    44#endif
    55
    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);
     6double centi2base (double centi, double power);
     7double milli2base (double milli, double power);
     8double micro2base (double micro, double power);
     9double nano2base (double nano, double power);
     10double pico2base (double pico, double power);
     11double femto2base (double femto, double power);
     12double atto2base (double atto, double power);
     13double kilo2base (double kilo, double power);
     14double mega2base (double mega, double power);
     15double giga2base (double giga, double power);
     16double tera2base (double tera, double power);
     17double peta2base (double peta, double power);
    3218
    3319
    3420
    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);
     21double base2centi (double base, double power);
     22double base2milli (double base, double power);
     23double base2micro (double base, double power);
     24double base2nano (double base, double power);
     25double base2pico (double base, double power);
     26double base2femto (double base, double power);
     27double base2atto (double base, double power);
     28double base2kilo (double base, double power);
     29double base2mega (double base, double power);
     30double base2giga (double base, double power);
     31double base2tera (double base, double power);
     32double base2peta (double base, double power);
     33
     34
     35
     36double angstrom2meter (double angstrom, double power);
     37double meter2angstrom (double meters, double power);
     38double meter2inch (double m, double power);
     39double inch2meter (double in, double power);
     40double meter2feet (double m, double power);
     41double feet2meter (double ft, double power);
     42double meter2yard (double m, double power);
     43double yard2meter (double yd, double power);
    4344
    4445
     
    6263
    6364
     65double cubicMeter2usGallon (double m3, double none);
     66double usGallon2cubicMeter (double g, double none);
     67double cubicFeet2usGallon (double ft3, double none);
     68double usGallon2cubicFeet (double g, double none);
    6469
    6570
  • trunk/src/cee/RpUnitsCInterface.cc

    r93 r104  
    1717#endif
    1818
    19 RpUnits*
    20 rpDefineUnit(const char* unitSymbol, RpUnits* basis) {
     19const RpUnits*
     20rpDefineUnit(const char* unitSymbol, const RpUnits* basis) {
    2121
    2222    return RpUnits::define(unitSymbol, basis);
    2323}
    2424
    25 RpUnits*
    26 rpDefineConv(    RpUnits* fromUnit,
    27                RpUnits* toUnit,
     25const RpUnits*
     26rpDefineConv(  const RpUnits* fromUnit,
     27               const RpUnits* toUnit,
    2828               double (*convForwFxnPtr)(double),
    2929               double (*convBackFxnPtr)(double)    ) {
     
    3232}
    3333
    34 RpUnits*
     34const RpUnits*
    3535rpFind ( const char* key ) {
    3636
     
    3939
    4040const char*
    41 rpGetUnits ( RpUnits* unit ) {
     41rpGetUnits ( const RpUnits* unit ) {
    4242
    4343    static std::string retVal;
     
    4747
    4848const char*
    49 rpGetUnitsName ( RpUnits* unit ) {
     49rpGetUnitsName ( const RpUnits* unit ) {
    5050
    5151    static std::string retVal;
     
    5555
    5656double
    57 rpGetExponent ( RpUnits* unit ) {
     57rpGetExponent ( const RpUnits* unit ) {
    5858
    5959    return unit->getExponent();
    6060}
    6161
    62 RpUnits*
    63 rpGetBasis ( RpUnits* unit ) {
     62const RpUnits*
     63rpGetBasis ( const RpUnits* unit ) {
    6464
    6565    return unit->getBasis();
     
    6767
    6868int
    69 rpMakeMetric(RpUnits* basis) {
     69rpMakeMetric(const RpUnits* basis) {
    7070
    7171    return RpUnits::makeMetric(basis);
     
    9595
    9696const char*
    97 rpConvert_ObjStr ( RpUnits* fromUnits,
    98                    RpUnits* toUnits,
     97rpConvert_ObjStr ( const RpUnits* fromUnits,
     98                   const RpUnits* toUnits,
    9999                   double val,
    100100                   int showUnits,
     
    124124
    125125double
    126 rpConvert_ObjDbl (   RpUnits* fromUnits,
    127                      RpUnits* toUnits,
     126rpConvert_ObjDbl (   const RpUnits* fromUnits,
     127                     const RpUnits* toUnits,
    128128                     double val,
    129129                     int* result ) {
  • trunk/src/core/RpBindingsDict.cc

    r97 r104  
    8989}
    9090
    91 RpUnits*
     91const RpUnits*
    9292getObject_UnitsStr(int objKey) {
    9393
  • trunk/src/core/RpNumber.cc

    r37 r104  
    44
    55/************************************************************************
    6  *                                                                     
     6 *
    77 * set the default value of a RpNumber object
    8  *                                                                     
    9  ************************************************************************/
    10 
    11 RpNumber& 
    12 RpNumber::setDefaultValue(double newDefaultVal)
    13 {
     8 *
     9 ************************************************************************/
     10
     11RpNumber&
     12RpNumber::setDefaultValue(double newDefaultVal) {
     13
    1414    double* def = NULL;
    15    
     15
    1616    def = (double*) RpVariable::getDefaultValue();
    1717
     
    2727
    2828/************************************************************************
    29  *                                                                     
     29 *
    3030 * set the current value of a RpNumber object
    31  *                                                                     
    32  ************************************************************************/
    33 
    34 RpNumber& 
    35 RpNumber::setCurrentValue(double newCurrentVal)
    36 {
     31 *
     32 ************************************************************************/
     33
     34RpNumber&
     35RpNumber::setCurrentValue(double newCurrentVal) {
     36
    3737    double* cur = (double*) RpVariable::getCurrentValue();
    3838    double* def = (double*) RpVariable::getDefaultValue();
     
    5050
    5151/************************************************************************
    52  *                                                                     
     52 *
    5353 * set the min value of a RpNumber object
    54  *                                                                     
    55  ************************************************************************/
    56 RpNumber& 
    57 RpNumber::setMin(double newMin)
    58 {
     54 *
     55 ************************************************************************/
     56RpNumber&
     57RpNumber::setMin(double newMin) {
     58
    5959    min = newMin;
    6060    return *this;
    6161}
    6262/************************************************************************
    63  *                                                                     
     63 *
    6464 * set the min value of a RpNumber object
    65  *                                                                     
    66  ************************************************************************/
    67 RpNumber& 
    68 RpNumber::setMax(double newMax)
    69 {
     65 *
     66 ************************************************************************/
     67RpNumber&
     68RpNumber::setMax(double newMax) {
     69
    7070    max = newMax;
    7171    return *this;
    7272}
    7373/************************************************************************
    74  *                                                                     
     74 *
    7575 * report the units of the object
    76  *                                                                     
     76 *
    7777 ************************************************************************/
    7878
    7979std::string
    80 RpNumber::getUnits() const
    81 {
     80RpNumber::getUnits() const {
     81
    8282    return units->getUnitsName();
    8383}
     
    8585
    8686/************************************************************************
    87  *                                                                     
     87 *
    8888 * report the default value of the object
    89  *                                                                     
    90  ************************************************************************/
    91 double
    92 RpNumber::getDefaultValue(void* null_val) const
    93 {
     89 *
     90 ************************************************************************/
     91double
     92RpNumber::getDefaultValue(void* null_val) const {
     93
    9494    return *((double*) RpVariable::getDefaultValue());
    9595}
    9696
    9797/************************************************************************
    98  *                                                                     
     98 *
    9999 * report the current value of the object
    100  *                                                                     
    101  ************************************************************************/
    102 double
    103 RpNumber::getCurrentValue(void* null_val) const
    104 {
     100 *
     101 ************************************************************************/
     102double
     103RpNumber::getCurrentValue(void* null_val) const {
     104
    105105    return *((double*) RpVariable::getCurrentValue());
    106106}
    107107
    108108/************************************************************************
    109  *                                                                     
     109 *
    110110 * report the min of the object
    111  *                                                                     
    112  ************************************************************************/
    113 double
    114 RpNumber::getMin() const
    115 {
    116     return min; 
    117 }
    118 
    119 /************************************************************************
    120  *                                                                     
     111 *
     112 ************************************************************************/
     113double
     114RpNumber::getMin() const {
     115
     116    return min;
     117}
     118
     119/************************************************************************
     120 *
    121121 * report the max of the object
    122  *                                                                     
    123  ************************************************************************/
    124 double
    125 RpNumber::getMax() const
    126 {
    127     return max; 
    128 }
    129 
    130 /************************************************************************
    131  *                                                                     
     122 *
     123 ************************************************************************/
     124double
     125RpNumber::getMax() const {
     126
     127    return max;
     128}
     129
     130/************************************************************************
     131 *
    132132 * convert the number object to another unit from string
    133133 * store the result as the currentValue
    134  *                                                                     
    135  ************************************************************************/
    136 double
    137 RpNumber::convert(std::string toUnitStr, int storeResult, int* result)
    138 {
    139     RpUnits * toUnit = NULL;
     134 *
     135 ************************************************************************/
     136double
     137RpNumber::convert(std::string toUnitStr, int storeResult, int* result) {
     138
     139    const RpUnits* toUnit = NULL;
    140140    double retVal = 0;
    141141    int my_result = 0;
     
    156156    // perform the conversion
    157157    retVal = convert(toUnit,&my_result);
    158    
     158
    159159    // check the result of the conversion and store if necessary
    160160    if (my_result) {
     
    176176
    177177/************************************************************************
    178  *                                                                     
     178 *
    179179 * convert the number object to another unit from string
    180  *                                                                     
    181  ************************************************************************/
    182 double
    183 RpNumber::convert(std::string toUnitStr, int* result)
    184 {
    185     RpUnits * toUnit = NULL;
     180 *
     181 ************************************************************************/
     182double
     183RpNumber::convert(std::string toUnitStr, int* result) {
     184
     185    const RpUnits* toUnit = NULL;
    186186    toUnit = RpUnits::find(toUnitStr);
    187187    if (!toUnit) {
     
    197197
    198198/************************************************************************
    199  *                                                                     
     199 *
    200200 * convert the number object to another unit from RpUnits object
    201  *                                                                     
    202  ************************************************************************/
    203 double
    204 RpNumber::convert(RpUnits* toUnit, int *result)
    205 {
     201 *
     202 ************************************************************************/
     203double
     204RpNumber::convert(const RpUnits* toUnit, int *result) {
     205
    206206    return units->convert(toUnit,getCurrentValue(), result);
    207207}
  • trunk/src/core/RpUnits.cc

    r103 r104  
    2323 ************************************************************************/
    2424
    25 RpUnits * RpUnits::define(const std::string units, RpUnits * basis)
    26 {
     25RpUnits *
     26RpUnits::define(const std::string units, const RpUnits* basis) {
     27
    2728    RpUnits * newRpUnit = NULL;
    2829
     
    187188 ************************************************************************/
    188189
    189 RpUnits * RpUnits::defineCmplx ( const std::string units, RpUnits * basis )
    190 {
     190RpUnits *
     191RpUnits::defineCmplx ( const std::string units, const RpUnits* basis ) {
     192
    191193    RpUnits * newRpUnit = NULL;
    192194
     
    427429 *
    428430 ************************************************************************/
    429 RpUnits * RpUnits::define(  RpUnits* from,
    430                             RpUnits* to,
    431                             double (*convForwFxnPtr)(double),
    432                             double (*convBackFxnPtr)(double))
    433 {
     431RpUnits *
     432RpUnits::define(  const RpUnits* from,
     433                  const RpUnits* to,
     434                  double (*convForwFxnPtr)(double),
     435                  double (*convBackFxnPtr)(double)) {
     436
    434437    RpUnits* conv = new RpUnits(    from,
    435438                                    to,
     
    442445}
    443446
    444 RpUnits * RpUnits::define(  RpUnits* from,
    445                             RpUnits* to,
    446                             double (*convForwFxnPtr)(double,double),
    447                             double (*convBackFxnPtr)(double,double))
    448 {
     447RpUnits *
     448RpUnits::define(  const RpUnits* from,
     449                  const RpUnits* to,
     450                  double (*convForwFxnPtr)(double,double),
     451                  double (*convBackFxnPtr)(double,double)) {
     452
    449453    RpUnits* conv = new RpUnits(    from,
    450454                                    to,
     
    457461}
    458462
    459 RpUnits * RpUnits::define(  RpUnits* from,
    460                             RpUnits* to,
    461                             void* (*convForwFxnPtr)(void*, void*),
    462                             void* convForwData,
    463                             void* (*convBackFxnPtr)(void*, void*),
    464                             void* convBackData)
    465 {
     463RpUnits *
     464RpUnits::define(  const RpUnits* from,
     465                  const RpUnits* to,
     466                  void* (*convForwFxnPtr)(void*, void*),
     467                  void* convForwData,
     468                  void* (*convBackFxnPtr)(void*, void*),
     469                  void* convBackData) {
     470
    466471    RpUnits* conv = new RpUnits(    from,
    467472                                    to,
     
    480485 * report the units this object represents back to the user
    481486 *
    482  * **********************************************************************/
    483 std::string RpUnits::getUnits()
    484 {
     487 ************************************************************************/
     488
     489/**********************************************************************/
     490// METHOD: getUnits()
     491// /// Report the text portion of the units of this object back to caller.
     492// /**
     493//  * See Also getUnitsName().
     494//  */
     495//
     496std::string
     497RpUnits::getUnits() const {
     498
    485499    std::stringstream unitText;
    486500    unit* p = head;
     
    498512 * report the units this object represents back to the user
    499513 *
    500  * **********************************************************************/
    501 std::string RpUnits::getUnitsName()
    502 {
     514 ************************************************************************/
     515
     516/**********************************************************************/
     517// METHOD: getUnitsName()
     518// /// Report the full name of the units of this object back to caller.
     519// /**
     520//  * Reports the full text and exponent of the units represented by this
     521//  * object, back to the caller. Note that if the exponent == 1, no
     522//  * exponent will be printed.
     523//  */
     524//
     525std::string
     526RpUnits::getUnitsName() const {
     527
    503528    std::stringstream unitText;
    504529    unit* p = head;
     
    527552 *
    528553 * **********************************************************************/
    529 double RpUnits::getExponent()
    530 {
     554/**********************************************************************/
     555// METHOD: getExponent()
     556// /// Report the exponent of the units of this object back to caller.
     557// /**
     558//  * Reports the exponent of the units represented by this
     559//  * object, back to the caller. Note that if the exponent == 1, no
     560//  * exponent will be printed.
     561//  */
     562//
     563double
     564RpUnits::getExponent() const {
     565
    531566    return head->getExponent();
    532567}
     
    537572 *
    538573 * **********************************************************************/
    539 RpUnits * RpUnits::getBasis()
    540 {
     574/**********************************************************************/
     575// METHOD: getBasis()
     576// /// Retrieve the RpUnits object representing the basis of this object.
     577// /**
     578//  * Returns a pointer to a RpUnits object which, on success, points to the
     579//  * RpUnits object that is the basis of the calling object.
     580//  */
     581//
     582const RpUnits *
     583RpUnits::getBasis() const {
     584
    541585    // check if head exists?
     586    if (!head) {
     587        // raise error for badly formed Rappture Units object
     588    }
     589
    542590    return head->getBasis();
    543591}
     
    553601 *
    554602 ************************************************************************/
    555 double RpUnits::makeBasis(double value, int* result)
    556 {
    557 
    558     RpUnits* basis = getBasis();
     603double
     604RpUnits::makeBasis(double value, int* result) const {
     605
     606    const RpUnits* basis = getBasis();
    559607    double retVal = value;
    560608
     
    567615        // do nothing
    568616
    569         if (result) {
    570             *result = 1;
    571         }
     617        // if (result) {
     618        //     *result = 1;
     619        // }
    572620    }
    573621    else {
     
    578626}
    579627
    580 RpUnits& RpUnits::makeBasis(double* value, int* result)
    581 {
    582     RpUnits* basis = getBasis();
     628const RpUnits&
     629RpUnits::makeBasis(double* value, int* result) const {
     630    const RpUnits* basis = getBasis();
    583631    double retVal = *value;
    584632    int convResult = 0;
     
    588636        // do nothing
    589637
    590         if (result) {
    591             *result = 1;
    592         }
     638        // if (result) {
     639        //     *result = 1;
     640        // }
    593641    }
    594642    else {
     
    603651        *result = convResult;
    604652    }
    605 
    606 
    607653
    608654    return *this;
     
    616662 *
    617663 * **********************************************************************/
    618 /*
    619 int RpUnits::makeMetric(RpUnits * basis) {
     664
     665int
     666RpUnits::makeMetric(const RpUnits * basis) {
    620667
    621668    if (!basis) {
     
    623670    }
    624671
    625     std::string basisName = basis->getUnits();
     672    std::string basisName = basis->getUnitsName();
    626673    std::string name;
    627674    std::string forw, back;
     
    677724    return (1);
    678725}
    679 */
    680 
    681 int RpUnits::makeMetric(RpUnits * basis) {
    682 
    683     if (!basis) {
    684         return 0;
    685     }
    686 
    687     std::string basisName = basis->getUnitsName();
    688     std::string name;
    689     std::string forw, back;
    690 
    691     name = "c" + basisName;
    692     RpUnits * centi = RpUnits::define(name, basis);
    693     RpUnits::define(centi, basis, centi2base, base2centi);
    694 
    695     name = "m" + basisName;
    696     RpUnits * milli = RpUnits::define(name, basis);
    697     RpUnits::define(milli, basis, milli2base, base2milli);
    698 
    699     name = "u" + basisName;
    700     RpUnits * micro = RpUnits::define(name, basis);
    701     RpUnits::define(micro, basis, micro2base, base2micro);
    702 
    703     name = "n" + basisName;
    704     RpUnits * nano  = RpUnits::define(name, basis);
    705     RpUnits::define(nano, basis, nano2base, base2nano);
    706 
    707     name = "p" + basisName;
    708     RpUnits * pico  = RpUnits::define(name, basis);
    709     RpUnits::define(pico, basis, pico2base, base2pico);
    710 
    711     name = "f" + basisName;
    712     RpUnits * femto = RpUnits::define(name, basis);
    713     RpUnits::define(femto, basis, femto2base, base2femto);
    714 
    715     name = "a" + basisName;
    716     RpUnits * atto  = RpUnits::define(name, basis);
    717     RpUnits::define(atto, basis, atto2base, base2atto);
    718 
    719     name = "k" + basisName;
    720     RpUnits * kilo  = RpUnits::define(name, basis);
    721     RpUnits::define(kilo, basis, kilo2base, base2kilo);
    722 
    723     name = "M" + basisName;
    724     RpUnits * mega  = RpUnits::define(name, basis);
    725     RpUnits::define(mega, basis, mega2base, base2mega);
    726 
    727     name = "G" + basisName;
    728     RpUnits * giga  = RpUnits::define(name, basis);
    729     RpUnits::define(giga, basis, giga2base, base2giga);
    730 
    731     name = "T" + basisName;
    732     RpUnits * tera  = RpUnits::define(name, basis);
    733     RpUnits::define(tera, basis, tera2base, base2tera);
    734 
    735     name = "P" + basisName;
    736     RpUnits * peta  = RpUnits::define(name, basis);
    737     RpUnits::define(peta, basis, peta2base, base2peta);
    738 
    739     return (1);
    740 }
    741 
    742 
    743 RpUnits*
    744 RpUnits::find(std::string key)
    745 {
     726
     727
     728const RpUnits*
     729RpUnits::find(std::string key) {
     730
    746731    // dict.find seems to return a (RpUnits* const) so i had to
    747732    // cast it as a (RpUnits*)
    748733
    749734    // dict pointer
    750     RpUnits* unitEntry = (RpUnits*) *(dict->find(key).getValue());
     735    const RpUnits* unitEntry = *(dict->find(key).getValue());
    751736
    752737    // dict pointer
    753     if (unitEntry == (RpUnits*)dict->getNullEntry().getValue()) {
     738    if (unitEntry == *(dict->getNullEntry().getValue()) ) {
    754739        unitEntry = NULL;
    755740    }
     
    768753                    int* result ) {
    769754
    770     RpUnits* toUnits = NULL;
    771     RpUnits* fromUnits = NULL;
     755    const RpUnits* toUnits = NULL;
     756    const RpUnits* fromUnits = NULL;
    772757    std::string tmpNumVal = "";
    773758    std::string fromUnitsName = "";
     
    849834    if ( (result) && (*result == 0) ) {
    850835        *result = convResult;
    851    }
     836    }
    852837
    853838    return convVal;
     
    855840}
    856841
    857 std::string RpUnits::convert (   RpUnits* toUnits,
    858                         double val,
    859                         int showUnits,
    860                         int* result )
    861 {
     842std::string
     843RpUnits::convert ( const  RpUnits* toUnits,
     844                   double val,
     845                   int showUnits,
     846                   int* result )  const {
     847
    862848    double retVal = convert(toUnits,val,result);
    863849    std::stringstream unitText;
     
    880866//      cm.convert(meter,10)
    881867//      cm.convert(angstrum,100)
    882 double RpUnits::convert(RpUnits* toUnit, double val, int* result)
    883 {
     868double
     869RpUnits::convert(const RpUnits* toUnit, double val, int* result) const {
    884870
    885871    // currently we convert this object to its basis and look for the
     
    887873
    888874    double value = val;
    889     RpUnits* basis = this->getBasis();
    890     RpUnits* toBasis = toUnit->getBasis();
    891     RpUnits* fromUnit = this;
    892     RpUnits* dictToUnit = NULL;
     875    const RpUnits* basis = this->getBasis();
     876    const RpUnits* toBasis = toUnit->getBasis();
     877    const RpUnits* fromUnit = this;
     878    const RpUnits* dictToUnit = NULL;
    893879    convEntry *p;
    894880    int my_result = 0;
     
    10611047
    10621048
    1063 void* RpUnits::convert(RpUnits* toUnit, void* val, int* result)
    1064 {
     1049void*
     1050RpUnits::convert(const RpUnits* toUnit, void* val, int* result) const {
    10651051
    10661052    // currently we convert this object to its basis and look for the
     
    10681054
    10691055    void* value = val;
    1070     RpUnits* basis = this->getBasis();
    1071     RpUnits* toBasis = toUnit->getBasis();
    1072     RpUnits* fromUnit = this;
    1073     RpUnits* dictToUnit = NULL;
     1056    const RpUnits* basis = this->getBasis();
     1057    const RpUnits* toBasis = toUnit->getBasis();
     1058    const RpUnits* fromUnit = this;
     1059    const RpUnits* dictToUnit = NULL;
    10741060    convEntry *p;
    10751061    int my_result = 0;
     
    12111197}
    12121198
    1213 void RpUnits::addUnit( const std::string& units,
    1214                        double&  exponent,
    1215                        RpUnits* basis
    1216                       )
    1217 {
     1199void
     1200RpUnits::addUnit( const std::string& units,
     1201                  double&  exponent,
     1202                  const RpUnits* basis) {
     1203
    12181204    unit* p = NULL;
    12191205
     
    12311217}
    12321218
    1233 int RpUnits::insert(std::string key)
    1234 {
     1219int
     1220RpUnits::insert(std::string key) {
     1221
    12351222    int newRecord = 0;
    12361223    RpUnits* val = this;
     
    12411228
    12421229
    1243 int RpUnits::pre_compare( std::string& units, RpUnits* basis )
    1244 {
     1230int
     1231RpUnits::pre_compare( std::string& units, const RpUnits* basis ) {
    12451232
    12461233    // compare the incomming units with the previously defined units.
     
    13561343
    13571344
    1358 void RpUnits::connectConversion(RpUnits* myRpUnit)
    1359 {
     1345void
     1346RpUnits::connectConversion(const RpUnits* myRpUnit) {
     1347
    13601348    convEntry* p = myRpUnit->convList;
    13611349
     
    13921380        retVal = addPresetTime();
    13931381    }
     1382    else if (group.compare("volume") == 0) {
     1383        retVal = addPresetTime();
     1384    }
    13941385
    13951386    return retVal;
  • trunk/src/fortran/RpUnitsFInterface.cc

    r93 r104  
    2222
    2323    int result = -1;
    24     RpUnits* newUnit = NULL;
    25     RpUnits* basis = NULL;
     24    const RpUnits* newUnit = NULL;
     25    const RpUnits* basis = NULL;
    2626    std::string basisStrName = "";
    2727    std::string newUnitName = "";
     
    6464
    6565    // RpUnits* searchUnit = RpUnits::find(searchName);
    66     RpUnits* searchUnit = RpUnits::find(inText);
     66    const RpUnits* searchUnit = RpUnits::find(inText);
    6767
    6868    if (searchUnit) {
     
    8181{
    8282    int result = -1;
    83     RpUnits* newBasis = NULL;
     83    const RpUnits* newBasis = NULL;
    8484
    8585    if (basis && *basis) {
     
    9797rp_get_units(int* unitRefVal, char* retText, int retText_len)
    9898{
    99     RpUnits* unitObj = NULL;
     99    const RpUnits* unitObj = NULL;
    100100    std::string unitNameText = "";
    101101    int result = 0;
     
    115115rp_get_units_name(int* unitRefVal, char* retText, int retText_len)
    116116{
    117     RpUnits* unitObj = NULL;
     117    const RpUnits* unitObj = NULL;
    118118    std::string unitNameText = "";
    119119    int result = 0;
     
    133133rp_get_exponent(int* unitRefVal, double* retExponent)
    134134{
    135     RpUnits* unitObj = NULL;
     135    const RpUnits* unitObj = NULL;
    136136    int result = 0;
    137137
     
    149149rp_get_basis(int* unitRefVal)
    150150{
    151     RpUnits* unitObj = NULL;
    152     RpUnits* basisObj = NULL;
     151    const RpUnits* unitObj = NULL;
     152    const RpUnits* basisObj = NULL;
    153153    int result = -1;
    154154
     
    170170int
    171171rp_units_convert_dbl (  char* fromVal,
    172                             char* toUnitsName,
    173                             double* convResult,
    174                             int fromVal_len,
    175                             int toUnitsName_len ) {
     172                        char* toUnitsName,
     173                        double* convResult,
     174                        int fromVal_len,
     175                        int toUnitsName_len ) {
    176176
    177177    char* inFromVal = NULL;
     
    210210int
    211211rp_units_convert_str (      char* fromVal,
    212                                 char* toUnitsName,
    213                                 char* retText,
    214                                 int fromVal_len,
    215                                 int toUnitsName_len,
    216                                 int retText_len     ) {
     212                            char* toUnitsName,
     213                            char* retText,
     214                            int fromVal_len,
     215                            int toUnitsName_len,
     216                            int retText_len     ) {
    217217
    218218    char* inFromVal = NULL;
  • trunk/src/python/PyRpUnits.cc

    r97 r104  
    66typedef struct {
    77    PyObject_HEAD
    8     RpUnits* rp_unit;
     8    const RpUnits* rp_unit;
    99} RpUnitsObject;
    1010
     
    131131    0,                                    /*tp_as_buffer*/
    132132    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,   /*tp_flags*/
    133     "RpUnits Object",                     /*tp_doc*/
     133    "Rappture.Units Object",              /*tp_doc*/
    134134    0,                                    /*tp_traverse*/
    135135    0,                                    /*tp_clear*/
     
    291291
    292292    RpUnitsObject* newRpUnit = NULL;
    293     RpUnits* newConv = NULL;
     293    const RpUnits* newConv = NULL;
    294294
    295295    if (PyTuple_Size(args) > 0) {
     
    360360{
    361361    char* searchUnits = NULL;
    362     RpUnits* foundUnits = NULL;
     362    const RpUnits* foundUnits = NULL;
    363363    RpUnitsObject* returnUnits = NULL;
    364364
  • trunk/test/src/RpNumber_test.cc

    r40 r104  
    8484void define_some_units()
    8585{
    86     RpUnits * meters = RpUnits::define("m", NULL);
     86    const RpUnits * meters = RpUnits::define("m", NULL);
    8787    RpUnits::makeMetric(meters);
    8888    RpUnits::define("V", NULL);
    8989    RpUnits::define("s", NULL);
    9090    RpUnits::define("cm2/Vs", NULL);
    91     RpUnits* angstrom = RpUnits::define("A", NULL);
     91    const RpUnits* angstrom = RpUnits::define("A", NULL);
    9292    RpUnits::define(angstrom, meters, angstrom2meter, meter2angstrom);
    93     RpUnits* fahrenheit = RpUnits::define("F", NULL);
    94     RpUnits* celcius = RpUnits::define("C", NULL);
    95     RpUnits* kelvin = RpUnits::define("K", NULL);
     93    const RpUnits* fahrenheit = RpUnits::define("F", NULL);
     94    const RpUnits* celcius = RpUnits::define("C", NULL);
     95    const RpUnits* kelvin = RpUnits::define("K", NULL);
    9696    RpUnits::define(fahrenheit, celcius, fahrenheit2centigrade, centigrade2fahrenheit);
    9797    RpUnits::define(celcius, kelvin, centigrade2kelvin, kelvin2centigrade);
  • trunk/test/src/RpUnitsC_test.c

    r93 r104  
    5151{
    5252
    53     RpUnits* meters = rpDefineUnit("m",NULL);
     53    const RpUnits* meters = rpDefineUnit("m",NULL);
    5454
    55     RpUnits* centimeters = NULL;
    56     RpUnits* nanometers = NULL;
    57     RpUnits* cm_basis = NULL;
     55    const RpUnits* centimeters = NULL;
     56    const RpUnits* nanometers = NULL;
     57    const RpUnits* cm_basis = NULL;
    5858
    59     RpUnits* angstrom = rpDefineUnit("A",NULL);
    60     RpUnits* fahrenheit = rpDefineUnit("F",NULL);
    61     RpUnits* celcius = rpDefineUnit("C",NULL);
    62     RpUnits* kelvin = rpDefineUnit("K",NULL);
     59    const RpUnits* angstrom = rpDefineUnit("A",NULL);
     60    const RpUnits* fahrenheit = rpDefineUnit("F",NULL);
     61    const RpUnits* celcius = rpDefineUnit("C",NULL);
     62    const RpUnits* kelvin = rpDefineUnit("K",NULL);
    6363
    6464    rpDefineConv(angstrom, meters, angstrom2meter, meter2angstrom);
  • trunk/test/src/RpUnits_test.cc

    r73 r104  
    3333    //
    3434    printf ("=============== TEST 1 ===============\n");
    35     RpUnits * meters = RpUnits::define("m", NULL);
     35    const RpUnits * meters = RpUnits::define("m", NULL);
    3636    // (meters) ? success() : fail();
    3737    // RpUnits * centimeter = RpUnits::define("cm", NULL);
     
    5454*/
    5555   
    56     RpUnits* mobility = RpUnits::define("cm2/Vs", NULL);
     56    const RpUnits* mobility = RpUnits::defineCmplx("cm2/Vs", NULL);
    5757    std::cout << "mobility = :" << mobility->getUnitsName() <<":"<< std::endl;
    5858
    59     RpUnits* mobility2 = RpUnits::find("cm2V-1s-1");
     59    const RpUnits* mobility2 = RpUnits::find("cm2V-1s-1");
    6060    if (mobility2) {
    6161        std::cout << "mobility2 exists" << std::endl;
     
    6767    }
    6868
    69     RpUnits* cmeters = RpUnits::find("cm");
    70     RpUnits* angstrom = RpUnits::define("A", NULL);
     69    const RpUnits* cmeters = RpUnits::find("cm");
     70    const RpUnits* angstrom = RpUnits::define("A", NULL);
    7171    RpUnits::define(angstrom, meters, angstrom2meter, meter2angstrom);
    7272
     
    7979
    8080
    81     RpUnits* fahrenheit  = RpUnits::define("F", NULL);
    82     RpUnits* celcius  = RpUnits::define("C", NULL);
    83     RpUnits* kelvin  = RpUnits::define("K", NULL);
     81    const RpUnits* fahrenheit  = RpUnits::define("F", NULL);
     82    const RpUnits* celcius  = RpUnits::define("C", NULL);
     83    const RpUnits* kelvin  = RpUnits::define("K", NULL);
    8484   
    8585    RpUnits::define(fahrenheit, celcius, fahrenheit2centigrade, centigrade2fahrenheit);
     
    155155    printf ("=============== TEST 4.4 ===============\n");
    156156
    157     RpUnits * millimeter = RpUnits::find("mm");
    158     RpUnits * micrometer = RpUnits::find("um");
    159     RpUnits * nanometer  = RpUnits::find("nm");
    160     RpUnits * picometer  = RpUnits::find("pm");
    161     RpUnits * femtometer = RpUnits::find("fm");
    162     RpUnits * attometer  = RpUnits::find("am");
    163     RpUnits * kilometer  = RpUnits::find("km");
    164     RpUnits * megameter  = RpUnits::find("Mm");
    165     RpUnits * gigameter  = RpUnits::find("Gm");
    166     RpUnits * terameter  = RpUnits::find("Tm");
    167     RpUnits * petameter  = RpUnits::find("Pm");
     157    const RpUnits * millimeter = RpUnits::find("mm");
     158    const RpUnits * micrometer = RpUnits::find("um");
     159    const RpUnits * nanometer  = RpUnits::find("nm");
     160    const RpUnits * picometer  = RpUnits::find("pm");
     161    const RpUnits * femtometer = RpUnits::find("fm");
     162    const RpUnits * attometer  = RpUnits::find("am");
     163    const RpUnits * kilometer  = RpUnits::find("km");
     164    const RpUnits * megameter  = RpUnits::find("Mm");
     165    const RpUnits * gigameter  = RpUnits::find("Gm");
     166    const RpUnits * terameter  = RpUnits::find("Tm");
     167    const RpUnits * petameter  = RpUnits::find("Pm");
    168168
    169169    value = 1.0e+3;
     
    256256
    257257
    258     RpUnits* eV  = RpUnits::define("eV", NULL);
    259     RpUnits* joules  = RpUnits::define("J", NULL);
     258    const RpUnits* eV  = RpUnits::define("eV", NULL);
     259    const RpUnits* joules  = RpUnits::define("J", NULL);
    260260   
    261261    RpUnits::define(eV, joules, electronVolt2joule, joule2electronVolt);
Note: See TracChangeset for help on using the changeset viewer.