1 | /* |
---|
2 | * ---------------------------------------------------------------------- |
---|
3 | * INTERFACE: Fortran Rappture Library Source |
---|
4 | * |
---|
5 | * ====================================================================== |
---|
6 | * AUTHOR: Derrick Kearney, Purdue University |
---|
7 | * Copyright (c) 2004-2007 Purdue Research Foundation |
---|
8 | * |
---|
9 | * See the file "license.terms" for information on usage and |
---|
10 | * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
11 | * ====================================================================== |
---|
12 | */ |
---|
13 | |
---|
14 | #include "RpLibraryFInterface.h" |
---|
15 | #include "RpBindingsDict.h" |
---|
16 | #include "RpLibraryFStubs.c" |
---|
17 | #include "RpDXWriter.h" |
---|
18 | |
---|
19 | /**********************************************************************/ |
---|
20 | // FUNCTION: rp_lib(const char* filePath, int filePath_len) |
---|
21 | /// Open the file at 'filePath' and return Rappture Library Object. |
---|
22 | /** |
---|
23 | */ |
---|
24 | |
---|
25 | int rp_lib(const char* filePath, int filePath_len) { |
---|
26 | |
---|
27 | RpLibrary* lib = NULL; |
---|
28 | int handle = -1; |
---|
29 | std::string inFilePath = ""; |
---|
30 | |
---|
31 | inFilePath = null_terminate_str(filePath, filePath_len); |
---|
32 | |
---|
33 | // create a RapptureIO object and store in dictionary |
---|
34 | lib = new RpLibrary(inFilePath); |
---|
35 | |
---|
36 | if (lib) { |
---|
37 | handle = storeObject_Void((void*)lib); |
---|
38 | } |
---|
39 | |
---|
40 | return handle; |
---|
41 | } |
---|
42 | |
---|
43 | /**********************************************************************/ |
---|
44 | // FUNCTION: rp_lib_element_obj() |
---|
45 | /// Return the node located at 'path'. |
---|
46 | /** |
---|
47 | */ |
---|
48 | int rp_lib_element_obj(int* handle, /* integer handle of library */ |
---|
49 | char* path, /* null terminated path */ |
---|
50 | int path_len |
---|
51 | ) |
---|
52 | { |
---|
53 | int newObjHandle = -1; |
---|
54 | |
---|
55 | std::string inPath = ""; |
---|
56 | |
---|
57 | RpLibrary* lib = NULL; |
---|
58 | RpLibrary* retObj = NULL; |
---|
59 | |
---|
60 | inPath = null_terminate_str(path,path_len); |
---|
61 | |
---|
62 | if ((handle) && (*handle != 0)) { |
---|
63 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
64 | if (lib) { |
---|
65 | retObj = lib->element(inPath); |
---|
66 | |
---|
67 | if (retObj) { |
---|
68 | newObjHandle = storeObject_Void((void*)retObj); |
---|
69 | } |
---|
70 | } |
---|
71 | } |
---|
72 | |
---|
73 | return newObjHandle; |
---|
74 | } |
---|
75 | |
---|
76 | /**********************************************************************/ |
---|
77 | // FUNCTION: rp_lib_element_comp() |
---|
78 | /// Return the component name of the node located at 'path'. |
---|
79 | /** |
---|
80 | */ |
---|
81 | void rp_lib_element_comp( int* handle, /* integer handle of library */ |
---|
82 | char* path, /* null terminated path */ |
---|
83 | char* retText, /* return buffer for fortran*/ |
---|
84 | int path_len, |
---|
85 | int retText_len /* length of return text buffer */ |
---|
86 | ) |
---|
87 | { |
---|
88 | std::string inPath = ""; |
---|
89 | RpLibrary* lib = NULL; |
---|
90 | std::string retStr = ""; |
---|
91 | |
---|
92 | inPath = null_terminate_str(path,path_len); |
---|
93 | |
---|
94 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
95 | |
---|
96 | if (lib) { |
---|
97 | retStr = lib->element(inPath)->nodeComp(); |
---|
98 | if (!retStr.empty()) { |
---|
99 | fortranify(retStr.c_str(),retText,retText_len); |
---|
100 | } |
---|
101 | } |
---|
102 | |
---|
103 | } |
---|
104 | |
---|
105 | /**********************************************************************/ |
---|
106 | // FUNCTION: rp_lib_element_id() |
---|
107 | /// Return the 'id' of node located at 'path'. |
---|
108 | /** |
---|
109 | */ |
---|
110 | void rp_lib_element_id( int* handle, /* integer handle of library */ |
---|
111 | char* path, /* path of element within xml */ |
---|
112 | char* retText, /* return buffer for fortran */ |
---|
113 | int path_len, |
---|
114 | int retText_len /* length of return text buffer */ |
---|
115 | ) |
---|
116 | { |
---|
117 | std::string inPath = ""; |
---|
118 | RpLibrary* lib = NULL; |
---|
119 | std::string retStr = ""; |
---|
120 | |
---|
121 | inPath = null_terminate_str(path,path_len); |
---|
122 | |
---|
123 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
124 | |
---|
125 | if (lib) { |
---|
126 | retStr = lib->element(inPath)->nodeId(); |
---|
127 | if (!retStr.empty()) { |
---|
128 | fortranify(retStr.c_str(),retText,retText_len); |
---|
129 | } |
---|
130 | } |
---|
131 | } |
---|
132 | |
---|
133 | /**********************************************************************/ |
---|
134 | // FUNCTION: rp_lib_element_type() |
---|
135 | /// Return the type of the node located at 'path'. |
---|
136 | /** |
---|
137 | */ |
---|
138 | void rp_lib_element_type( int* handle, /* integer handle of library */ |
---|
139 | char* path, /* search path inside xml */ |
---|
140 | char* retText, /* return buffer for fortran*/ |
---|
141 | int path_len, |
---|
142 | int retText_len /* length of return text buffer */ |
---|
143 | ) |
---|
144 | { |
---|
145 | std::string inPath = ""; |
---|
146 | RpLibrary* lib = NULL; |
---|
147 | std::string retStr = ""; |
---|
148 | |
---|
149 | inPath = null_terminate_str(path,path_len); |
---|
150 | |
---|
151 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
152 | |
---|
153 | if (lib) { |
---|
154 | retStr = lib->element(inPath)->nodeType(); |
---|
155 | fortranify(retStr.c_str(),retText,retText_len); |
---|
156 | } |
---|
157 | } |
---|
158 | |
---|
159 | /**********************************************************************/ |
---|
160 | // FUNCTION: rp_lib_children(const char* filePath, int filePath_len) |
---|
161 | /// Retrieve the next child of 'path' from the Rappture Library Object. |
---|
162 | /** |
---|
163 | */ |
---|
164 | int rp_lib_children ( int* handle, /* integer handle of library */ |
---|
165 | char* path, /* search path of the xml */ |
---|
166 | int* childHandle, /*integer hanlde of last returned child*/ |
---|
167 | int path_len /* length of the search path buffer */ |
---|
168 | ) { |
---|
169 | |
---|
170 | std::string inPath = ""; |
---|
171 | RpLibrary* lib = NULL; |
---|
172 | RpLibrary* childNode = NULL; |
---|
173 | int newObjHandle = -1; |
---|
174 | |
---|
175 | inPath = null_terminate_str(path,path_len); |
---|
176 | |
---|
177 | if (handle && (*handle >= 0) ) { |
---|
178 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
179 | if (lib) { |
---|
180 | |
---|
181 | if (*childHandle > 0) { |
---|
182 | // check to see if there were any previously returned children |
---|
183 | childNode = (RpLibrary*) getObject_Void(*childHandle); |
---|
184 | } |
---|
185 | |
---|
186 | // call the children base method |
---|
187 | childNode = lib->children(inPath,childNode); |
---|
188 | |
---|
189 | // store the childNode in the dictionary. |
---|
190 | // |
---|
191 | // because the base method is using static memory to get store the |
---|
192 | // children we should be able to check and see if the childHandle |
---|
193 | // was valid. |
---|
194 | // if so, then we can just return the childHandle back to the user |
---|
195 | // if not, store the object in the dictionary and return the new |
---|
196 | // handle. |
---|
197 | |
---|
198 | if (childNode) { |
---|
199 | if (*childHandle < 1) { |
---|
200 | newObjHandle = storeObject_Void((void*)childNode); |
---|
201 | } |
---|
202 | else { |
---|
203 | newObjHandle = storeObject_Void((void*)childNode,*childHandle); |
---|
204 | } |
---|
205 | } |
---|
206 | } |
---|
207 | } |
---|
208 | |
---|
209 | return newObjHandle; |
---|
210 | |
---|
211 | } |
---|
212 | |
---|
213 | /**********************************************************************/ |
---|
214 | // FUNCTION: rp_lib_get() |
---|
215 | /// Get data located at 'path' and return it as a string value. |
---|
216 | /** |
---|
217 | */ |
---|
218 | void |
---|
219 | rp_lib_get( |
---|
220 | int* handle, /* integer handle of library */ |
---|
221 | char* path, /* null terminated path */ |
---|
222 | char* retText, /* return text buffer for fortran*/ |
---|
223 | |
---|
224 | int retText_len) /* length of return text buffer */ |
---|
225 | { |
---|
226 | std::string xmlText = ""; |
---|
227 | |
---|
228 | RpLibrary* lib = NULL; |
---|
229 | |
---|
230 | std::string inPath = ""; |
---|
231 | |
---|
232 | inPath = null_terminate_str(path,path_len); |
---|
233 | |
---|
234 | if ((handle) && (*handle != 0)) { |
---|
235 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
236 | |
---|
237 | if (lib) { |
---|
238 | xmlText = lib->get(inPath); |
---|
239 | if (!xmlText.empty()) { |
---|
240 | fortranify(xmlText.c_str(),retText,retText_len); |
---|
241 | } |
---|
242 | |
---|
243 | } |
---|
244 | } |
---|
245 | } |
---|
246 | |
---|
247 | /**********************************************************************/ |
---|
248 | // FUNCTION: rp_lib_get_str() |
---|
249 | /// Get data located at 'path' and return it as a string value. |
---|
250 | /** |
---|
251 | */ |
---|
252 | void |
---|
253 | rp_lib_get_str( |
---|
254 | int* handle, /* integer handle of library */ |
---|
255 | char* path, /* null terminated path */ |
---|
256 | char* retText, /* return text buffer for fortran*/ |
---|
257 | int path_len, |
---|
258 | int retText_len) /* length of return text buffer */ |
---|
259 | { |
---|
260 | std::string xmlText = ""; |
---|
261 | |
---|
262 | RpLibrary* lib = NULL; |
---|
263 | |
---|
264 | std::string inPath = ""; |
---|
265 | |
---|
266 | inPath = null_terminate_str(path,path_len); |
---|
267 | |
---|
268 | if ((handle) && (*handle != 0)) { |
---|
269 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
270 | |
---|
271 | if (lib) { |
---|
272 | xmlText = lib->getString(inPath); |
---|
273 | if (!xmlText.empty()) { |
---|
274 | fortranify(xmlText.c_str(),retText,retText_len); |
---|
275 | } |
---|
276 | |
---|
277 | } |
---|
278 | } |
---|
279 | } |
---|
280 | |
---|
281 | |
---|
282 | /**********************************************************************/ |
---|
283 | // FUNCTION: rp_lib_get_double() |
---|
284 | /// Get data located at 'path' and return it as a double precision value. |
---|
285 | /** |
---|
286 | */ |
---|
287 | double |
---|
288 | rp_lib_get_double( |
---|
289 | int* handle, /* integer handle of library */ |
---|
290 | char* path, /* null terminated path */ |
---|
291 | int path_len) |
---|
292 | { |
---|
293 | double retVal = 0.0; |
---|
294 | |
---|
295 | RpLibrary* lib = NULL; |
---|
296 | |
---|
297 | std::string inPath = ""; |
---|
298 | |
---|
299 | inPath = null_terminate_str(path,path_len); |
---|
300 | |
---|
301 | if ((handle) && (*handle != 0)) { |
---|
302 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
303 | |
---|
304 | if (lib) { |
---|
305 | retVal = lib->getDouble(inPath); |
---|
306 | } |
---|
307 | } |
---|
308 | |
---|
309 | return retVal; |
---|
310 | } |
---|
311 | |
---|
312 | |
---|
313 | /**********************************************************************/ |
---|
314 | // FUNCTION: rp_lib_get_integer() |
---|
315 | /// Get data located at 'path' and return it as an integer value. |
---|
316 | /** |
---|
317 | */ |
---|
318 | int rp_lib_get_integer( int* handle, /* integer handle of library */ |
---|
319 | char* path, /* null terminated path */ |
---|
320 | int path_len |
---|
321 | ) |
---|
322 | { |
---|
323 | int retVal = 0; |
---|
324 | |
---|
325 | RpLibrary* lib = NULL; |
---|
326 | |
---|
327 | std::string inPath = ""; |
---|
328 | |
---|
329 | inPath = null_terminate_str(path,path_len); |
---|
330 | |
---|
331 | if ((handle) && (*handle != 0)) { |
---|
332 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
333 | |
---|
334 | if (lib) { |
---|
335 | retVal = lib->getInt(inPath); |
---|
336 | } |
---|
337 | } |
---|
338 | |
---|
339 | return retVal; |
---|
340 | } |
---|
341 | |
---|
342 | |
---|
343 | /**********************************************************************/ |
---|
344 | // FUNCTION: rp_lib_get_boolean() |
---|
345 | /// Get data located at 'path' and return it as an integer value. |
---|
346 | /** |
---|
347 | */ |
---|
348 | int rp_lib_get_boolean( int* handle, /* integer handle of library */ |
---|
349 | char* path, /* null terminated path */ |
---|
350 | int path_len |
---|
351 | ) |
---|
352 | { |
---|
353 | bool value = false; |
---|
354 | int retVal = 0; |
---|
355 | |
---|
356 | RpLibrary* lib = NULL; |
---|
357 | |
---|
358 | std::string inPath = ""; |
---|
359 | |
---|
360 | inPath = null_terminate_str(path,path_len); |
---|
361 | |
---|
362 | if ((handle) && (*handle != 0)) { |
---|
363 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
364 | |
---|
365 | if (lib) { |
---|
366 | value = lib->getBool(inPath); |
---|
367 | if (value == true) { |
---|
368 | retVal = 1; |
---|
369 | } |
---|
370 | else { |
---|
371 | retVal = 0; |
---|
372 | } |
---|
373 | } |
---|
374 | } |
---|
375 | |
---|
376 | return retVal; |
---|
377 | } |
---|
378 | |
---|
379 | |
---|
380 | /**********************************************************************/ |
---|
381 | // FUNCTION: rp_lib_get_file() |
---|
382 | /// Get data located at 'path' and write it to the file 'fileName'. |
---|
383 | /** |
---|
384 | * Returns if any bytes were written to the file |
---|
385 | */ |
---|
386 | int rp_lib_get_file ( int* handle, /* integer handle of library */ |
---|
387 | char* path, /* null terminated path */ |
---|
388 | char* fileName, /* name of file to write data to */ |
---|
389 | int path_len, /* length of the path variable */ |
---|
390 | int fileName_len /* length of the fileName variable */ |
---|
391 | ) |
---|
392 | { |
---|
393 | size_t nbytes = 0; |
---|
394 | |
---|
395 | RpLibrary* lib = NULL; |
---|
396 | |
---|
397 | std::string inPath = ""; |
---|
398 | std::string filePath = ""; |
---|
399 | |
---|
400 | inPath = null_terminate_str(path,path_len); |
---|
401 | filePath = null_terminate_str(fileName,fileName_len); |
---|
402 | |
---|
403 | if ((handle) && (*handle != 0)) { |
---|
404 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
405 | |
---|
406 | if (lib) { |
---|
407 | nbytes = lib->getFile(inPath, filePath); |
---|
408 | } |
---|
409 | } |
---|
410 | |
---|
411 | return nbytes; |
---|
412 | } |
---|
413 | |
---|
414 | |
---|
415 | |
---|
416 | /**********************************************************************/ |
---|
417 | // FUNCTION: rp_lib_put_str() |
---|
418 | /// Put string into Rappture Library Object at location 'path'. |
---|
419 | /** |
---|
420 | */ |
---|
421 | void rp_lib_put_str( int* handle, |
---|
422 | char* path, |
---|
423 | char* value, |
---|
424 | int* append, |
---|
425 | int path_len, |
---|
426 | int value_len |
---|
427 | ) |
---|
428 | { |
---|
429 | std::string inPath = ""; |
---|
430 | std::string inValue = ""; |
---|
431 | RpLibrary* lib = NULL; |
---|
432 | |
---|
433 | inPath = null_terminate_str(path,path_len); |
---|
434 | inValue = null_terminate_str(value,value_len); |
---|
435 | |
---|
436 | if ((handle) && (*handle != 0)) { |
---|
437 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
438 | |
---|
439 | if (lib) { |
---|
440 | lib->put(inPath,inValue,"",*append); |
---|
441 | } |
---|
442 | } |
---|
443 | |
---|
444 | return; |
---|
445 | |
---|
446 | } |
---|
447 | |
---|
448 | |
---|
449 | /**********************************************************************/ |
---|
450 | // FUNCTION: rp_lib_put_id_str() |
---|
451 | /// Put string into Rappture Library Object at location 'path' with id = 'id' |
---|
452 | /** |
---|
453 | */ |
---|
454 | void rp_lib_put_id_str ( int* handle, |
---|
455 | char* path, |
---|
456 | char* value, |
---|
457 | char* id, |
---|
458 | int* append, |
---|
459 | int path_len, |
---|
460 | int value_len, |
---|
461 | int id_len |
---|
462 | ) |
---|
463 | { |
---|
464 | RpLibrary* lib = NULL; |
---|
465 | |
---|
466 | std::string inPath = ""; |
---|
467 | std::string inValue = ""; |
---|
468 | std::string inId = ""; |
---|
469 | |
---|
470 | inPath = null_terminate_str(path,path_len); |
---|
471 | inValue = null_terminate_str(value,value_len); |
---|
472 | inId = null_terminate_str(id,id_len); |
---|
473 | |
---|
474 | if ((handle) && (*handle != 0)) { |
---|
475 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
476 | |
---|
477 | if (lib) { |
---|
478 | lib->put(inPath,inValue,inId,*append); |
---|
479 | } |
---|
480 | } |
---|
481 | |
---|
482 | } |
---|
483 | |
---|
484 | |
---|
485 | /**********************************************************************/ |
---|
486 | // FUNCTION: rp_lib_put_data() |
---|
487 | /// Put string into Rappture Library Object at location 'path'. |
---|
488 | /** |
---|
489 | */ |
---|
490 | void |
---|
491 | rp_lib_put_data( |
---|
492 | int* handle, |
---|
493 | char* path, |
---|
494 | char* bytes, |
---|
495 | int* nbytes, |
---|
496 | int* append, |
---|
497 | int path_len, |
---|
498 | int bytes_len) |
---|
499 | { |
---|
500 | std::string inPath = ""; |
---|
501 | RpLibrary* lib = NULL; |
---|
502 | int bufferSize = 0; |
---|
503 | |
---|
504 | inPath = null_terminate_str(path,path_len); |
---|
505 | |
---|
506 | if (*nbytes < bytes_len) { |
---|
507 | bufferSize = *nbytes; |
---|
508 | } |
---|
509 | else { |
---|
510 | bufferSize = bytes_len; |
---|
511 | } |
---|
512 | |
---|
513 | if ((handle) && (*handle != 0)) { |
---|
514 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
515 | |
---|
516 | if (lib) { |
---|
517 | lib->putData(inPath,bytes,bufferSize,*append); |
---|
518 | } |
---|
519 | } |
---|
520 | |
---|
521 | return; |
---|
522 | |
---|
523 | } |
---|
524 | |
---|
525 | |
---|
526 | /**********************************************************************/ |
---|
527 | // FUNCTION: rp_lib_put_file() |
---|
528 | /// Put string into Rappture Library Object at location 'path'. |
---|
529 | /** |
---|
530 | */ |
---|
531 | void |
---|
532 | rp_lib_put_file( |
---|
533 | int* handle, |
---|
534 | char* path, |
---|
535 | char* fileName, |
---|
536 | int* compress, |
---|
537 | int* append, |
---|
538 | int path_len, |
---|
539 | int fileName_len) |
---|
540 | { |
---|
541 | std::string inPath = ""; |
---|
542 | std::string inFileName = ""; |
---|
543 | RpLibrary* lib = NULL; |
---|
544 | |
---|
545 | inPath = null_terminate_str(path,path_len); |
---|
546 | inFileName = null_terminate_str(fileName,fileName_len); |
---|
547 | |
---|
548 | if ((handle) && (*handle != 0)) { |
---|
549 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
550 | |
---|
551 | if (lib) { |
---|
552 | lib->putFile(inPath,inFileName,*compress,*append); |
---|
553 | } |
---|
554 | } |
---|
555 | |
---|
556 | return; |
---|
557 | |
---|
558 | } |
---|
559 | |
---|
560 | |
---|
561 | void |
---|
562 | rp_lib_put_obj( |
---|
563 | int* handle, |
---|
564 | char* path, |
---|
565 | int* valHandle, |
---|
566 | int* append, |
---|
567 | int path_len) |
---|
568 | { |
---|
569 | std::string inPath = ""; |
---|
570 | RpLibrary* lib = NULL; |
---|
571 | // Rp_Obj does not currently exist |
---|
572 | Rappture::DXWriter* obj = NULL; |
---|
573 | char* objStr = NULL; |
---|
574 | |
---|
575 | |
---|
576 | inPath = null_terminate_str(path,path_len); |
---|
577 | |
---|
578 | if ((handle) && (*handle != 0)) { |
---|
579 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
580 | if (!lib) { |
---|
581 | // return error, lib was not found |
---|
582 | } |
---|
583 | |
---|
584 | obj = (Rappture::DXWriter*) getObject_Void(*valHandle); |
---|
585 | if (!obj) { |
---|
586 | // return error, obj was not found |
---|
587 | } |
---|
588 | |
---|
589 | // textsize function does not currently exist |
---|
590 | objStr = (char*) malloc(obj->size()*sizeof(char)); |
---|
591 | obj->write(objStr); |
---|
592 | lib->put(inPath,objStr,"",*append); |
---|
593 | free(objStr); |
---|
594 | } |
---|
595 | } |
---|
596 | |
---|
597 | /**********************************************************************/ |
---|
598 | // FUNCTION: rp_lib_write_xml() |
---|
599 | /// Write the xml text into a file. |
---|
600 | /** |
---|
601 | * \sa {rp_result} |
---|
602 | */ |
---|
603 | int rp_lib_write_xml(int* handle, char* outFile, int outFile_len) |
---|
604 | { |
---|
605 | int retVal = -1; |
---|
606 | RpLibrary* lib = NULL; |
---|
607 | std::string inOutFile = ""; |
---|
608 | std::string xmlText = ""; |
---|
609 | std::fstream file; |
---|
610 | |
---|
611 | inOutFile = null_terminate_str(outFile, outFile_len); |
---|
612 | |
---|
613 | if (!inOutFile.empty() ) { |
---|
614 | file.open(inOutFile.c_str(),std::ios::out); |
---|
615 | } |
---|
616 | |
---|
617 | if ( file.is_open() ) { |
---|
618 | if ((handle) && (*handle != 0)) { |
---|
619 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
620 | |
---|
621 | if (lib) { |
---|
622 | xmlText = lib->xml(); |
---|
623 | if (!xmlText.empty()) { |
---|
624 | file << xmlText; |
---|
625 | retVal = 0; |
---|
626 | } |
---|
627 | } |
---|
628 | } |
---|
629 | |
---|
630 | file.close(); |
---|
631 | } |
---|
632 | |
---|
633 | return retVal; |
---|
634 | } |
---|
635 | |
---|
636 | /**********************************************************************/ |
---|
637 | // FUNCTION: rp_lib_xml() |
---|
638 | /// Return this node's xml text |
---|
639 | /** |
---|
640 | */ |
---|
641 | void rp_lib_xml(int* handle, char* retText, int retText_len) |
---|
642 | { |
---|
643 | std::string xmlText = ""; |
---|
644 | |
---|
645 | RpLibrary* lib = NULL; |
---|
646 | |
---|
647 | if ((handle) && (*handle != 0)) { |
---|
648 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
649 | |
---|
650 | if (lib) { |
---|
651 | xmlText = lib->xml(); |
---|
652 | if (!xmlText.empty()) { |
---|
653 | fortranify(xmlText.c_str(), retText, retText_len); |
---|
654 | } |
---|
655 | } |
---|
656 | } |
---|
657 | } |
---|
658 | |
---|
659 | /**********************************************************************/ |
---|
660 | // FUNCTION: rp_lib_node_comp() |
---|
661 | /// Return this node's component name |
---|
662 | /** |
---|
663 | */ |
---|
664 | void rp_lib_node_comp ( int* handle, char* retText, int retText_len ) { |
---|
665 | |
---|
666 | std::string retStr = ""; |
---|
667 | RpLibrary* node = NULL; |
---|
668 | |
---|
669 | if ((handle) && (*handle != 0)) { |
---|
670 | node = (RpLibrary*) getObject_Void(*handle); |
---|
671 | |
---|
672 | if (node) { |
---|
673 | retStr = node->nodeComp(); |
---|
674 | if (!retStr.empty()) { |
---|
675 | fortranify(retStr.c_str(), retText, retText_len); |
---|
676 | } |
---|
677 | } |
---|
678 | } |
---|
679 | } |
---|
680 | |
---|
681 | /**********************************************************************/ |
---|
682 | // FUNCTION: rp_lib_node_type() |
---|
683 | /// Return this node's type |
---|
684 | /** |
---|
685 | */ |
---|
686 | void rp_lib_node_type ( int* handle, char* retText, int retText_len ) { |
---|
687 | |
---|
688 | std::string retStr = ""; |
---|
689 | RpLibrary* node = NULL; |
---|
690 | |
---|
691 | if ((handle) && (*handle != 0)) { |
---|
692 | node = (RpLibrary*) getObject_Void(*handle); |
---|
693 | |
---|
694 | if (node) { |
---|
695 | retStr = node->nodeType(); |
---|
696 | if (!retStr.empty()) { |
---|
697 | fortranify(retStr.c_str(), retText, retText_len); |
---|
698 | } |
---|
699 | } |
---|
700 | } |
---|
701 | } |
---|
702 | |
---|
703 | /**********************************************************************/ |
---|
704 | // FUNCTION: rp_lib_node_id() |
---|
705 | /// Return this node's id. |
---|
706 | /** |
---|
707 | */ |
---|
708 | void rp_lib_node_id ( int* handle, char* retText, int retText_len ) { |
---|
709 | |
---|
710 | std::string retStr = ""; |
---|
711 | RpLibrary* node = NULL; |
---|
712 | |
---|
713 | if ((handle) && (*handle != 0)) { |
---|
714 | node = (RpLibrary*) getObject_Void(*handle); |
---|
715 | |
---|
716 | if (node) { |
---|
717 | retStr = node->nodeId(); |
---|
718 | if (!retStr.empty()) { |
---|
719 | fortranify(retStr.c_str(), retText, retText_len); |
---|
720 | } |
---|
721 | } |
---|
722 | } |
---|
723 | } |
---|
724 | |
---|
725 | /**********************************************************************/ |
---|
726 | // FUNCTION: rp_result() |
---|
727 | /// Write xml text to a run.xml file and signal the program has completed |
---|
728 | /** |
---|
729 | */ |
---|
730 | void rp_result(int* handle) { |
---|
731 | RpLibrary* lib = NULL; |
---|
732 | |
---|
733 | if (handle && *handle != 0) { |
---|
734 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
735 | if (lib) { |
---|
736 | lib->put("tool.version.rappture.language", "fortran"); |
---|
737 | lib->result(); |
---|
738 | } |
---|
739 | } |
---|
740 | |
---|
741 | // do no delete this, still working on testing this |
---|
742 | cleanLibDict(); |
---|
743 | } |
---|
744 | |
---|