1 | /* ************************************************************************** * |
---|
2 | * Copyright © IPSL/LSCE, XMLIOServer, Avril 2010 - Octobre 2011 * |
---|
3 | * ************************************************************************** */ |
---|
4 | |
---|
5 | #include <boost/multi_array.hpp> |
---|
6 | #include <boost/shared_ptr.hpp> |
---|
7 | |
---|
8 | #include "xmlioserver.hpp" |
---|
9 | |
---|
10 | #include "attribute_template_impl.hpp" |
---|
11 | #include "object_template_impl.hpp" |
---|
12 | #include "group_template_impl.hpp" |
---|
13 | |
---|
14 | #include "icutil.hpp" |
---|
15 | |
---|
16 | extern "C" |
---|
17 | { |
---|
18 | // /////////////////////////////// Définitions ////////////////////////////// // |
---|
19 | |
---|
20 | // ----------------------- Redéfinition de types ---------------------------- |
---|
21 | |
---|
22 | typedef xmlioserver::tree::CField * XFieldPtr; |
---|
23 | typedef xmlioserver::tree::CFieldGroup * XFieldGroupPtr; |
---|
24 | |
---|
25 | // ------------------------- Attributs des champs --------------------------- |
---|
26 | |
---|
27 | void cxios_set_field_name(XFieldPtr field_hdl, const char * name, int name_size) |
---|
28 | { |
---|
29 | std::string name_str; |
---|
30 | if (!cstr2string(name, name_size, name_str)) return; |
---|
31 | |
---|
32 | field_hdl->name.setValue(name_str); |
---|
33 | } |
---|
34 | |
---|
35 | void cxios_set_field_standard_name(XFieldPtr field_hdl, const char * standard_name, int standard_name_size) |
---|
36 | { |
---|
37 | std::string standard_name_str; |
---|
38 | if (!cstr2string(standard_name, standard_name_size, standard_name_str)) return; |
---|
39 | |
---|
40 | field_hdl->standard_name.setValue(standard_name_str); |
---|
41 | } |
---|
42 | |
---|
43 | void cxios_set_field_long_name(XFieldPtr field_hdl, const char * long_name, int long_name_size) |
---|
44 | { |
---|
45 | std::string long_name_str; |
---|
46 | if (!cstr2string(long_name, long_name_size, long_name_str)) return; |
---|
47 | |
---|
48 | field_hdl->long_name.setValue(long_name_str); |
---|
49 | } |
---|
50 | |
---|
51 | void cxios_set_field_unit(XFieldPtr field_hdl, const char * unit, int unit_size) |
---|
52 | { |
---|
53 | std::string unit_str; |
---|
54 | if (!cstr2string(unit, unit_size, unit_str)) return; |
---|
55 | |
---|
56 | field_hdl->unit.setValue(unit_str); |
---|
57 | } |
---|
58 | |
---|
59 | void cxios_set_field_operation(XFieldPtr field_hdl, const char * operation, int operation_size) |
---|
60 | { |
---|
61 | std::string operation_str; |
---|
62 | if (!cstr2string(operation, operation_size, operation_str)) return; |
---|
63 | |
---|
64 | field_hdl->operation.setValue(operation_str); |
---|
65 | } |
---|
66 | |
---|
67 | void cxios_set_field_freq_op(XFieldPtr field_hdl, const char * freq_op, int freq_op_size) |
---|
68 | { |
---|
69 | std::string freq_op_str; |
---|
70 | if (!cstr2string(freq_op, freq_op_size, freq_op_str)) return; |
---|
71 | |
---|
72 | field_hdl->freq_op.setValue(freq_op_str); |
---|
73 | } |
---|
74 | |
---|
75 | void cxios_set_field_level(XFieldPtr field_hdl, int level) |
---|
76 | { |
---|
77 | field_hdl->level.setValue(level); |
---|
78 | } |
---|
79 | |
---|
80 | void cxios_set_field_prec(XFieldPtr field_hdl, int prec) |
---|
81 | { |
---|
82 | field_hdl->prec.setValue(prec); |
---|
83 | } |
---|
84 | |
---|
85 | void cxios_set_field_enabled(XFieldPtr field_hdl, bool enabled) |
---|
86 | { |
---|
87 | field_hdl->enabled.setValue(enabled); |
---|
88 | } |
---|
89 | |
---|
90 | void cxios_set_field_domain_ref(XFieldPtr field_hdl, const char * domain_ref, int domain_ref_size) |
---|
91 | { |
---|
92 | std::string domain_ref_str; |
---|
93 | if (!cstr2string(domain_ref, domain_ref_size, domain_ref_str)) return; |
---|
94 | |
---|
95 | field_hdl->domain_ref.setValue(domain_ref_str); |
---|
96 | } |
---|
97 | |
---|
98 | void cxios_set_field_axis_ref(XFieldPtr field_hdl, const char * axis_ref, int axis_ref_size) |
---|
99 | { |
---|
100 | std::string axis_ref_str; |
---|
101 | if (!cstr2string(axis_ref, axis_ref_size, axis_ref_str)) return; |
---|
102 | |
---|
103 | field_hdl->axis_ref.setValue(axis_ref_str); |
---|
104 | } |
---|
105 | |
---|
106 | void cxios_set_field_grid_ref(XFieldPtr field_hdl, const char * grid_ref, int grid_ref_size) |
---|
107 | { |
---|
108 | std::string grid_ref_str; |
---|
109 | if (!cstr2string(grid_ref, grid_ref_size, grid_ref_str)) return; |
---|
110 | |
---|
111 | field_hdl->grid_ref.setValue(grid_ref_str); |
---|
112 | } |
---|
113 | |
---|
114 | void cxios_set_field_field_ref(XFieldPtr field_hdl, const char * field_ref, int field_ref_size) |
---|
115 | { |
---|
116 | std::string field_ref_str; |
---|
117 | if (!cstr2string(field_ref, field_ref_size, field_ref_str)) return; |
---|
118 | |
---|
119 | field_hdl->field_ref.setValue(field_ref_str); |
---|
120 | } |
---|
121 | |
---|
122 | void cxios_set_field_default_value(XFieldPtr field_hdl, double default_value) |
---|
123 | { |
---|
124 | field_hdl->default_value.setValue(default_value); |
---|
125 | } |
---|
126 | |
---|
127 | // -------------------- Attributs des groupes de champs --------------------- |
---|
128 | |
---|
129 | void cxios_set_fieldgroup_name(XFieldGroupPtr fieldgroup_hdl, const char * name, int name_size) |
---|
130 | { |
---|
131 | std::string name_str; |
---|
132 | if (!cstr2string(name, name_size, name_str)) return; |
---|
133 | |
---|
134 | fieldgroup_hdl->name.setValue(name_str); |
---|
135 | } |
---|
136 | |
---|
137 | void cxios_set_fieldgroup_standard_name(XFieldGroupPtr fieldgroup_hdl, const char * standard_name, int standard_name_size) |
---|
138 | { |
---|
139 | std::string standard_name_str; |
---|
140 | if (!cstr2string(standard_name, standard_name_size, standard_name_str)) return; |
---|
141 | |
---|
142 | fieldgroup_hdl->standard_name.setValue(standard_name_str); |
---|
143 | } |
---|
144 | |
---|
145 | void cxios_set_fieldgroup_long_name(XFieldGroupPtr fieldgroup_hdl, const char * long_name, int long_name_size) |
---|
146 | { |
---|
147 | std::string long_name_str; |
---|
148 | if (!cstr2string(long_name, long_name_size, long_name_str)) return; |
---|
149 | |
---|
150 | fieldgroup_hdl->long_name.setValue(long_name_str); |
---|
151 | } |
---|
152 | |
---|
153 | void cxios_set_fieldgroup_unit(XFieldGroupPtr fieldgroup_hdl, const char * unit, int unit_size) |
---|
154 | { |
---|
155 | std::string unit_str; |
---|
156 | if (!cstr2string(unit, unit_size, unit_str)) return; |
---|
157 | |
---|
158 | fieldgroup_hdl->unit.setValue(unit_str); |
---|
159 | } |
---|
160 | |
---|
161 | void cxios_set_fieldgroup_operation(XFieldGroupPtr fieldgroup_hdl, const char * operation, int operation_size) |
---|
162 | { |
---|
163 | std::string operation_str; |
---|
164 | if (!cstr2string(operation, operation_size, operation_str)) return; |
---|
165 | |
---|
166 | fieldgroup_hdl->operation.setValue(operation_str); |
---|
167 | } |
---|
168 | |
---|
169 | void cxios_set_fieldgroup_freq_op(XFieldGroupPtr fieldgroup_hdl, const char * freq_op, int freq_op_size) |
---|
170 | { |
---|
171 | std::string freq_op_str; |
---|
172 | if (!cstr2string(freq_op, freq_op_size, freq_op_str)) return; |
---|
173 | |
---|
174 | fieldgroup_hdl->freq_op.setValue(freq_op_str); |
---|
175 | } |
---|
176 | |
---|
177 | void cxios_set_fieldgroup_level(XFieldGroupPtr fieldgroup_hdl, int level) |
---|
178 | { |
---|
179 | fieldgroup_hdl->level.setValue(level); |
---|
180 | } |
---|
181 | |
---|
182 | void cxios_set_fieldgroup_prec(XFieldGroupPtr fieldgroup_hdl, int prec) |
---|
183 | { |
---|
184 | fieldgroup_hdl->prec.setValue(prec); |
---|
185 | } |
---|
186 | |
---|
187 | void cxios_set_fieldgroup_enabled(XFieldGroupPtr fieldgroup_hdl, bool enabled) |
---|
188 | { |
---|
189 | fieldgroup_hdl->enabled.setValue(enabled); |
---|
190 | } |
---|
191 | |
---|
192 | void cxios_set_fieldgroup_domain_ref(XFieldGroupPtr fieldgroup_hdl, const char * domain_ref, int domain_ref_size) |
---|
193 | { |
---|
194 | std::string domain_ref_str; |
---|
195 | if (!cstr2string(domain_ref, domain_ref_size, domain_ref_str)) return; |
---|
196 | |
---|
197 | fieldgroup_hdl->domain_ref.setValue(domain_ref_str); |
---|
198 | } |
---|
199 | |
---|
200 | void cxios_set_fieldgroup_axis_ref(XFieldGroupPtr fieldgroup_hdl, const char * axis_ref, int axis_ref_size) |
---|
201 | { |
---|
202 | std::string axis_ref_str; |
---|
203 | if (!cstr2string(axis_ref, axis_ref_size, axis_ref_str)) return; |
---|
204 | |
---|
205 | fieldgroup_hdl->axis_ref.setValue(axis_ref_str); |
---|
206 | } |
---|
207 | |
---|
208 | void cxios_set_fieldgroup_grid_ref(XFieldGroupPtr fieldgroup_hdl, const char * grid_ref, int grid_ref_size) |
---|
209 | { |
---|
210 | std::string grid_ref_str; |
---|
211 | if (!cstr2string(grid_ref, grid_ref_size, grid_ref_str)) return; |
---|
212 | |
---|
213 | fieldgroup_hdl->grid_ref.setValue(grid_ref_str); |
---|
214 | } |
---|
215 | |
---|
216 | void cxios_set_fieldgroup_field_ref(XFieldGroupPtr fieldgroup_hdl, const char * field_ref, int field_ref_size) |
---|
217 | { |
---|
218 | std::string field_ref_str; |
---|
219 | if (!cstr2string(field_ref, field_ref_size, field_ref_str)) return; |
---|
220 | |
---|
221 | fieldgroup_hdl->field_ref.setValue(field_ref_str); |
---|
222 | } |
---|
223 | |
---|
224 | void cxios_set_fieldgroup_default_value(XFieldGroupPtr fieldgroup_hdl, double default_value) |
---|
225 | { |
---|
226 | fieldgroup_hdl->default_value.setValue(default_value); |
---|
227 | } |
---|
228 | |
---|
229 | // ------------------------ Création des handle ----------------------------- |
---|
230 | |
---|
231 | void cxios_field_handle_create (XFieldPtr * _ret, const char * _id, int _id_len) |
---|
232 | { |
---|
233 | std::string id; |
---|
234 | if (!cstr2string(_id, _id_len, id)) return; |
---|
235 | |
---|
236 | *_ret = xmlioserver::CObjectFactory::GetObject<xmlioserver::tree::CField>(id).get(); |
---|
237 | } |
---|
238 | |
---|
239 | void cxios_fieldgroup_handle_create (XFieldGroupPtr * _ret, const char * _id, int _id_len) |
---|
240 | { |
---|
241 | std::string id; |
---|
242 | if (!cstr2string(_id, _id_len, id)) return; |
---|
243 | |
---|
244 | *_ret = xmlioserver::CObjectFactory::GetObject<xmlioserver::tree::CFieldGroup>(id).get(); |
---|
245 | } |
---|
246 | |
---|
247 | |
---|
248 | // -------------------- Vérification des identifiants ----------------------- |
---|
249 | |
---|
250 | void cxios_field_valid_id (bool * _ret, const char * _id, int _id_len) |
---|
251 | { |
---|
252 | std::string id; |
---|
253 | if (!cstr2string(_id, _id_len, id)) return; |
---|
254 | |
---|
255 | *_ret = xmlioserver::CObjectFactory::HasObject<xmlioserver::tree::CField>(id); |
---|
256 | } |
---|
257 | |
---|
258 | void cxios_fieldgroup_valid_id (bool * _ret, const char * _id, int _id_len) |
---|
259 | { |
---|
260 | std::string id; |
---|
261 | if (!cstr2string(_id, _id_len, id)) return; |
---|
262 | |
---|
263 | *_ret = xmlioserver::CObjectFactory::HasObject<xmlioserver::tree::CFieldGroup>(id); |
---|
264 | } |
---|
265 | |
---|
266 | } // extern "C" |
---|