Changeset 554


Ignore:
Timestamp:
Dec 9, 2006, 12:56:11 AM (18 years ago)
Author:
dkearney
Message:

adjusted units code removing const ints in favor of enum values
adjusted library code to include enum values
added time stamp abilities to rappture library's result function
added cplusplus define checks to header files for c and fortran bindings so people can compile with rappture.h

Location:
trunk/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/cee/RpLibraryCInterface.h

    r511 r554  
    1313
    1414
     15#ifndef _RpLIBRARY_C_H
     16#define _RpLIBRARY_C_H
     17
    1518#ifdef __cplusplus
    16 extern "C" {
    17 #endif
     19    extern "C" {
     20#endif // ifdef __cplusplus
    1821
    1922typedef struct RpLibrary RpLibrary;
     
    8083
    8184#ifdef __cplusplus
    82 }
    83 #endif
     85    }
     86#endif // ifdef __cplusplus
     87
     88#endif // ifndef _RpLIBRARY_C_H
  • trunk/src/cee/RpUnitsCInterface.h

    r511 r554  
    1212 */
    1313
     14#ifndef _RpUNITS_C_H
     15#define _RpUNITS_C_H
     16
    1417#ifdef __cplusplus
    15 extern "C" {
    16 #endif
     18    extern "C" {
     19#endif // ifdef __cplusplus
    1720
    1821    typedef struct RpUnits RpUnits;
     
    7174
    7275#ifdef __cplusplus
    73 }
    74 #endif
     76    }
     77#endif // ifdef __cplusplus
     78
     79#endif // ifndef _RpUNITS_C_H
  • trunk/src/core/RpLibrary.cc

    r543 r554  
    12051205    }
    12061206
    1207     if (translateFlag == TRANSLATE) {
     1207    if (translateFlag == RPLIB_TRANSLATE) {
    12081208        // translatedContents = new char[strlen(retCStr)+1];
    12091209        len = strlen(retCStr);
     
    13561356    if (retNode) {
    13571357
    1358         if (append) {
     1358        if (append == RPLIB_APPEND) {
    13591359            if ( (contents = scew_element_contents(retNode)) ) {
    13601360                tmpVal = std::string(contents);
     
    13631363        }
    13641364
    1365         if (translateFlag == TRANSLATE) {
     1365        if (translateFlag == RPLIB_TRANSLATE) {
    13661366            _translateIn(value,translatedContents);
    13671367            scew_element_set_contents(retNode,translatedContents.c_str());
     
    14291429    // old_elem = _find(path+"."+nodeName,NO_CREATE_PATH);
    14301430
    1431     if (!append) {
     1431    if (append == RPLIB_OVERWRITE) {
    14321432        retNode = _find(path,NO_CREATE_PATH);
    14331433        if (retNode) {
     
    16211621    std::string xmlText = "";
    16221622    time_t t = 0;
     1623    struct tm* timeinfo = NULL;
     1624    std::string timestamp = "";
    16231625
    16241626    if (this->root) {
     
    16291631        put("tool.repository.rappture.revision","$Rev$");
    16301632        put("tool.repository.rappture.url","$URL$");
     1633
     1634        // generate a timestamp for the run file
     1635        timeinfo = localtime(&t);
     1636        timestamp = std::string(ctime(&t));
     1637        // erase the 24th character because it is a newline
     1638        timestamp.erase(24);
     1639        // concatinate the timezone
     1640        timestamp.append(" ");
     1641        timestamp.append(timeinfo->tm_zone);
     1642
     1643        // add the timestamp to the run file
     1644        put("output.time", timestamp);
    16311645
    16321646        if ( file.is_open() ) {
  • trunk/src/core/RpLibrary.h

    r511 r554  
    1212 */
    1313
     14#ifndef _RpLIBRARY_H
     15#define _RpLIBRARY_H
     16
     17enum RP_LIBRARY_CONSTS {
     18    RPLIB_OVERWRITE     = 0,
     19    RPLIB_APPEND        = 1,
     20    RPLIB_NO_TRANSLATE  = 0,
     21    RPLIB_TRANSLATE     = 1,
     22};
     23
     24
     25#ifdef __cplusplus
     26
    1427#include "scew/scew.h"
    1528#include "scew_extras.h"
     
    2740
    2841/* indentation size (in whitespaces) */
     42
    2943#define INDENT_SIZE 4
    3044#define CREATE_PATH 1
     
    3549#define NO_TRANSLATE 0
    3650
    37 #ifndef _RpLIBRARY_H
    38 #define _RpLIBRARY_H
    39 
    40 
    4151class RpLibrary
    4252{
     
    7181
    7282        std::string get       ( std::string path = "",
    73                                 int translateFlag = TRANSLATE);
     83                                int translateFlag = RPLIB_TRANSLATE);
    7484        std::string getString ( std::string path = "",
    75                                 int translateFlag = TRANSLATE);
     85                                int translateFlag = RPLIB_TRANSLATE);
    7686
    7787        double      getDouble ( std::string path = "");
     
    8393        RpLibrary&  get       ( std::string path = "",
    8494                                std::string retVal = "",
    85                                 int translateFlag = TRANSLATE);
     95                                int translateFlag = RPLIB_TRANSLATE);
    8696
    8797        RpLibrary&  get       ( std::string path = "",
    8898                                double retVal = 0.0,
    89                                 int translateFlag = TRANSLATE);
     99                                int translateFlag = RPLIB_TRANSLATE);
    90100
    91101        RpLibrary&  get       ( std::string path = "",
    92102                                int retVal = 0,
    93                                 int translateFlag = TRANSLATE);
     103                                int translateFlag = RPLIB_TRANSLATE);
    94104
    95105        RpLibrary&  get       ( std::string path = "",
    96106                                bool retVal = false,
    97                                 int translateFlag = TRANSLATE);
     107                                int translateFlag = RPLIB_TRANSLATE);
    98108        */
    99109
     
    101111                            std::string value,
    102112                            std::string id = "",
    103                             int append = 0,
    104                             int translateFlag = TRANSLATE);
     113                            int append = RPLIB_OVERWRITE,
     114                            int translateFlag = RPLIB_TRANSLATE   );
    105115
    106116        RpLibrary& put (    std::string path,
    107117                            double value,
    108118                            std::string id = "",
    109                             int append = 0  );
     119                            int append = RPLIB_OVERWRITE    );
    110120
    111121        RpLibrary& put (    std::string path,
    112122                            RpLibrary* value,
    113123                            std::string id = "",
    114                             int append = 0  );
     124                            int append = RPLIB_OVERWRITE    );
    115125
    116126        RpLibrary* remove (std::string path = "");
     
    443453/*--------------------------------------------------------------------------*/
    444454
    445 #endif
     455#endif // ifdef __cplusplus
     456
     457#endif // ifndef _RpLIBRARY_H
  • trunk/src/core/RpUnits.cc

    r544 r554  
    1919// set the dictionary to be case insensitive for seaches and storage
    2020RpDict<std::string,RpUnits*,RpUnits::_key_compare>* RpUnits::dict =
    21     new RpDict<std::string,RpUnits*,RpUnits::_key_compare>(true);
     21    new RpDict<std::string,RpUnits*,RpUnits::_key_compare>(
     22        RPUNITS_CASE_INSENSITIVE);
    2223
    2324// install predefined units
    2425static RpUnitsPreset loader;
    25 
    26 // convert function flags
    27 const int RpUnits::UNITS_OFF = 0;
    28 const int RpUnits::UNITS_ON  = 1;
    2926
    3027/**********************************************************************/
     
    646643
    647644    name = "m" + basisName;
    648     RpUnits * milli = RpUnits::define(name, basis, basis->type,!RPUNITS_CI);
     645    RpUnits * milli = RpUnits::define(name, basis, basis->type,
     646        !RPUNITS_CASE_INSENSITIVE);
    649647    RpUnits::define(milli, basis, milli2base, base2milli);
    650648
     
    658656
    659657    name = "p" + basisName;
    660     RpUnits * pico  = RpUnits::define(name, basis, basis->type,!RPUNITS_CI);
     658    RpUnits * pico  = RpUnits::define(name, basis, basis->type,
     659        !RPUNITS_CASE_INSENSITIVE);
    661660    RpUnits::define(pico, basis, pico2base, base2pico);
    662661
     
    682681
    683682    name = "M" + basisName;
    684     RpUnits * mega  = RpUnits::define(name, basis, basis->type,!RPUNITS_CI);
     683    RpUnits * mega  = RpUnits::define(name, basis, basis->type,
     684        !RPUNITS_CASE_INSENSITIVE);
    685685    RpUnits::define(mega, basis, mega2base, base2mega);
    686686
     
    694694
    695695    name = "P" + basisName;
    696     RpUnits * peta  = RpUnits::define(name, basis, basis->type,!RPUNITS_CI);
     696    RpUnits * peta  = RpUnits::define(name, basis, basis->type,
     697        !RPUNITS_CASE_INSENSITIVE);
    697698    RpUnits::define(peta, basis, peta2base, base2peta);
    698699
     
    12011202        }
    12021203
    1203         if (showUnits) {
     1204        if (showUnits == RPUNITS_UNITS_ON) {
    12041205            outVal << numVal << fromUnitsName;
    12051206        }
     
    12231224        }
    12241225
    1225         if (showUnits) {
     1226        if (showUnits == RPUNITS_UNITS_ON) {
    12261227            outVal << numVal << toUnitsName;
    12271228        }
     
    13951396                // outVal.flags(std::ios::fixed);
    13961397                // outVal.precision(10);
    1397                 if (showUnits) {
     1398                if (showUnits == RPUNITS_UNITS_ON) {
    13981399                    outVal << numVal << toUnitsName;
    13991400                }
     
    14341435
    14351436
    1436     if (showUnits) {
     1437    if (showUnits == RPUNITS_UNITS_ON) {
    14371438        unitText << retVal << toUnits->getUnitsName();
    14381439    }
  • trunk/src/core/RpUnits.h

    r544 r554  
    1313 * ======================================================================
    1414 */
    15 #include <iostream>
    16 #include <string>
    17 #include <list>
    18 #include <sstream>
    19 #include <stdlib.h>
    20 #include <errno.h>
    21 #include <math.h>
    22 
    23 #include "RpDict.h"
    24 #include "RpUnitsStd.h"
    2515
    2616#ifndef _RpUNITS_H
    2717#define _RpUNITS_H
    2818
    29 #define LIST_TEMPLATE RpUnitsListEntry
     19enum RP_UNITS_CONSTS {
     20    RPUNITS_UNITS_OFF           = 0,
     21    RPUNITS_UNITS_ON            = 1
     22};
    3023
    3124// RpUnits Case Insensitivity define
    32 #define RPUNITS_CI true
    33 
     25#define RPUNITS_CASE_INSENSITIVE true
     26//
    3427//define our different types of units
    3528#define RP_TYPE_ENERGY      "energy"
     
    4437#define RP_TYPE_MISC        "misc"
    4538
    46 // should the define function:
    47 // 1. compare portions of inStr to unit names that have previously
    48 //    been defined (you must parse in order for this option to work)
    49 #define COMPARE_MASK    1
    50 // 2. create a unit if no unit by the name exists.
    51 #define CREATE_MASK     2
    52 // 3. parse the unit name to try to find previously defined units.
    53 #define PARSE_MASK      4
     39
     40#ifdef __cplusplus
     41
     42#include <iostream>
     43#include <string>
     44#include <list>
     45#include <sstream>
     46#include <stdlib.h>
     47#include <errno.h>
     48#include <math.h>
     49
     50#include "RpDict.h"
     51#include "RpUnitsStd.h"
     52
     53#define LIST_TEMPLATE RpUnitsListEntry
    5454
    5555class RpUnits;
     
    329329    public:
    330330
    331         // constant static class variables
    332         // flags to tell how convert should return the value
    333         static const int UNITS_OFF;
    334         static const int UNITS_ON;
    335 
    336331        // users member fxns
    337332        std::string getUnits() const;
     
    364359        std::string convert (   const RpUnits* toUnits,
    365360                                double val,
    366                                 int showUnits = 0,
     361                                int showUnits = RPUNITS_UNITS_OFF,
    367362                                int* result = NULL  ) const;
    368 
    369         static std::string convert1 ( std::string val,
    370                                      std::string toUnits,
    371                                      int showUnits,
    372                                      int* result = NULL );
    373363
    374364        static std::string convert ( std::string val,
    375365                                     std::string toUnits,
    376                                      int showUnits,
     366                                     int showUnits = RPUNITS_UNITS_OFF,
    377367                                     int* result = NULL );
    378 
    379         /*
    380         static std::string convert ( std::string val,
    381                                      std::string toUnits,
    382                                      int showUnits,
    383                                      int* result = NULL );
    384         */
    385368
    386369        // turn the current unit to the metric system
     
    414397                                const RpUnits* basis=NULL,
    415398                                const std::string type="",
    416                                 bool caseInsensitive=RPUNITS_CI);
     399                                bool caseInsensitive=RPUNITS_CASE_INSENSITIVE);
    417400
    418401        // add relation rule
     
    713696/*--------------------------------------------------------------------------*/
    714697
    715 #endif
     698#endif // ifdef __cplusplus
     699
     700#endif // ifndef _RpUNITS_H
  • trunk/src/fortran/RpLibraryFInterface.h

    r511 r554  
    1212 */
    1313
    14 #include "RpLibrary.h"
    15 #include <string.h>
    16 #include <fstream>
    17 #include "RpFortranCommon.h"
    18 #include "RpLibraryFStubs.h"
     14#ifndef _RpLIBRARY_F_H
     15#define _RpLIBRARY_F_H
    1916
    2017#ifdef __cplusplus
     18    #include "RpLibrary.h"
     19    #include <string.h>
     20    #include <fstream>
     21    #include "RpFortranCommon.h"
     22    #include "RpLibraryFStubs.h"
     23
    2124    extern "C" {
    22 #endif
     25#endif // ifdef __cplusplus
    2326
    2427int rp_lib ( const char* filePath, int filePath_len );
     
    154157#ifdef __cplusplus
    155158    }
    156 #endif
     159#endif // ifdef __cplusplus
     160
     161#endif // ifndef _RpLIBRARY_F_H
  • trunk/src/fortran/RpUnitsFInterface.h

    r511 r554  
    1515#define _RpUNITS_F_H
    1616
    17 #include "RpFortranCommon.h"
    18 #include "RpUnitsFStubs.h"
     17#ifdef __cplusplus
     18    #include "RpFortranCommon.h"
     19    #include "RpUnitsFStubs.h"
    1920
    20 #ifdef __cplusplus
    21 extern "C" {
     21    extern "C" {
    2222#endif
    2323
     
    5050
    5151#ifdef __cplusplus
    52 }
    53 #endif
     52    }
     53#endif // ifdef __cplusplus
    5454
    55 #endif
     55#endif // ifndef _RpUNITS_F_H
Note: See TracChangeset for help on using the changeset viewer.