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 | field_hdl->sendAttributToServer(field_hdl->name) ; |
---|
34 | } |
---|
35 | |
---|
36 | void cxios_set_field_standard_name(XFieldPtr field_hdl, const char * standard_name, int standard_name_size) |
---|
37 | { |
---|
38 | std::string standard_name_str; |
---|
39 | if (!cstr2string(standard_name, standard_name_size, standard_name_str)) return; |
---|
40 | |
---|
41 | field_hdl->standard_name.setValue(standard_name_str); |
---|
42 | field_hdl->sendAttributToServer(field_hdl->standard_name) ; |
---|
43 | } |
---|
44 | |
---|
45 | void cxios_set_field_long_name(XFieldPtr field_hdl, const char * long_name, int long_name_size) |
---|
46 | { |
---|
47 | std::string long_name_str; |
---|
48 | if (!cstr2string(long_name, long_name_size, long_name_str)) return; |
---|
49 | |
---|
50 | field_hdl->long_name.setValue(long_name_str); |
---|
51 | field_hdl->sendAttributToServer(field_hdl->long_name) ; |
---|
52 | } |
---|
53 | |
---|
54 | void cxios_set_field_unit(XFieldPtr field_hdl, const char * unit, int unit_size) |
---|
55 | { |
---|
56 | std::string unit_str; |
---|
57 | if (!cstr2string(unit, unit_size, unit_str)) return; |
---|
58 | |
---|
59 | field_hdl->unit.setValue(unit_str); |
---|
60 | field_hdl->sendAttributToServer(field_hdl->unit) ; |
---|
61 | |
---|
62 | } |
---|
63 | |
---|
64 | void cxios_set_field_operation(XFieldPtr field_hdl, const char * operation, int operation_size) |
---|
65 | { |
---|
66 | std::string operation_str; |
---|
67 | if (!cstr2string(operation, operation_size, operation_str)) return; |
---|
68 | |
---|
69 | field_hdl->operation.setValue(operation_str); |
---|
70 | field_hdl->sendAttributToServer(field_hdl->operation) ; |
---|
71 | } |
---|
72 | |
---|
73 | void cxios_set_field_freq_op(XFieldPtr field_hdl, const char * freq_op, int freq_op_size) |
---|
74 | { |
---|
75 | std::string freq_op_str; |
---|
76 | if (!cstr2string(freq_op, freq_op_size, freq_op_str)) return; |
---|
77 | |
---|
78 | field_hdl->freq_op.setValue(freq_op_str); |
---|
79 | field_hdl->sendAttributToServer(field_hdl->freq_op) ; |
---|
80 | } |
---|
81 | |
---|
82 | void cxios_set_field_level(XFieldPtr field_hdl, int level) |
---|
83 | { |
---|
84 | field_hdl->level.setValue(level); |
---|
85 | field_hdl->sendAttributToServer(field_hdl->level) ; |
---|
86 | } |
---|
87 | |
---|
88 | void cxios_set_field_prec(XFieldPtr field_hdl, int prec) |
---|
89 | { |
---|
90 | field_hdl->prec.setValue(prec); |
---|
91 | field_hdl->sendAttributToServer(field_hdl->prec) ; |
---|
92 | } |
---|
93 | |
---|
94 | void cxios_set_field_enabled(XFieldPtr field_hdl, bool enabled) |
---|
95 | { |
---|
96 | field_hdl->enabled.setValue(enabled); |
---|
97 | field_hdl->sendAttributToServer(field_hdl->enabled) ; |
---|
98 | } |
---|
99 | |
---|
100 | void cxios_set_field_domain_ref(XFieldPtr field_hdl, const char * domain_ref, int domain_ref_size) |
---|
101 | { |
---|
102 | std::string domain_ref_str; |
---|
103 | if (!cstr2string(domain_ref, domain_ref_size, domain_ref_str)) return; |
---|
104 | |
---|
105 | field_hdl->domain_ref.setValue(domain_ref_str); |
---|
106 | field_hdl->sendAttributToServer(field_hdl->domain_ref) ; |
---|
107 | } |
---|
108 | |
---|
109 | void cxios_set_field_axis_ref(XFieldPtr field_hdl, const char * axis_ref, int axis_ref_size) |
---|
110 | { |
---|
111 | std::string axis_ref_str; |
---|
112 | if (!cstr2string(axis_ref, axis_ref_size, axis_ref_str)) return; |
---|
113 | |
---|
114 | field_hdl->axis_ref.setValue(axis_ref_str); |
---|
115 | field_hdl->sendAttributToServer(field_hdl->axis_ref) ; |
---|
116 | } |
---|
117 | |
---|
118 | void cxios_set_field_grid_ref(XFieldPtr field_hdl, const char * grid_ref, int grid_ref_size) |
---|
119 | { |
---|
120 | std::string grid_ref_str; |
---|
121 | if (!cstr2string(grid_ref, grid_ref_size, grid_ref_str)) return; |
---|
122 | |
---|
123 | field_hdl->grid_ref.setValue(grid_ref_str); |
---|
124 | field_hdl->sendAttributToServer(field_hdl->grid_ref) ; |
---|
125 | } |
---|
126 | |
---|
127 | void cxios_set_field_field_ref(XFieldPtr field_hdl, const char * field_ref, int field_ref_size) |
---|
128 | { |
---|
129 | std::string field_ref_str; |
---|
130 | if (!cstr2string(field_ref, field_ref_size, field_ref_str)) return; |
---|
131 | |
---|
132 | field_hdl->field_ref.setValue(field_ref_str); |
---|
133 | field_hdl->sendAttributToServer(field_hdl->field_ref) ; |
---|
134 | } |
---|
135 | |
---|
136 | void cxios_set_field_default_value(XFieldPtr field_hdl, double default_value) |
---|
137 | { |
---|
138 | field_hdl->default_value.setValue(default_value); |
---|
139 | field_hdl->sendAttributToServer(field_hdl->default_value) ; |
---|
140 | } |
---|
141 | |
---|
142 | // -------------------- Attributs des groupes de champs --------------------- |
---|
143 | |
---|
144 | void cxios_set_fieldgroup_name(XFieldGroupPtr fieldgroup_hdl, const char * name, int name_size) |
---|
145 | { |
---|
146 | std::string name_str; |
---|
147 | if (!cstr2string(name, name_size, name_str)) return; |
---|
148 | |
---|
149 | fieldgroup_hdl->name.setValue(name_str); |
---|
150 | fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->name); |
---|
151 | } |
---|
152 | |
---|
153 | void cxios_set_fieldgroup_standard_name(XFieldGroupPtr fieldgroup_hdl, const char * standard_name, int standard_name_size) |
---|
154 | { |
---|
155 | std::string standard_name_str; |
---|
156 | if (!cstr2string(standard_name, standard_name_size, standard_name_str)) return; |
---|
157 | |
---|
158 | fieldgroup_hdl->standard_name.setValue(standard_name_str); |
---|
159 | fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->standard_name); |
---|
160 | } |
---|
161 | |
---|
162 | void cxios_set_fieldgroup_long_name(XFieldGroupPtr fieldgroup_hdl, const char * long_name, int long_name_size) |
---|
163 | { |
---|
164 | std::string long_name_str; |
---|
165 | if (!cstr2string(long_name, long_name_size, long_name_str)) return; |
---|
166 | |
---|
167 | fieldgroup_hdl->long_name.setValue(long_name_str); |
---|
168 | fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->long_name); |
---|
169 | } |
---|
170 | |
---|
171 | void cxios_set_fieldgroup_unit(XFieldGroupPtr fieldgroup_hdl, const char * unit, int unit_size) |
---|
172 | { |
---|
173 | std::string unit_str; |
---|
174 | if (!cstr2string(unit, unit_size, unit_str)) return; |
---|
175 | |
---|
176 | fieldgroup_hdl->unit.setValue(unit_str); |
---|
177 | fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->unit); |
---|
178 | } |
---|
179 | |
---|
180 | void cxios_set_fieldgroup_operation(XFieldGroupPtr fieldgroup_hdl, const char * operation, int operation_size) |
---|
181 | { |
---|
182 | std::string operation_str; |
---|
183 | if (!cstr2string(operation, operation_size, operation_str)) return; |
---|
184 | |
---|
185 | fieldgroup_hdl->operation.setValue(operation_str); |
---|
186 | fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->operation); |
---|
187 | } |
---|
188 | |
---|
189 | void cxios_set_fieldgroup_freq_op(XFieldGroupPtr fieldgroup_hdl, const char * freq_op, int freq_op_size) |
---|
190 | { |
---|
191 | std::string freq_op_str; |
---|
192 | if (!cstr2string(freq_op, freq_op_size, freq_op_str)) return; |
---|
193 | |
---|
194 | fieldgroup_hdl->freq_op.setValue(freq_op_str); |
---|
195 | fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->freq_op); |
---|
196 | } |
---|
197 | |
---|
198 | void cxios_set_fieldgroup_level(XFieldGroupPtr fieldgroup_hdl, int level) |
---|
199 | { |
---|
200 | fieldgroup_hdl->level.setValue(level); |
---|
201 | fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->level); |
---|
202 | } |
---|
203 | |
---|
204 | void cxios_set_fieldgroup_prec(XFieldGroupPtr fieldgroup_hdl, int prec) |
---|
205 | { |
---|
206 | fieldgroup_hdl->prec.setValue(prec); |
---|
207 | fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->prec); |
---|
208 | } |
---|
209 | |
---|
210 | void cxios_set_fieldgroup_enabled(XFieldGroupPtr fieldgroup_hdl, bool enabled) |
---|
211 | { |
---|
212 | fieldgroup_hdl->enabled.setValue(enabled); |
---|
213 | fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->enabled); |
---|
214 | } |
---|
215 | |
---|
216 | void cxios_set_fieldgroup_domain_ref(XFieldGroupPtr fieldgroup_hdl, const char * domain_ref, int domain_ref_size) |
---|
217 | { |
---|
218 | std::string domain_ref_str; |
---|
219 | if (!cstr2string(domain_ref, domain_ref_size, domain_ref_str)) return; |
---|
220 | |
---|
221 | fieldgroup_hdl->domain_ref.setValue(domain_ref_str); |
---|
222 | fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->domain_ref); |
---|
223 | } |
---|
224 | |
---|
225 | void cxios_set_fieldgroup_axis_ref(XFieldGroupPtr fieldgroup_hdl, const char * axis_ref, int axis_ref_size) |
---|
226 | { |
---|
227 | std::string axis_ref_str; |
---|
228 | if (!cstr2string(axis_ref, axis_ref_size, axis_ref_str)) return; |
---|
229 | |
---|
230 | fieldgroup_hdl->axis_ref.setValue(axis_ref_str); |
---|
231 | fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->axis_ref); |
---|
232 | } |
---|
233 | |
---|
234 | void cxios_set_fieldgroup_grid_ref(XFieldGroupPtr fieldgroup_hdl, const char * grid_ref, int grid_ref_size) |
---|
235 | { |
---|
236 | std::string grid_ref_str; |
---|
237 | if (!cstr2string(grid_ref, grid_ref_size, grid_ref_str)) return; |
---|
238 | |
---|
239 | fieldgroup_hdl->grid_ref.setValue(grid_ref_str); |
---|
240 | fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->grid_ref); |
---|
241 | } |
---|
242 | |
---|
243 | void cxios_set_fieldgroup_field_ref(XFieldGroupPtr fieldgroup_hdl, const char * field_ref, int field_ref_size) |
---|
244 | { |
---|
245 | std::string field_ref_str; |
---|
246 | if (!cstr2string(field_ref, field_ref_size, field_ref_str)) return; |
---|
247 | |
---|
248 | fieldgroup_hdl->field_ref.setValue(field_ref_str); |
---|
249 | fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->field_ref); |
---|
250 | } |
---|
251 | |
---|
252 | void cxios_set_fieldgroup_default_value(XFieldGroupPtr fieldgroup_hdl, double default_value) |
---|
253 | { |
---|
254 | fieldgroup_hdl->default_value.setValue(default_value); |
---|
255 | fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->default_value); |
---|
256 | } |
---|
257 | |
---|
258 | // ------------------------ Création des handle ----------------------------- |
---|
259 | |
---|
260 | void cxios_field_handle_create (XFieldPtr * _ret, const char * _id, int _id_len) |
---|
261 | { |
---|
262 | std::string id; |
---|
263 | if (!cstr2string(_id, _id_len, id)) return; |
---|
264 | |
---|
265 | *_ret = xmlioserver::CObjectFactory::GetObject<xmlioserver::tree::CField>(id).get(); |
---|
266 | } |
---|
267 | |
---|
268 | void cxios_fieldgroup_handle_create (XFieldGroupPtr * _ret, const char * _id, int _id_len) |
---|
269 | { |
---|
270 | std::string id; |
---|
271 | if (!cstr2string(_id, _id_len, id)) return; |
---|
272 | |
---|
273 | *_ret = xmlioserver::CObjectFactory::GetObject<xmlioserver::tree::CFieldGroup>(id).get(); |
---|
274 | } |
---|
275 | |
---|
276 | |
---|
277 | // -------------------- Vérification des identifiants ----------------------- |
---|
278 | |
---|
279 | void cxios_field_valid_id (bool * _ret, const char * _id, int _id_len) |
---|
280 | { |
---|
281 | std::string id; |
---|
282 | if (!cstr2string(_id, _id_len, id)) return; |
---|
283 | |
---|
284 | *_ret = xmlioserver::CObjectFactory::HasObject<xmlioserver::tree::CField>(id); |
---|
285 | } |
---|
286 | |
---|
287 | void cxios_fieldgroup_valid_id (bool * _ret, const char * _id, int _id_len) |
---|
288 | { |
---|
289 | std::string id; |
---|
290 | if (!cstr2string(_id, _id_len, id)) return; |
---|
291 | |
---|
292 | *_ret = xmlioserver::CObjectFactory::HasObject<xmlioserver::tree::CFieldGroup>(id); |
---|
293 | } |
---|
294 | |
---|
295 | void cxios_field_is_active (XFieldPtr field_hdl, bool* ret) |
---|
296 | { |
---|
297 | *ret = field_hdl->isActive(); |
---|
298 | } |
---|
299 | |
---|
300 | } // extern "C" |
---|