Changeset 125
- Timestamp:
- Nov 4, 2005, 3:19:11 PM (19 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/c-example/plotc.c
r115 r125 106 106 107 107 // free the rappture library 108 rpFreeLibrary( lib);108 rpFreeLibrary(&lib); 109 109 110 110 // exit program -
trunk/examples/c-example/tool.xml
r90 r125 4 4 <title>SIN(x) Graph</title> 5 5 <about>Press Simulate to view results.</about> 6 <command> @tool/plot c@driver</command>6 <command> @tool/plot @driver</command> 7 7 </tool> 8 8 <input> -
trunk/include/cee/RpLibraryCInterface.h
r115 r125 22 22 // 23 23 RpLibrary* rpLibrary (const char* path); 24 void rpFreeLibrary (RpLibrary* lib);24 void rpFreeLibrary (RpLibrary** lib); 25 25 26 26 // RpLibrary member functions … … 53 53 */ 54 54 55 RpLibrary*rpGet (RpLibrary* lib, const char* path);55 const char* rpGet (RpLibrary* lib, const char* path); 56 56 const char* rpGetString (RpLibrary* lib, const char* path); 57 57 double rpGetDouble (RpLibrary* lib, const char* path); -
trunk/include/core/RpLibrary.h
r115 r125 34 34 // users member fxns 35 35 36 RpLibrary* element (std::string path = "" , std::string as = "object");36 RpLibrary* element (std::string path = ""); 37 37 38 38 // should return RpObject& but for simplicity right now it doesnt 39 39 // RpObject will either be an Array, RpString, RpNumber ... 40 40 41 RpLibrary* children (std::string path = "",41 RpLibrary* children ( std::string path = "", 42 42 RpLibrary* rpChildNode = NULL, 43 43 std::string type = "", 44 44 int* childCount = NULL ); 45 45 46 RpLibrary* get (std::string path = "");47 std::string getString ( std::string path = "");48 double getDouble ( std::string path = "");46 std::string get ( std::string path = ""); 47 std::string getString ( std::string path = ""); 48 double getDouble ( std::string path = ""); 49 49 50 50 RpLibrary& put ( std::string path, … … 67 67 68 68 void result(); 69 const char* nodeTypeC();70 const char* nodeIdC();71 const char* nodeCompC();72 69 73 70 // no arg constructor … … 139 136 140 137 // copy constructor 141 // for some reason making this a const gives me problems when calling xml() 138 // for some reason making this a const gives me problems 139 // when calling xml() 142 140 // need help looking into this 143 141 // RpLibrary ( const RpLibrary& other ) … … 199 197 }// end copy constructor 200 198 201 // for some reason making this a const gives me problems when calling xml() 199 // copy assignment operator 200 // for some reason making this a const gives me problems 201 // when calling xml() 202 202 // need help looking into this 203 203 // RpLibrary& operator= (const RpLibrary& other) { … … 224 224 225 225 // Loads the XML from other 226 // the length cannot be 0 because xml() should not be returning227 // empty strings226 // the length cannot be 0 because xml() 227 // should not be returning empty strings 228 228 buffer = other.xml(); 229 229 buffLen = buffer.length(); -
trunk/include/fortran/RpLibraryFInterface.h
r119 r125 53 53 54 54 void rp_lib_get ( int* handle, 55 char* path, 56 char* retText, 57 int path_len, 58 int retText_len ); 59 60 void rp_lib_get_str ( int* handle, 55 61 char* path, 56 62 char* retText, -
trunk/include/fortran/RpLibraryFStubs.h
r119 r125 64 64 int retText_len ); 65 65 66 void rp_lib_get_str_ ( int* handle, 67 char* path, 68 char* retText, 69 int path_len, 70 int retText_len ); 71 66 72 double rp_lib_get_double_ ( int* handle, 67 73 char* path, … … 173 179 int retText_len ); 174 180 181 void rp_lib_get_str__ ( int* handle, 182 char* path, 183 char* retText, 184 int path_len, 185 int retText_len ); 186 175 187 double rp_lib_get_double__ (int* handle, 176 188 char* path, … … 283 295 int retText_len ); 284 296 297 void RP_LIB_GET_STR ( int* handle, 298 char* path, 299 char* retText, 300 int path_len, 301 int retText_len ); 302 285 303 double RP_LIB_GET_DOUBLE ( int* handle, 286 304 char* path, -
trunk/src/Makefile
r122 r125 292 292 $(OCT) $(OCTAVE_SRC)/rpXml.cc $(OCTAVE_COMP_ARGS) 293 293 294 294 docs: 295 if test ! -d docs; then \ 296 mkdir docs; \ 297 fi 298 if test ! -d docs/doxygen; then \ 299 mkdir docs/doxygen; \ 300 fi 301 doxygen 295 302 296 303 #### CLEAN UP ############################################################ -
trunk/src/cee/RpLibraryCInterface.cc
r115 r125 26 26 27 27 void 28 rpFreeLibrary (RpLibrary* lib) 29 { 30 delete lib; 31 lib = NULL; 28 rpFreeLibrary (RpLibrary** lib) 29 { 30 if (lib && (*lib)) { 31 delete (*lib); 32 (*lib) = NULL; 33 } 32 34 } 33 35 … … 99 101 } 100 102 101 RpLibrary*103 const char* 102 104 rpGet (RpLibrary* lib, const char* path) 103 105 { 104 return lib->get(path); 106 static std::string retStr = ""; 107 retStr = lib->getString(path); 108 return retStr.c_str(); 105 109 } 106 110 … … 202 206 rpResult (RpLibrary* lib) 203 207 { 208 // signal the processing is complete 204 209 lib->result(); 205 210 } -
trunk/src/core/RpLibrary.cc
r121 r125 448 448 449 449 RpLibrary* 450 RpLibrary::element (std::string path , std::string as)450 RpLibrary::element (std::string path) 451 451 { 452 452 RpLibrary* retLib; … … 566 566 } 567 567 568 569 568 /**********************************************************************/ 570 569 // METHOD: get() 571 /// Return the RpLibraryobject held at location 'path'572 /** 573 */ 574 575 RpLibrary* 570 /// Return the string value of the object held at location 'path' 571 /** 572 */ 573 574 std::string 576 575 RpLibrary::get (std::string path) 577 576 { 578 RpLibrary* retVal;579 580 scew_element* retNode = _find(path,0);581 582 if (retNode == NULL) {583 // need to raise error584 return NULL;585 }586 587 retVal = new RpLibrary(retNode);588 589 //who delete's this memory?590 return retVal;591 }592 593 /**********************************************************************/594 // METHOD: getString()595 /// Return the string value of the object held at location 'path'596 /**597 */598 599 std::string600 RpLibrary::getString (std::string path)601 {602 // std::string retVal;603 604 /*605 if (path.empty()) {606 return "";607 }608 */609 610 577 scew_element* retNode = _find(path,0); 611 578 … … 615 582 } 616 583 617 // retVal = std::string(scew_element_contents(retNode)); 618 // return retVal; 584 return std::string(scew_element_contents(retNode)); 585 } 586 587 /**********************************************************************/ 588 // METHOD: getString() 589 /// Return the string value of the object held at location 'path' 590 /** 591 */ 592 593 std::string 594 RpLibrary::getString (std::string path) 595 { 596 scew_element* retNode = _find(path,0); 597 598 if (retNode == NULL) { 599 // need to raise error 600 return ""; 601 } 619 602 620 603 return std::string(scew_element_contents(retNode)); -
trunk/src/fortran/RpLibraryFInterface.cc
r122 r125 462 462 463 463 if (lib) { 464 xmlText = lib->get(inPath); 465 if (!xmlText.empty()) { 466 fortranify(xmlText.c_str(),retText,retText_len); 467 } 468 469 } 470 } 471 } 472 473 /**********************************************************************/ 474 // FUNCTION: rp_lib_get_str() 475 /// Get data located at 'path' and return it as a string value. 476 /** 477 */ 478 void rp_lib_get_str( int* handle, /* integer handle of library */ 479 char* path, /* null terminated path */ 480 char* retText, /* return text buffer for fortran*/ 481 int path_len, 482 int retText_len /* length of return text buffer */ 483 ) 484 { 485 std::string xmlText = ""; 486 487 RpLibrary* lib = NULL; 488 489 std::string inPath = ""; 490 491 inPath = null_terminate_str(path,path_len); 492 493 if ((handle) && (*handle != 0)) { 494 lib = getObject_Lib(*handle); 495 496 if (lib) { 464 497 xmlText = lib->getString(inPath); 465 498 if (!xmlText.empty()) { … … 470 503 } 471 504 } 505 472 506 473 507 /**********************************************************************/ -
trunk/src/fortran/RpLibraryFStubs.c
r119 r125 238 238 } 239 239 240 void 241 rp_lib_get_str_ ( int* handle, 242 char* path, 243 char* retText, 244 int path_len, 245 int retText_len ) { 246 247 return rp_lib_get_str(handle,path,retText,path_len,retText_len); 248 } 249 250 void 251 rp_lib_get_str__ ( int* handle, 252 char* path, 253 char* retText, 254 int path_len, 255 int retText_len ) { 256 257 return rp_lib_get_str(handle,path,retText,path_len,retText_len); 258 } 259 260 void 261 RP_LIB_GET_STR ( int* handle, 262 char* path, 263 char* retText, 264 int path_len, 265 int retText_len ) { 266 267 return rp_lib_get_str(handle,path,retText,path_len,retText_len); 268 } 269 240 270 double 241 271 rp_lib_get_double_ ( int* handle, -
trunk/src/matlab/rpGet.cc
r115 r125 3 3 * INTERFACE: Matlab Rappture Library Source 4 4 * 5 * nodeHandle= rpGet(libHandle,path)5 * retStr = rpGet(libHandle,path) 6 6 * 7 7 * ====================================================================== … … 19 19 int nrhs, const mxArray *prhs[]) 20 20 { 21 int libIndex = 0;21 int libIndex = 0; 22 22 int retLibIndex = 0; 23 RpLibrary* lib = NULL;24 RpLibrary* retLib= NULL;25 c har* path= NULL;23 RpLibrary* lib = NULL; 24 char* path = NULL; 25 const char* retString = NULL; 26 26 27 27 /* Check for proper number of arguments. */ … … 39 39 40 40 if (lib) { 41 retLib = rpGet(lib,path); 42 retLibIndex = storeObject_Lib(retLib); 41 retString = rpGet(lib,path); 43 42 } 44 43 } 45 44 46 /* Set double scalar node handleto MATLAB mexFunction output*/47 plhs[0] = mxCreate DoubleScalar(retLibIndex);45 /* Set C-style string output_buf to MATLAB mexFunction output*/ 46 plhs[0] = mxCreateString(retString); 48 47 49 48 return; -
trunk/src/octave/rpGet.cc
r122 r125 62 62 63 63 if (lib) { 64 retStr = lib->get String(path);64 retStr = lib->get(path); 65 65 err = 0; 66 66 } -
trunk/test/src/RpLibraryF_test.f
r115 r125 32 32 END SUBROUTINE test_element 33 33 34 SUBROUTINE test_get(lib,path) 35 integer lib 36 character*100 path, retText 37 38 print *,"TESTING GET : path = ",path 39 40 call rp_lib_get(lib, path, retText) 41 42 print *,"retText = ",retText 43 END SUBROUTINE test_get 44 34 45 SUBROUTINE test_get_str(lib,path) 35 46 integer lib 36 47 character*100 path, retText 37 48 38 print *,"TESTING GET : path = ",path49 print *,"TESTING GET STRING: path = ",path 39 50 40 call rp_lib_get (lib, path, retText)51 call rp_lib_get_str(lib, path, retText) 41 52 42 53 print *,"retText = ",retText … … 46 57 integer lib 47 58 double precision rslt, rp_lib_get_double 48 character*100 path , retText59 character*100 path 49 60 50 print *,"TESTING GET : path = ",path61 print *,"TESTING GET DOUBLE: path = ",path 51 62 52 63 rslt = rp_lib_get_double(lib, path) … … 58 69 IMPLICIT NONE 59 70 60 integer rp_lib, rp_units_convert_dbl, rp_units_add_presets 61 integer rp_lib_element_obj 71 integer rp_lib 62 72 63 integer driver, ok 64 double precision T, Ef, kT, Emin, Emax, dE, f, E 65 CHARACTER*100 inFile, strVal, path 66 character*40 xy 73 integer driver 74 CHARACTER*100 inFile, path 67 75 68 76 call getarg(1,inFile) … … 70 78 ! print *,"dict key = ",driver 71 79 72 ok = rp_units_add_presets("all")73 74 80 ! TESTING ELEMENT 75 !call test_element(driver, "input.number(min)")76 81 path = "input.number(min)" 77 82 call test_element(driver, path) 78 !call rp_lib_get(driver, path, strVal) 79 !print *,"strVal = ",strVal 83 84 ! TESTING GET 85 path = "input.number(min).current" 86 call test_get(driver, path) 80 87 81 88 ! TESTING GET STRING -
trunk/test/src/RpLibrary_test.cc
r115 r125 16 16 int test_element (RpLibrary* lib, std::string path ); 17 17 int test_get (RpLibrary* lib, std::string path ); 18 int test_getString (RpLibrary* lib, std::string path ); 19 int test_getDouble (RpLibrary* lib, std::string path ); 18 20 19 21 int test_element (RpLibrary* lib, std::string path ) … … 32 34 std::cout << "searchEle id = :" << searchEle->nodeId() << ":" << std::endl; 33 35 std::cout << "searchEle type = :" << searchEle->nodeType() << ":" << std::endl; 36 retVal = 0; 37 } 38 39 return retVal; 40 } 41 42 int test_get (RpLibrary* lib, std::string path ) 43 { 44 int retVal = 1; 45 std::string searchVal = lib->get(path); 46 47 std::cout << "TESTING GET : path = " << path << std::endl; 48 49 if (searchVal.empty()) { 50 std::cout << "searchVal is EMPTY STRING" << std::endl; 51 retVal = 1; 52 } 53 else { 54 std::cout << "searchVal = :" << searchVal << ":" << std::endl; 34 55 retVal = 0; 35 56 } … … 135 156 RpLibrary lib2; 136 157 137 if (argc < 3)158 if (argc < 2) 138 159 { 139 printf("usage: RpLibrary_test infile.xml outfile.xml\n");160 printf("usage: RpLibrary_test infile.xml\n"); 140 161 return EXIT_FAILURE; 141 162 } … … 152 173 test_getString(lib, "output.curve.about.label"); 153 174 175 lib->put("input.number(test_one).default", "3000"); 176 test_get(lib, "input.number(test_one).default"); 154 177 lib->put("input.number(test).default", "1000"); 155 178 test_getString(lib, "input.number(test).default");
Note: See TracChangeset
for help on using the changeset viewer.