Changeset 93
- Timestamp:
- Oct 6, 2005 3:33:41 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/c-example/plotc.c
r92 r93 2 2 3 3 //#include <stdlib.h> 4 #include <time.h>5 4 #include <string.h> 6 5 #include <stdio.h> … … 33 32 34 33 // create a rappture library from the file filePath 35 lib = library(argv[1]);34 lib = rpLibrary(argv[1]); 36 35 37 36 if (lib) { … … 47 46 48 47 // get the xml that is stored in the rappture library lib 49 if( (xmltext = xml(lib)) ) {48 if( (xmltext = rpXml(lib)) ) { 50 49 if(DEBUG) { 51 50 //printf("XML file content:\n"); … … 59 58 60 59 // get the min 61 xmltext = getString (lib, "input.number(min).current");60 xmltext = rpGetString (lib, "input.number(min).current"); 62 61 63 62 if (! (xmltext) ) { … … 81 80 82 81 // get the max 83 fmax = getDouble(lib,"input.(max).current");82 fmax = rpGetDouble(lib,"input.(max).current"); 84 83 if(DEBUG) { 85 84 printf("max: %f\n", fmax); … … 91 90 fy = sin(fx); 92 91 sprintf(str, "%f %f\n", fx, fy); 93 put(lib, "output.curve.component.xy", str, "result", 1);92 rpPut(lib, "output.curve.component.xy", str, "result", 1); 94 93 } 95 94 96 95 97 96 // write output to run file and signal 98 r esult(lib);97 rpResult(lib); 99 98 99 // free the rappture library 100 rpFreeLibrary(lib); 101 102 // exit program 100 103 return 0; 101 104 } -
trunk/include/cee/RpLibraryCInterface.h
r83 r93 18 18 19 19 // unit definition functions 20 RpLibrary* library (const char* path);21 void freeLibrary (RpLibrary* lib);20 RpLibrary* rpLibrary (const char* path); 21 void rpFreeLibrary (RpLibrary* lib); 22 22 23 23 // RpLibrary member functions 24 RpLibrary* element (RpLibrary* lib, const char* path);25 RpLibrary* elementAsObject (RpLibrary* lib, const char* path);26 const char* elementAsType (RpLibrary* lib, const char* path);27 const char* elementAsComp (RpLibrary* lib, const char* path);28 const char* elementAsId (RpLibrary* lib, const char* path);24 RpLibrary* rpElement (RpLibrary* lib, const char* path); 25 RpLibrary* rpElementAsObject (RpLibrary* lib, const char* path); 26 const char* rpElementAsType (RpLibrary* lib, const char* path); 27 const char* rpElementAsComp (RpLibrary* lib, const char* path); 28 const char* rpElementAsId (RpLibrary* lib, const char* path); 29 29 30 RpLibrary* children (RpLibrary* lib,31 const char* path, 30 RpLibrary* rpChildren (RpLibrary* lib, 31 const char* path, 32 32 RpLibrary* childEle); 33 RpLibrary* childrenByType (RpLibrary* lib,34 const char* path, 35 RpLibrary* childEle, 33 RpLibrary* rpChildrenByType (RpLibrary* lib, 34 const char* path, 35 RpLibrary* childEle, 36 36 const char* type ); 37 RpLibrary* childrenAsObject (RpLibrary* lib,38 const char* path, 37 RpLibrary* rpChildrenAsObject (RpLibrary* lib, 38 const char* path, 39 39 const char* type ); 40 const char* childrenAsType (RpLibrary* lib,41 const char* path, 40 const char* rpChildrenAsType (RpLibrary* lib, 41 const char* path, 42 42 const char* type ); 43 const char* childrenAsComp (RpLibrary* lib,44 const char* path, 43 const char* rpChildrenAsComp (RpLibrary* lib, 44 const char* path, 45 45 const char* type ); 46 const char* childrenAsId (RpLibrary* lib,47 const char* path, 46 const char* rpChildrenAsId (RpLibrary* lib, 47 const char* path, 48 48 const char* type ); 49 49 50 RpLibrary* get (RpLibrary* lib, const char* path);51 const char* getString (RpLibrary* lib, const char* path);52 double getDouble (RpLibrary* lib, const char* path);50 RpLibrary* rpGet (RpLibrary* lib, const char* path); 51 const char* rpGetString (RpLibrary* lib, const char* path); 52 double rpGetDouble (RpLibrary* lib, const char* path); 53 53 54 void put (RpLibrary* lib,55 const char* path, 54 void rpPut (RpLibrary* lib, 55 const char* path, 56 56 const char* value, 57 57 const char* id, 58 58 int append ); 59 void putStringId (RpLibrary* lib,60 const char* path, 59 void rpPutStringId (RpLibrary* lib, 60 const char* path, 61 61 const char* value, 62 62 const char* id, 63 63 int append ); 64 void putString (RpLibrary* lib,65 const char* path, 64 void rpPutString (RpLibrary* lib, 65 const char* path, 66 66 const char* value, 67 67 int append ); 68 void putDoubleId (RpLibrary* lib,69 const char* path, 68 void rpPutDoubleId (RpLibrary* lib, 69 const char* path, 70 70 double value, 71 71 const char* id, 72 72 int append ); 73 void putDouble (RpLibrary* lib,74 const char* path, 73 void rpPutDouble (RpLibrary* lib, 74 const char* path, 75 75 double value, 76 76 int append ); 77 77 78 const char* xml (RpLibrary* lib);78 const char* rpXml (RpLibrary* lib); 79 79 80 const char* nodeComp (RpLibrary* node);81 const char* nodeType (RpLibrary* node);82 const char* nodeId (RpLibrary* node);80 const char* rpNodeComp (RpLibrary* node); 81 const char* rpNodeType (RpLibrary* node); 82 const char* rpNodeId (RpLibrary* node); 83 83 84 void r esult (RpLibrary* lib);84 void rpResult (RpLibrary* lib); 85 85 86 86 #ifdef __cplusplus -
trunk/include/cee/RpUnitsCInterface.h
r83 r93 12 12 #ifdef __cplusplus 13 13 extern "C" { 14 #endif 14 #endif 15 15 16 16 typedef struct RpUnits RpUnits; 17 17 18 18 // unit definition functions 19 RpUnits* defineUnit(const char* unitSymbol, RpUnits* basis);19 RpUnits* rpDefineUnit ( const char* unitSymbol, RpUnits* basis ); 20 20 21 21 // conversion definition functions 22 RpUnits* defineConv(RpUnits* fromUnit,23 RpUnits* toUnit,24 double (*convForwFxnPtr)(double),25 double (*convBackFxnPtr)(double) );22 RpUnits* rpDefineConv ( RpUnits* fromUnit, 23 RpUnits* toUnit, 24 double (*convForwFxnPtr)(double), 25 double (*convBackFxnPtr)(double) ); 26 26 27 27 // unit attribute access functions 28 const char* getUnits(RpUnits* unit);28 const char* rpGetUnits ( RpUnits* unit ); 29 29 30 const char* getUnitsName(RpUnits* unit);30 const char* rpGetUnitsName ( RpUnits* unit ); 31 31 32 double getExponent(RpUnits* unit);32 double rpGetExponent ( RpUnits* unit ); 33 33 34 RpUnits* getBasis(RpUnits* unit);34 RpUnits* rpGetBasis ( RpUnits* unit); 35 35 36 RpUnits* find(const char* unitSymbol);36 RpUnits* rpFind ( const char* unitSymbol); 37 37 38 int makeMetric(RpUnits* basis);38 int rpMakeMetric ( RpUnits* basis ); 39 39 40 // convert functions 40 // convert functions 41 41 42 const char* convert (const char* fromVal,43 const char* toUnitsName,44 int showUnits,45 int* result );42 const char* rpConvert ( const char* fromVal, 43 const char* toUnitsName, 44 int showUnits, 45 int* result ); 46 46 47 const char* convert_str (const char* fromVal,48 const char* toUnitsName,49 int showUnits,50 int* result );47 const char* rpConvertStr ( const char* fromVal, 48 const char* toUnitsName, 49 int showUnits, 50 int* result ); 51 51 52 const char* convert_obj_str ( RpUnits* fromUnits, 53 RpUnits* toUnits, 54 double val, 55 int showUnits ); 52 const char* rpConvert_ObjStr ( RpUnits* fromUnits, 53 RpUnits* toUnits, 54 double val, 55 int showUnits, 56 int* result ); 56 57 57 const char* convert_obj_str_result( RpUnits* fromUnits, 58 RpUnits* toUnits, 59 double val, 60 int showUnits, 61 int* result ); 58 double rpConvertDbl ( const char* fromVal, 59 const char* toUnitsName, 60 int* result ); 62 61 63 double convert_dbl ( const char* fromVal, 64 const char* toUnitsName, 65 int* result ); 62 double rpConvert_ObjDbl ( RpUnits* fromUnits, 63 RpUnits* toUnits, 64 double val, 65 int* result ); 66 66 67 double convert_obj_double ( RpUnits* fromUnits, 68 RpUnits* toUnits, 69 double val ); 70 71 double convert_obj_double_result ( RpUnits* fromUnits, 72 RpUnits* toUnits, 73 double val, 74 int* result ); 75 76 int add_presets(const char* presetName); 67 int rpAddPresets ( const char* presetName ); 77 68 78 69 #ifdef __cplusplus -
trunk/include/fortran/RpLibraryFInterface.h
r84 r93 4 4 * 5 5 * ====================================================================== 6 * AUTHOR: Derrick Kearney, Purdue University6 * AUTHOR: Derrick S. Kearney, Purdue University 7 7 * Copyright (c) 2005 8 8 * Purdue Research Foundation, West Lafayette, IN … … 11 11 12 12 #include "RpLibrary.h" 13 #include "RpDict.h"14 13 #include <string.h> 15 14 #include <fstream> … … 150 149 /**********************************************************/ 151 150 152 /**********************************************************/153 154 // private member functions155 int objType( char* flavor);156 157 int storeObject_Lib(RpLibrary* objectName);158 RpLibrary* getObject_Lib(int objKey);159 160 // global vars161 // dictionary to hold the python objects that162 // cannot be sent to fortran163 164 #define DICT_TEMPLATE <int,RpLibrary*>165 RpDict DICT_TEMPLATE fortObjDict_Lib;166 167 151 #ifdef __cplusplus 168 152 } -
trunk/src/Makefile
r90 r93 73 73 scew_extras.o 74 74 RP_UNITS_DEPS = RpUnitsStd.o RpUnits.o RpUnitsCInterface.o RpUnitsFInterface.o 75 RP_OTHER_DEPS = RpFortranCommon.o #RpBindingsDict.o75 RP_OTHER_DEPS = RpFortranCommon.o RpBindingsDict.o 76 76 RP_OBJS_DEP = RpVariable.o RpAbout.o RpNumber.o RpString.o RpBoolean.o \ 77 77 RpChoice.o RpOption.o RpUnitsStd.o RpUnits.o -
trunk/src/cee/RpLibraryCInterface.cc
r83 r93 18 18 19 19 RpLibrary* 20 library (const char* path)20 rpLibrary (const char* path) 21 21 { 22 22 return new RpLibrary(path); … … 24 24 25 25 void 26 freeLibrary (RpLibrary* lib)26 rpFreeLibrary (RpLibrary* lib) 27 27 { 28 28 delete lib; … … 31 31 32 32 RpLibrary* 33 element (RpLibrary* lib, const char* path)33 rpElement (RpLibrary* lib, const char* path) 34 34 { 35 35 return lib->element(path); … … 37 37 38 38 RpLibrary* 39 elementAsObject (RpLibrary* lib, const char* path)40 { 41 return element(lib,path);42 } 43 44 const char* 45 elementAsType (RpLibrary* lib, const char* path)39 rpElementAsObject (RpLibrary* lib, const char* path) 40 { 41 return rpElement(lib,path); 42 } 43 44 const char* 45 rpElementAsType (RpLibrary* lib, const char* path) 46 46 { 47 47 static std::string retStr = ""; … … 56 56 57 57 const char* 58 elementAsComp (RpLibrary* lib, const char* path)58 rpElementAsComp (RpLibrary* lib, const char* path) 59 59 { 60 60 static std::string retStr = ""; … … 69 69 70 70 const char* 71 elementAsId (RpLibrary* lib, const char* path)71 rpElementAsId (RpLibrary* lib, const char* path) 72 72 { 73 73 static std::string retStr = ""; … … 83 83 84 84 RpLibrary* 85 children (RpLibrary* lib, const char* path, RpLibrary* childEle )85 rpChildren (RpLibrary* lib, const char* path, RpLibrary* childEle ) 86 86 { 87 87 return lib->children(path,childEle); … … 89 89 90 90 RpLibrary* 91 childrenByType( RpLibrary* lib,91 rpChildrenByType( RpLibrary* lib, 92 92 const char* path, 93 93 RpLibrary* childEle, … … 98 98 99 99 RpLibrary* 100 get (RpLibrary* lib, const char* path)100 rpGet (RpLibrary* lib, const char* path) 101 101 { 102 102 return lib->get(path); … … 104 104 105 105 const char* 106 getString (RpLibrary* lib, const char* path)106 rpGetString (RpLibrary* lib, const char* path) 107 107 { 108 108 static std::string retStr = ""; … … 112 112 113 113 double 114 getDouble (RpLibrary* lib, const char* path)114 rpGetDouble (RpLibrary* lib, const char* path) 115 115 { 116 116 return lib->getDouble(path); … … 118 118 119 119 void 120 put (RpLibrary* lib,120 rpPut (RpLibrary* lib, 121 121 const char* path, 122 122 const char* value, … … 128 128 129 129 void 130 putStringId (RpLibrary* lib,130 rpPutStringId (RpLibrary* lib, 131 131 const char* path, 132 132 const char* value, … … 138 138 139 139 void 140 putString ( RpLibrary* lib,140 rpPutString ( RpLibrary* lib, 141 141 const char* path, 142 142 const char* value, … … 147 147 148 148 void 149 putDoubleId (RpLibrary* lib,149 rpPutDoubleId (RpLibrary* lib, 150 150 const char* path, 151 151 double value, … … 157 157 158 158 void 159 putDouble (RpLibrary* lib,159 rpPutDouble (RpLibrary* lib, 160 160 const char* path, 161 161 double value, … … 166 166 167 167 const char* 168 xml (RpLibrary* lib)168 rpXml (RpLibrary* lib) 169 169 { 170 170 static std::string retStr = ""; … … 174 174 175 175 const char* 176 nodeComp (RpLibrary* node)176 rpNodeComp (RpLibrary* node) 177 177 { 178 178 static std::string retStr = ""; … … 182 182 183 183 const char* 184 nodeType (RpLibrary* node)184 rpNodeType (RpLibrary* node) 185 185 { 186 186 static std::string retStr = ""; … … 190 190 191 191 const char* 192 nodeId (RpLibrary* node)192 rpNodeId (RpLibrary* node) 193 193 { 194 194 static std::string retStr = ""; … … 198 198 199 199 void 200 r esult (RpLibrary* lib)200 rpResult (RpLibrary* lib) 201 201 { 202 202 lib->result(); -
trunk/src/cee/RpUnitsCInterface.cc
r83 r93 17 17 #endif 18 18 19 RpUnits* defineUnit(const char* unitSymbol, RpUnits* basis) { 19 RpUnits* 20 rpDefineUnit(const char* unitSymbol, RpUnits* basis) { 20 21 21 return RpUnits::define(unitSymbol, basis); 22 return RpUnits::define(unitSymbol, basis); 23 } 24 25 RpUnits* 26 rpDefineConv( RpUnits* fromUnit, 27 RpUnits* toUnit, 28 double (*convForwFxnPtr)(double), 29 double (*convBackFxnPtr)(double) ) { 30 31 return RpUnits::define(fromUnit,toUnit,convForwFxnPtr,convBackFxnPtr); 32 } 33 34 RpUnits* 35 rpFind ( const char* key ) { 36 37 return RpUnits::find(key); 38 } 39 40 const char* 41 rpGetUnits ( RpUnits* unit ) { 42 43 static std::string retVal; 44 retVal = unit->getUnits(); 45 return retVal.c_str(); 46 } 47 48 const char* 49 rpGetUnitsName ( RpUnits* unit ) { 50 51 static std::string retVal; 52 retVal = unit->getUnitsName(); 53 return retVal.c_str(); 54 } 55 56 double 57 rpGetExponent ( RpUnits* unit ) { 58 59 return unit->getExponent(); 60 } 61 62 RpUnits* 63 rpGetBasis ( RpUnits* unit ) { 64 65 return unit->getBasis(); 66 } 67 68 int 69 rpMakeMetric(RpUnits* basis) { 70 71 return RpUnits::makeMetric(basis); 72 } 73 74 const char* 75 rpConvert ( const char* fromVal, 76 const char* toUnitsName, 77 int showUnits, 78 int* result ) { 79 80 static std::string retVal; 81 retVal = RpUnits::convert(fromVal,toUnitsName,showUnits,result); 82 return retVal.c_str(); 83 } 84 85 const char* 86 rpConvertStr ( const char* fromVal, 87 const char* toUnitsName, 88 int showUnits, 89 int* result ) { 90 91 static std::string retVal; 92 retVal = RpUnits::convert(fromVal,toUnitsName,showUnits,result); 93 return retVal.c_str(); 94 } 95 96 const char* 97 rpConvert_ObjStr ( RpUnits* fromUnits, 98 RpUnits* toUnits, 99 double val, 100 int showUnits, 101 int* result ) { 102 103 static std::string retVal; 104 retVal = fromUnits->convert(toUnits,val,showUnits,result); 105 return retVal.c_str(); 106 } 107 108 double 109 rpConvertDbl ( const char* fromVal, 110 const char* toUnitsName, 111 int* result ) { 112 113 std::string convStr; 114 double retVal = 0.0; 115 116 convStr = RpUnits::convert(fromVal,toUnitsName,0,result); 117 118 if (!convStr.empty()) { 119 retVal = atof(convStr.c_str()); 22 120 } 23 121 24 RpUnits* defineConv( RpUnits* fromUnit, 25 RpUnits* toUnit, 26 double (*convForwFxnPtr)(double), 27 double (*convBackFxnPtr)(double) ) { 122 return retVal; 123 } 28 124 29 return RpUnits::define(fromUnit,toUnit,convForwFxnPtr,convBackFxnPtr); 30 } 125 double 126 rpConvert_ObjDbl ( RpUnits* fromUnits, 127 RpUnits* toUnits, 128 double val, 129 int* result ) { 31 130 32 RpUnits* find(const char* key) { 131 return fromUnits->convert(toUnits,val,result); 132 } 33 133 34 return RpUnits::find(key); 35 } 134 int rpAddPresets ( const char* presetName ) { 36 135 37 const char* getUnits(RpUnits* unit) { 38 39 static std::string retVal; 40 retVal = unit->getUnits(); 41 return retVal.c_str(); 42 } 43 44 const char* getUnitsName(RpUnits* unit) { 45 46 static std::string retVal; 47 retVal = unit->getUnitsName(); 48 return retVal.c_str(); 49 } 50 51 double getExponent(RpUnits* unit) { 52 53 return unit->getExponent(); 54 } 55 56 RpUnits* getBasis(RpUnits* unit) { 57 58 return unit->getBasis(); 59 } 60 61 int makeMetric(RpUnits* basis) { 62 63 return RpUnits::makeMetric(basis); 64 } 65 66 const char* convert ( const char* fromVal, 67 const char* toUnitsName, 68 int showUnits, 69 int* result ) { 70 71 static std::string retVal; 72 retVal = RpUnits::convert(fromVal,toUnitsName,showUnits,result); 73 return retVal.c_str(); 74 } 75 76 const char* convert_str ( const char* fromVal, 77 const char* toUnitsName, 78 int showUnits, 79 int* result ) { 80 81 static std::string retVal; 82 retVal = RpUnits::convert(fromVal,toUnitsName,showUnits,result); 83 return retVal.c_str(); 84 } 85 86 const char* convert_obj_str( RpUnits* fromUnits, 87 RpUnits* toUnits, 88 double val, 89 int showUnits ) { 90 91 return convert_obj_str_result(fromUnits,toUnits,val,showUnits,NULL); 92 } 93 94 const char* convert_obj_str_result( RpUnits* fromUnits, 95 RpUnits* toUnits, 96 double val, 97 int showUnits, 98 int* result ) { 99 100 static std::string retVal; 101 retVal = fromUnits->convert(toUnits,val,showUnits,result); 102 return retVal.c_str(); 103 } 104 105 double convert_dbl ( const char* fromVal, 106 const char* toUnitsName, 107 int* result ) { 108 109 std::string convStr; 110 double retVal = 0.0; 111 112 convStr = RpUnits::convert(fromVal,toUnitsName,0,result); 113 114 if (!convStr.empty()) { 115 retVal = atof(convStr.c_str()); 116 } 117 118 return retVal; 119 } 120 121 double convert_obj_double( RpUnits* fromUnits, 122 RpUnits* toUnits, 123 double val ) { 124 125 return convert_obj_double_result(fromUnits,toUnits,val,NULL); 126 } 127 128 double convert_obj_double_result( RpUnits* fromUnits, 129 RpUnits* toUnits, 130 double val, 131 int* result ) { 132 133 return fromUnits->convert(toUnits,val,result); 134 } 135 136 int add_presets ( const char* presetName ) { 137 138 return RpUnits::addPresets(presetName); 139 } 136 return RpUnits::addPresets(presetName); 137 } 140 138 141 139 #ifdef __cplusplus -
trunk/src/fortran/RpLibraryFInterface.cc
r84 r93 11 11 12 12 #include "RpLibraryFInterface.h" 13 #include "RpBindingsDict.h" 13 14 #include "RpLibraryFStubs.c" 14 15 … … 403 404 PyObject* lib = NULL; 404 405 PyObject* list = NULL; 405 406 406 407 char* inPath = NULL; 407 408 char* inType = NULL; … … 413 414 if ((handle) && (*handle != 0)) { 414 415 lib = getObject_Lib(*handle); 415 416 416 417 if (lib) { 417 418 list = rpChildren_f(lib, inPath, "object"); … … 423 424 } 424 425 else { 425 426 426 427 } 427 428 } … … 606 607 PyObject* lib = NULL; 607 608 PyObject* value = NULL; 608 609 609 610 char* inPath = NULL; 610 611 char* inId = NULL; … … 617 618 lib = getObject_Lib(*handle); 618 619 value = getObject_Lib(*valHandle); 619 620 620 621 if (lib && value) { 621 622 // retObj is a borrowed object … … 811 812 // clean up the dictionary 812 813 813 RpDictEntry DICT_TEMPLATE *hPtr; 814 // RpDictIterator DICT_TEMPLATE iter((RpDict&)*this); 815 RpDictIterator DICT_TEMPLATE iter(fortObjDict_Lib); 814 RpDictEntry DICT_TEMPLATE_L *hPtr; 815 // RpDictIterator DICT_TEMPLATE iter(fortObjDict_Lib); 816 // should rp_quit clean up the dict or some function in RpBindingsCommon.h 817 RpDictIterator DICT_TEMPLATE_L iter(ObjDict_Lib); 816 818 817 819 hPtr = iter.first(); … … 823 825 } 824 826 825 if (fortObjDict_Lib.size()) { 827 // if (fortObjDict_Lib.size()) { 828 if (ObjDict_Lib.size()) { 826 829 // probably want to change the warning sometime 827 830 // printf("\nWARNING: internal dictionary is not empty..deleting\n"); … … 841 844 } 842 845 843 int objType( char* flavor)844 {845 if (flavor == NULL) {846 // return a PyObject*847 return 0;848 }849 else if((*flavor == 'o')&&(strncmp(flavor,"object", 6)==0)){850 // return a PyObject*851 return 0;852 }853 else if (854 ((*flavor == 't')&&(strncmp(flavor,"type", 4) == 0))855 ||((*flavor == 'i')&&(strncmp(flavor,"id", 2) == 0))856 ||((*flavor == 'c')&&(strncmp(flavor,"component", 9) == 0)))857 {858 // return a char*859 // convert the result to c style strings860 return 1;861 }862 else {863 // unrecognized format864 return -1;865 }866 }867 868 int storeObject_Lib(RpLibrary* objectName) {869 870 int retVal = -1;871 int dictKey = fortObjDict_Lib.size() + 1;872 int newEntry = 0;873 874 if (objectName) {875 // dictionary returns a reference to the inserted value876 // no error checking to make sure it was successful in entering877 // the new entry.878 fortObjDict_Lib.set(dictKey,objectName, &newEntry);879 }880 881 retVal = dictKey;882 return retVal;883 }884 885 RpLibrary* getObject_Lib(int objKey) {886 887 RpLibrary* retVal = *(fortObjDict_Lib.find(objKey).getValue());888 889 if (retVal == *(fortObjDict_Lib.getNullEntry().getValue())) {890 retVal = NULL;891 }892 893 return retVal;894 895 } -
trunk/src/fortran/RpUnitsFInterface.cc
r84 r93 11 11 12 12 #include "RpUnits.h" 13 #include "RpDict.h"14 13 #include "string.h" 15 14 #include "RpUnitsFInterface.h" 16 15 #include "RpUnitsFStubs.c" 17 18 #define DICT_TEMPLATE <int,std::string> 19 RpDict DICT_TEMPLATE fortObjDictUnits; 20 21 int storeObject_UnitsStr(std::string objectName); 22 RpUnits* getObject_UnitsInt(int objKey); 16 #include "RpBindingsDict.h" 23 17 24 18 int … … 37 31 38 32 if (basisName && *basisName) { 39 basisStrName = fortObjDictUnits.find(*basisName); 33 // basisStrName = fortObjDictUnits.find(*basisName); 34 basisStrName = ObjDictUnits.find(*basisName); 40 35 41 36 if (basisStrName != "") { … … 89 84 90 85 if (basis && *basis) { 91 newBasis = getObject_Units Int(*basis);86 newBasis = getObject_UnitsStr(*basis); 92 87 93 88 if (newBasis) { … … 107 102 108 103 if (unitRefVal && *unitRefVal) { 109 unitObj = getObject_Units Int(*unitRefVal);104 unitObj = getObject_UnitsStr(*unitRefVal); 110 105 if (unitObj) { 111 106 unitNameText = unitObj->getUnits(); … … 125 120 126 121 if (unitRefVal && *unitRefVal) { 127 unitObj = getObject_Units Int(*unitRefVal);122 unitObj = getObject_UnitsStr(*unitRefVal); 128 123 if (unitObj) { 129 124 unitNameText = unitObj->getUnitsName(); … … 142 137 143 138 if (unitRefVal && *unitRefVal) { 144 unitObj = getObject_Units Int(*unitRefVal);139 unitObj = getObject_UnitsStr(*unitRefVal); 145 140 if (unitObj) { 146 141 *retExponent = unitObj->getExponent(); … … 159 154 160 155 if (unitRefVal && *unitRefVal) { 161 unitObj = getObject_Units Int(*unitRefVal);156 unitObj = getObject_UnitsStr(*unitRefVal); 162 157 163 158 if (unitObj) { … … 275 270 } 276 271 277 278 279 280 //**********************************************************************//281 282 283 int284 storeObject_UnitsStr(std::string objectName) {285 286 int retVal = -1;287 int dictNextKey = fortObjDictUnits.size() + 1;288 int newEntry = 0;289 290 if (objectName != "") {291 // dictionary returns a reference to the inserted value292 // no error checking to make sure it was successful in entering293 // the new entry.294 fortObjDictUnits.set(dictNextKey,objectName, &newEntry);295 }296 297 retVal = dictNextKey;298 return retVal;299 }300 301 RpUnits*302 getObject_UnitsInt(int objKey) {303 304 std::string basisName = *(fortObjDictUnits.find(objKey).getValue());305 306 if (basisName == *(fortObjDictUnits.getNullEntry().getValue())) {307 // basisName = "";308 return NULL;309 }310 311 return RpUnits::find(basisName);312 313 } -
trunk/test/src/RpLibraryC_test.c
r83 r93 28 28 printf("TESTING ELEMENT: path = %s\n", path); 29 29 30 searchEle = element(lib,path);31 type = elementAsType(lib,path);32 comp = elementAsComp(lib,path);33 id = elementAsId(lib,path);30 searchEle = rpElement(lib,path); 31 type = rpElementAsType(lib,path); 32 comp = rpElementAsComp(lib,path); 33 id = rpElementAsId(lib,path); 34 34 35 35 if (!searchEle) { … … 42 42 printf("searchEle type = :%s:\n", type); 43 43 44 comp = nodeComp(searchEle);45 id = nodeId(searchEle);46 type = nodeType(searchEle);47 44 comp = rpNodeComp(searchEle); 45 id = rpNodeId(searchEle); 46 type = rpNodeType(searchEle); 47 48 48 printf("searchEle comp = :%s:\n", comp); 49 49 printf("searchEle id = :%s:\n", id); … … 63 63 printf("TESTING GET String: path = %s\n", path); 64 64 65 searchVal = getString(lib,path);65 searchVal = rpGetString(lib,path); 66 66 67 67 if (!searchVal || *searchVal == '\0') { … … 84 84 printf("TESTING GET Double: path = %s\n", path); 85 85 86 searchVal = getDouble(lib,path);86 searchVal = rpGetDouble(lib,path); 87 87 88 88 printf("searchVal = :%f:\n", searchVal); … … 102 102 printf("TESTING CHILDREN: path = %s\n", path); 103 103 104 while ( (childEle = children(lib,path,childEle)) ) {105 comp = nodeComp(childEle);106 id = nodeId(childEle);107 type = nodeType(childEle);104 while ( (childEle = rpChildren(lib,path,childEle)) ) { 105 comp = rpNodeComp(childEle); 106 id = rpNodeId(childEle); 107 type = rpNodeType(childEle); 108 108 109 109 printf("childEle comp = :%s:\n",comp); … … 128 128 printf("TESTING CHILDREN: path = %s\n", path); 129 129 130 while ( (childEle = childrenByType(lib,path,childEle,searchType)) ) {131 comp = nodeComp(childEle);132 id = nodeId(childEle);133 type = nodeType(childEle);130 while ( (childEle = rpChildrenByType(lib,path,childEle,searchType)) ) { 131 comp = rpNodeComp(childEle); 132 id = rpNodeId(childEle); 133 type = rpNodeType(childEle); 134 134 135 135 printf("childEle comp = :%s:\n",comp); … … 151 151 printf("TESTING PUT String: path = %s\n", path); 152 152 153 putString(lib,path,value,append);154 searchVal = getString(lib, path);153 rpPutString(lib,path,value,append); 154 searchVal = rpGetString(lib, path); 155 155 156 156 if (!searchVal || *searchVal == '\0') { … … 173 173 printf("TESTING PUT String: path = %s\n", path); 174 174 175 putDouble(lib,path,value,append);176 searchVal = getDouble(lib, path);175 rpPutDouble(lib,path,value,append); 176 searchVal = rpGetDouble(lib, path); 177 177 printf("searchVal = :%f:\n", searchVal); 178 178 retVal = 0; … … 186 186 RpLibrary* lib = NULL; 187 187 188 if (argc < 3)188 if (argc < 2) 189 189 { 190 printf("usage: RpLibrary_test infile.xml outfile.xml\n");190 printf("usage: %s driver.xml\n", argv[0]); 191 191 return -1; 192 192 } 193 193 194 lib = library(argv[1]);194 lib = rpLibrary(argv[1]); 195 195 196 196 test_element(lib,"input.number(min)"); … … 217 217 test_childrenByType(lib,"input.number(test)","preset"); 218 218 219 printf("XML = \n%s\n", xml(lib));219 printf("XML = \n%s\n",rpXml(lib)); 220 220 221 freeLibrary(lib);221 rpFreeLibrary(lib); 222 222 223 223 return 0; -
trunk/test/src/RpLibraryF_test.f
r84 r93 5 5 c 6 6 c ====================================================================== 7 c AUTHOR: Derrick Kearney, Purdue University7 c AUTHOR: Derrick S. Kearney, Purdue University 8 8 c Copyright (c) 2005 9 9 c Purdue Research Foundation, West Lafayette, IN -
trunk/test/src/RpUnitsC_test.c
r76 r93 48 48 } 49 49 50 int main() 50 int main() 51 51 { 52 52 53 RpUnits* meters = defineUnit("m",NULL);53 RpUnits* meters = rpDefineUnit("m",NULL); 54 54 55 55 RpUnits* centimeters = NULL; … … 57 57 RpUnits* cm_basis = NULL; 58 58 59 RpUnits* angstrom = defineUnit("A",NULL);60 RpUnits* fahrenheit = defineUnit("F",NULL);61 RpUnits* celcius = defineUnit("C",NULL);62 RpUnits* kelvin = defineUnit("K",NULL);59 RpUnits* angstrom = rpDefineUnit("A",NULL); 60 RpUnits* fahrenheit = rpDefineUnit("F",NULL); 61 RpUnits* celcius = rpDefineUnit("C",NULL); 62 RpUnits* kelvin = rpDefineUnit("K",NULL); 63 63 64 defineConv(angstrom, meters, angstrom2meter, meter2angstrom);65 defineConv(fahrenheit, celcius, fahrenheit2centigrade, centigrade2fahrenheit);66 defineConv(celcius, kelvin, centigrade2kelvin, kelvin2centigrade);67 68 64 rpDefineConv(angstrom, meters, angstrom2meter, meter2angstrom); 65 rpDefineConv(fahrenheit, celcius, fahrenheit2centigrade, centigrade2fahrenheit); 66 rpDefineConv(celcius, kelvin, centigrade2kelvin, kelvin2centigrade); 67 68 69 69 double cm_exp = 0; 70 70 double nm_conv = 0; 71 71 double value = 0; 72 72 73 73 int result = 0; 74 74 int showUnits = 0; … … 76 76 const char* nm_conv_str = NULL; 77 77 const char* retStr = NULL; 78 79 makeMetric(meters);80 centimeters = find("cm");81 78 79 rpMakeMetric(meters); 80 centimeters = rpFind("cm"); 81 82 82 if (meters) { 83 printf("meters sign is :%s:\n", getUnitsName(meters));83 printf("meters sign is :%s:\n",rpGetUnitsName(meters)); 84 84 } 85 85 86 86 if (centimeters) { 87 cm_exp = getExponent(centimeters);88 cm_basis = getBasis(centimeters);87 cm_exp = rpGetExponent(centimeters); 88 cm_basis = rpGetBasis(centimeters); 89 89 90 printf("centimeters sign is :%s:\n", getUnits(centimeters));90 printf("centimeters sign is :%s:\n",rpGetUnits(centimeters)); 91 91 printf("cm_exp is :%f:\n",cm_exp); 92 92 93 93 if (cm_basis) { 94 printf("cm_basis sign is :%s:\n", getUnitsName(cm_basis));94 printf("cm_basis sign is :%s:\n",rpGetUnitsName(cm_basis)); 95 95 } 96 96 else { … … 100 100 } 101 101 102 nanometers = find("nm");102 nanometers = rpFind("nm"); 103 103 104 104 if (nanometers) { 105 105 106 nm_conv = convert_obj_double_result(nanometers,meters,1.0e9,&result);106 nm_conv = rpConvert_ObjDbl(nanometers,meters,1.0e9,&result); 107 107 printf("1.0e9 nm = %f m\tresult = %d\n",nm_conv,result); 108 108 109 nm_conv = convert_obj_double(nanometers,meters,1.0e9);109 nm_conv = rpConvert_ObjDbl(nanometers,meters,1.0e9, NULL); 110 110 printf("1.0e9 nm = %f m\n",nm_conv); 111 111 112 112 showUnits = 1; 113 nm_conv_str = convert_obj_str(nanometers,meters,1.588e9,showUnits);113 nm_conv_str = rpConvert_ObjStr(nanometers,meters,1.588e9,showUnits,NULL); 114 114 printf("1.588e9 nm = %s\n",nm_conv_str); 115 115 116 116 showUnits = 0; 117 nm_conv_str = convert_obj_str(nanometers,meters,1.588e9,showUnits);117 nm_conv_str = rpConvert_ObjStr(nanometers,meters,1.588e9,showUnits,NULL); 118 118 printf("1.588e9 nm = %s\n",nm_conv_str); 119 119 } … … 123 123 124 124 if (meters && angstrom && centimeters) { 125 value = convert_obj_double_result(angstrom,meters,1.0,&result);125 value = rpConvert_ObjDbl(angstrom,meters,1.0,&result); 126 126 printf("1 angstrom = %e meters\n",value); 127 127 128 value = convert_obj_double_result(centimeters,angstrom,1e-8,&result);128 value = rpConvert_ObjDbl(centimeters,angstrom,1e-8,&result); 129 129 printf("1.0e-8 centimeter = %f angstroms\n",value); 130 130 } … … 135 135 136 136 if (fahrenheit && celcius) { 137 value = convert_obj_double_result(fahrenheit,celcius,72,&result);137 value = rpConvert_ObjDbl(fahrenheit,celcius,72,&result); 138 138 printf("72 degrees fahrenheit = %f degrees celcius\n",value); 139 140 value = convert_obj_double_result(celcius,fahrenheit,value,&result);139 140 value = rpConvert_ObjDbl(celcius,fahrenheit,value,&result); 141 141 printf("22.222 degrees celcius = %f degrees fahrenheit\n",value); 142 142 } … … 144 144 printf("fahrenheit or celcius is NULL\n"); 145 145 } 146 146 147 147 if (celcius && kelvin) { 148 value = convert_obj_double_result(celcius,kelvin,20,&result);148 value = rpConvert_ObjDbl(celcius,kelvin,20,&result); 149 149 printf("20 degrees celcius = %f kelvin\n",value); 150 150 151 value = convert_obj_double_result(kelvin,celcius,300,&result);151 value = rpConvert_ObjDbl(kelvin,celcius,300,&result); 152 152 printf("300 kelvin = %f degrees celcius\n", value); 153 153 } … … 157 157 158 158 printf("====== adding all preset units ======\n"); 159 add_presets("all");159 rpAddPresets("all"); 160 160 161 161 printf("====== TESTING STATIC CONVERT FXNS ======\n"); 162 162 163 retStr = convert("72F","C",1,&result);163 retStr = rpConvert("72F","C",1,&result); 164 164 printf("72F = %s\tresult = %d\n", retStr,result); 165 165 166 retStr = convert("300K","F",1,&result);166 retStr = rpConvert("300K","F",1,&result); 167 167 printf("300K = %s\tresult = %d\n", retStr,result); 168 168 169 retStr = convert("1eV","J",0,&result);169 retStr = rpConvert("1eV","J",0,&result); 170 170 printf("1eV = %s (no units)\tresult = %d\n", retStr,result); 171 171 172 retStr = convert_str("300K","R",1,&result);172 retStr = rpConvertStr("300K","R",1,&result); 173 173 printf("300K = %s\tresult = %d\n", retStr,result); 174 174 175 retStr = convert_str("5m","ft",1,&result);175 retStr = rpConvertStr("5m","ft",1,&result); 176 176 printf("5m = %s\tresult = %d\n", retStr,result); 177 177 178 value = convert_dbl("5000mV","V",&result);178 value = rpConvertDbl("5000mV","V",&result); 179 179 printf("5V = %f (double value)\n", value); 180 180 181 181 182 182 return 0; 183 183 }
Note: See TracChangeset
for help on using the changeset viewer.