source: trunk/src/cee/RpLibraryCInterface.cc @ 83

Last change on this file since 83 was 83, checked in by dkearney, 17 years ago
  1. More cleaning of RpUnits and RpLibrary? code
  2. added rp_result code to c++/fortran/c code
  3. added rp_children, rp_lib_node[comp,type,id] for fortran code (need to test)
  4. adjusted convert function to recognize statements as follows:

convert("5J","neV")
convert("3.12075e+28neV","J")

  1. made joules a metric unit in RpUnits.cc
  2. tested examples/app-fermi/fortran/fermi.f with new rappture library.

added units conversion.

File size: 4.3 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: C Rappture Library Source
4 *
5 * ======================================================================
6 *  AUTHOR:  Derrick Kearney, Purdue University
7 *  Copyright (c) 2005
8 *  Purdue Research Foundation, West Lafayette, IN
9 * ======================================================================
10 */
11
12#include "RpLibrary.h"
13#include "RpLibraryCInterface.h"
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19    RpLibrary*
20    library (const char* path)
21    {
22        return new RpLibrary(path);
23    }
24
25    void
26    freeLibrary (RpLibrary* lib)
27    {
28        delete lib;
29        lib = NULL;
30    }
31
32    RpLibrary*
33    element (RpLibrary* lib, const char* path)
34    {
35        return lib->element(path);
36    }
37
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)
46    {
47        static std::string retStr = "";
48        RpLibrary* retLib = lib->element(path);
49
50        if (retLib) {
51            retStr = retLib->nodeType();
52        }
53
54        return retStr.c_str();
55    }
56
57    const char*
58    elementAsComp (RpLibrary* lib, const char* path)
59    {
60        static std::string retStr = "";
61        RpLibrary* retLib = lib->element(path);
62
63        if (retLib) {
64            retStr = retLib->nodeComp();
65        }
66
67        return retStr.c_str();
68    }
69
70    const char*
71    elementAsId (RpLibrary* lib, const char* path)
72    {
73        static std::string retStr = "";
74        RpLibrary* retLib = lib->element(path);
75
76        if (retLib) {
77            retStr = retLib->nodeId();
78        }
79
80        return retStr.c_str();
81    }
82
83
84    RpLibrary*
85    children (RpLibrary* lib, const char* path, RpLibrary* childEle   )
86    {
87        return lib->children(path,childEle);
88    }
89
90    RpLibrary*
91    childrenByType( RpLibrary* lib,
92                    const char* path,
93                    RpLibrary* childEle,
94                    const char* type    )
95    {
96        return lib->children(path,childEle,type);
97    }
98
99    RpLibrary*
100    get (RpLibrary* lib, const char* path)
101    {
102        return lib->get(path);
103    }
104
105    const char*
106    getString (RpLibrary* lib, const char* path)
107    {
108        static std::string retStr = "";
109        retStr = lib->getString(path);
110        return retStr.c_str();
111    }
112
113    double
114    getDouble (RpLibrary* lib, const char* path)
115    {
116        return lib->getDouble(path);
117    }
118
119    void
120    put         (RpLibrary* lib,
121                 const char* path,
122                 const char* value,
123                 const char* id,
124                 int append         )
125    {
126        lib->put(path,value,id,append);
127    }
128
129    void
130    putStringId (RpLibrary* lib,
131                 const char* path,
132                 const char* value,
133                 const char* id,
134                 int append          )
135    {
136        lib->put(path,value,id,append);
137    }
138
139    void
140    putString ( RpLibrary* lib,
141                const char* path,
142                const char* value,
143                int append          )
144    {
145        lib->put(path,value,"",append);
146    }
147
148    void
149    putDoubleId (RpLibrary* lib,
150                 const char* path,
151                 double value,
152                 const char* id,
153                 int append         )
154    {
155        lib->put(path,value,id,append);
156    }
157
158    void
159    putDouble   (RpLibrary* lib,
160                 const char* path,
161                 double value,
162                 int append         )
163    {
164        lib->put(path,value,"",append);
165    }
166
167    const char*
168    xml (RpLibrary* lib)
169    {
170        static std::string retStr = "";
171        retStr = lib->xml();
172        return retStr.c_str();
173    }
174
175    const char*
176    nodeComp (RpLibrary* node)
177    {
178        static std::string retStr = "";
179        retStr = node->nodeComp();
180        return retStr.c_str();
181    }
182
183    const char*
184    nodeType (RpLibrary* node)
185    {
186        static std::string retStr = "";
187        retStr = node->nodeType();
188        return retStr.c_str();
189    }
190
191    const char*
192    nodeId (RpLibrary* node)
193    {
194        static std::string retStr = "";
195        retStr = node->nodeId();
196        return retStr.c_str();
197    }
198
199    void
200    result (RpLibrary* lib)
201    {
202        lib->result();
203    }
204
205#ifdef __cplusplus
206}
207#endif
Note: See TracBrowser for help on using the repository browser.