source: XIOS/trunk/src/fortran/icfield.cpp @ 310

Last change on this file since 310 was 310, checked in by ymipsl, 12 years ago

Add xios_field_is_active functionnality

YM

File size: 10.5 KB
RevLine 
[274]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
16extern "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   
[286]27   void cxios_set_field_name(XFieldPtr field_hdl, const char * name, int name_size)
[274]28   {
29      std::string name_str; 
30      if (!cstr2string(name, name_size, name_str)) return;
31
32      field_hdl->name.setValue(name_str);
[300]33      field_hdl->sendAttributToServer(field_hdl->name) ; 
[274]34   }
35   
[286]36   void cxios_set_field_standard_name(XFieldPtr field_hdl, const char * standard_name, int standard_name_size)
[274]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);
[300]42      field_hdl->sendAttributToServer(field_hdl->standard_name) ; 
[274]43   }
44   
[286]45   void cxios_set_field_long_name(XFieldPtr field_hdl, const char * long_name, int long_name_size)
[274]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);
[300]51      field_hdl->sendAttributToServer(field_hdl->long_name) ;
[274]52   }
53   
[286]54   void cxios_set_field_unit(XFieldPtr field_hdl, const char * unit, int unit_size)
[274]55   {
56      std::string unit_str; 
57      if (!cstr2string(unit, unit_size, unit_str)) return;
58
59      field_hdl->unit.setValue(unit_str);
[300]60      field_hdl->sendAttributToServer(field_hdl->unit) ;
61
[274]62   }
63   
[286]64   void cxios_set_field_operation(XFieldPtr field_hdl, const char * operation, int operation_size) 
[274]65   {
66      std::string operation_str; 
67      if (!cstr2string(operation, operation_size, operation_str)) return;
68
69      field_hdl->operation.setValue(operation_str);
[300]70      field_hdl->sendAttributToServer(field_hdl->operation) ;
[274]71   }
72   
[286]73   void cxios_set_field_freq_op(XFieldPtr field_hdl, const char * freq_op, int freq_op_size)
[274]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);
[300]79      field_hdl->sendAttributToServer(field_hdl->freq_op) ;
[274]80   }
81   
[286]82   void cxios_set_field_level(XFieldPtr field_hdl, int level)
[274]83   {
84      field_hdl->level.setValue(level);
[300]85      field_hdl->sendAttributToServer(field_hdl->level) ;
[274]86   }
87   
[286]88   void cxios_set_field_prec(XFieldPtr field_hdl, int prec)
[274]89   {
90      field_hdl->prec.setValue(prec);
[300]91      field_hdl->sendAttributToServer(field_hdl->prec) ;
[274]92   }
93   
[286]94   void cxios_set_field_enabled(XFieldPtr field_hdl, bool enabled)
[274]95   {
96      field_hdl->enabled.setValue(enabled);
[300]97      field_hdl->sendAttributToServer(field_hdl->enabled) ;
[274]98   }
99   
[286]100   void cxios_set_field_domain_ref(XFieldPtr field_hdl,  const char * domain_ref, int domain_ref_size)
[274]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);
[300]106      field_hdl->sendAttributToServer(field_hdl->domain_ref) ;
[274]107   }
108   
[286]109   void cxios_set_field_axis_ref(XFieldPtr field_hdl,  const char * axis_ref,  int axis_ref_size)
[274]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);
[300]115      field_hdl->sendAttributToServer(field_hdl->axis_ref) ;
[274]116   }
117   
[286]118   void cxios_set_field_grid_ref(XFieldPtr field_hdl,  const char * grid_ref, int grid_ref_size)
[274]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);
[300]124      field_hdl->sendAttributToServer(field_hdl->grid_ref) ;
[274]125   }
126   
[286]127   void cxios_set_field_field_ref(XFieldPtr field_hdl,  const char * field_ref,  int field_ref_size)
[274]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);
[300]133      field_hdl->sendAttributToServer(field_hdl->field_ref) ;
[274]134   }
135   
[286]136   void cxios_set_field_default_value(XFieldPtr field_hdl, double default_value)
[274]137   {
138      field_hdl->default_value.setValue(default_value);
[300]139      field_hdl->sendAttributToServer(field_hdl->default_value) ;
[274]140   } 
141   
142   // -------------------- Attributs des groupes de champs ---------------------
143 
[286]144   void cxios_set_fieldgroup_name(XFieldGroupPtr fieldgroup_hdl, const char * name, int name_size)
[274]145   {
146      std::string name_str; 
147      if (!cstr2string(name, name_size, name_str)) return;
148
149      fieldgroup_hdl->name.setValue(name_str);
[300]150      fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->name);
[274]151   }
152   
[286]153   void cxios_set_fieldgroup_standard_name(XFieldGroupPtr fieldgroup_hdl, const char * standard_name, int standard_name_size)
[274]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);
[300]159      fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->standard_name);
[274]160   }
161   
[286]162   void cxios_set_fieldgroup_long_name(XFieldGroupPtr fieldgroup_hdl, const char * long_name, int long_name_size)
[274]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);
[300]168      fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->long_name);
[274]169   }
170   
[286]171   void cxios_set_fieldgroup_unit(XFieldGroupPtr fieldgroup_hdl, const char * unit, int unit_size)
[274]172   {
173      std::string unit_str; 
174      if (!cstr2string(unit, unit_size, unit_str)) return;
175
176      fieldgroup_hdl->unit.setValue(unit_str);
[300]177      fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->unit);
[274]178   }
179   
[286]180   void cxios_set_fieldgroup_operation(XFieldGroupPtr fieldgroup_hdl, const char * operation, int operation_size) 
[274]181   {
182      std::string operation_str; 
183      if (!cstr2string(operation, operation_size, operation_str)) return;
184
185      fieldgroup_hdl->operation.setValue(operation_str);
[300]186      fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->operation);
[274]187   }
188   
[286]189   void cxios_set_fieldgroup_freq_op(XFieldGroupPtr fieldgroup_hdl, const char * freq_op, int freq_op_size)
[274]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);
[300]195      fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->freq_op);
[274]196   }
197   
[286]198   void cxios_set_fieldgroup_level(XFieldGroupPtr fieldgroup_hdl, int level)
[274]199   {
200      fieldgroup_hdl->level.setValue(level);
[300]201      fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->level);
[274]202   }
203   
[286]204   void cxios_set_fieldgroup_prec(XFieldGroupPtr fieldgroup_hdl, int prec)
[274]205   {
206      fieldgroup_hdl->prec.setValue(prec);
[300]207      fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->prec);
[274]208   }
209   
[286]210   void cxios_set_fieldgroup_enabled(XFieldGroupPtr fieldgroup_hdl, bool enabled)
[274]211   {
212      fieldgroup_hdl->enabled.setValue(enabled);
[300]213      fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->enabled);
[274]214   }
215   
[286]216   void cxios_set_fieldgroup_domain_ref(XFieldGroupPtr fieldgroup_hdl,  const char * domain_ref, int domain_ref_size)
[274]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);
[300]222      fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->domain_ref);
[274]223   }
224   
[286]225   void cxios_set_fieldgroup_axis_ref(XFieldGroupPtr fieldgroup_hdl,  const char * axis_ref,  int axis_ref_size)
[274]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);
[300]231      fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->axis_ref);
[274]232   }
233   
[286]234   void cxios_set_fieldgroup_grid_ref(XFieldGroupPtr fieldgroup_hdl,  const char * grid_ref, int grid_ref_size)
[274]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);
[300]240      fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->grid_ref);
[274]241   }
242   
[286]243   void cxios_set_fieldgroup_field_ref(XFieldGroupPtr fieldgroup_hdl,  const char * field_ref,  int field_ref_size)
[274]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);
[300]249      fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->field_ref);
[274]250   }
251   
[286]252   void cxios_set_fieldgroup_default_value(XFieldGroupPtr fieldgroup_hdl, double default_value)
[274]253   {
254      fieldgroup_hdl->default_value.setValue(default_value);
[300]255      fieldgroup_hdl->sendAttributToServer(fieldgroup_hdl->default_value);
[274]256   } 
257   
258   // ------------------------ Création des handle -----------------------------
259   
[286]260   void cxios_field_handle_create (XFieldPtr * _ret, const char * _id, int _id_len)
[274]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   
[286]268   void cxios_fieldgroup_handle_create (XFieldGroupPtr * _ret, const char * _id, int _id_len)
[274]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   }
[280]275
276
277   // -------------------- Vérification des identifiants -----------------------
278
[286]279   void cxios_field_valid_id (bool * _ret, const char * _id, int _id_len)
[280]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
[286]287   void cxios_fieldgroup_valid_id (bool * _ret, const char * _id, int _id_len)
[280]288   {
289      std::string id;
290      if (!cstr2string(_id, _id_len, id)) return;
291
292      *_ret = xmlioserver::CObjectFactory::HasObject<xmlioserver::tree::CFieldGroup>(id);
293   }
[274]294   
[310]295   void cxios_field_is_active (XFieldPtr field_hdl, bool* ret)
296   {
297      *ret = field_hdl->isActive();
298   }
299   
[274]300} // extern "C"
Note: See TracBrowser for help on using the repository browser.