[270] | 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 xios_set_field_name(XFieldPtr field_hdl, const char * name, int name_size) |
---|
| 28 | { |
---|
| 29 | std::string name_str; |
---|
[271] | 30 | if (!cstr2string(name, name_size, name_str)) return; |
---|
| 31 | |
---|
| 32 | field_hdl->name.setValue(name_str); |
---|
[270] | 33 | } |
---|
| 34 | |
---|
| 35 | void xios_set_field_standard_name(XFieldPtr field_hdl, const char * standard_name, int standard_name_size) |
---|
| 36 | { |
---|
| 37 | std::string standard_name_str; |
---|
[271] | 38 | if (!cstr2string(standard_name, standard_name_size, standard_name_str)) return; |
---|
| 39 | |
---|
| 40 | field_hdl->standard_name.setValue(standard_name_str); |
---|
[270] | 41 | } |
---|
| 42 | |
---|
| 43 | void xios_set_field_long_name(XFieldPtr field_hdl, const char * long_name, int long_name_size) |
---|
| 44 | { |
---|
| 45 | std::string long_name_str; |
---|
[271] | 46 | if (!cstr2string(long_name, long_name_size, long_name_str)) return; |
---|
| 47 | |
---|
| 48 | field_hdl->long_name.setValue(long_name_str); |
---|
[270] | 49 | } |
---|
| 50 | |
---|
| 51 | void xios_set_field_unit(XFieldPtr field_hdl, const char * unit, int unit_size) |
---|
| 52 | { |
---|
| 53 | std::string unit_str; |
---|
[271] | 54 | if (!cstr2string(unit, unit_size, unit_str)) return; |
---|
| 55 | |
---|
| 56 | field_hdl->unit.setValue(unit_str); |
---|
[270] | 57 | } |
---|
| 58 | |
---|
| 59 | void xios_set_field_operation(XFieldPtr field_hdl, const char * operation, int operation_size) |
---|
| 60 | { |
---|
| 61 | std::string operation_str; |
---|
[271] | 62 | if (!cstr2string(operation, operation_size, operation_str)) return; |
---|
| 63 | |
---|
| 64 | field_hdl->operation.setValue(operation_str); |
---|
[270] | 65 | } |
---|
| 66 | |
---|
| 67 | void xios_set_field_freq_op(XFieldPtr field_hdl, const char * freq_op, int freq_op_size) |
---|
| 68 | { |
---|
| 69 | std::string freq_op_str; |
---|
[271] | 70 | if (!cstr2string(freq_op, freq_op_size, freq_op_str)) return; |
---|
| 71 | |
---|
| 72 | field_hdl->freq_op.setValue(freq_op_str); |
---|
[270] | 73 | } |
---|
| 74 | |
---|
| 75 | void xios_set_field_level(XFieldPtr field_hdl, int level) |
---|
| 76 | { |
---|
[271] | 77 | field_hdl->level.setValue(level); |
---|
[270] | 78 | } |
---|
| 79 | |
---|
| 80 | void xios_set_field_prec(XFieldPtr field_hdl, int prec) |
---|
| 81 | { |
---|
[271] | 82 | field_hdl->prec.setValue(prec); |
---|
[270] | 83 | } |
---|
| 84 | |
---|
| 85 | void xios_set_field_enabled(XFieldPtr field_hdl, bool enabled) |
---|
| 86 | { |
---|
[271] | 87 | field_hdl->enabled.setValue(enabled); |
---|
[270] | 88 | } |
---|
| 89 | |
---|
| 90 | void xios_set_field_domain_ref(XFieldPtr field_hdl, const char * domain_ref, int domain_ref_size) |
---|
| 91 | { |
---|
| 92 | std::string domain_ref_str; |
---|
[271] | 93 | if (!cstr2string(domain_ref, domain_ref_size, domain_ref_str)) return; |
---|
| 94 | |
---|
| 95 | field_hdl->domain_ref.setValue(domain_ref_str); |
---|
[270] | 96 | } |
---|
| 97 | |
---|
| 98 | void xios_set_field_axis_ref(XFieldPtr field_hdl, const char * axis_ref, int axis_ref_size) |
---|
| 99 | { |
---|
| 100 | std::string axis_ref_str; |
---|
[271] | 101 | if (!cstr2string(axis_ref, axis_ref_size, axis_ref_str)) return; |
---|
| 102 | |
---|
| 103 | field_hdl->axis_ref.setValue(axis_ref_str); |
---|
[270] | 104 | } |
---|
| 105 | |
---|
| 106 | void xios_set_field_grid_ref(XFieldPtr field_hdl, const char * grid_ref, int grid_ref_size) |
---|
| 107 | { |
---|
| 108 | std::string grid_ref_str; |
---|
[271] | 109 | if (!cstr2string(grid_ref, grid_ref_size, grid_ref_str)) return; |
---|
| 110 | |
---|
| 111 | field_hdl->grid_ref.setValue(grid_ref_str); |
---|
[270] | 112 | } |
---|
| 113 | |
---|
| 114 | void xios_set_field_field_ref(XFieldPtr field_hdl, const char * field_ref, int field_ref_size) |
---|
| 115 | { |
---|
| 116 | std::string field_ref_str; |
---|
[271] | 117 | if (!cstr2string(field_ref, field_ref_size, field_ref_str)) return; |
---|
| 118 | |
---|
| 119 | field_hdl->field_ref.setValue(field_ref_str); |
---|
[270] | 120 | } |
---|
| 121 | |
---|
| 122 | void xios_set_field_default_value(XFieldPtr field_hdl, double default_value) |
---|
| 123 | { |
---|
[271] | 124 | field_hdl->default_value.setValue(default_value); |
---|
[270] | 125 | } |
---|
| 126 | |
---|
| 127 | // -------------------- Attributs des groupes de champs --------------------- |
---|
| 128 | |
---|
| 129 | void xios_set_fieldgroup_name(XFieldGroupPtr fieldgroup_hdl, const char * name, int name_size) |
---|
| 130 | { |
---|
| 131 | std::string name_str; |
---|
[271] | 132 | if (!cstr2string(name, name_size, name_str)) return; |
---|
| 133 | |
---|
| 134 | fieldgroup_hdl->name.setValue(name_str); |
---|
[270] | 135 | } |
---|
| 136 | |
---|
| 137 | void xios_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; |
---|
[271] | 141 | |
---|
| 142 | fieldgroup_hdl->standard_name.setValue(standard_name_str); |
---|
[270] | 143 | } |
---|
| 144 | |
---|
| 145 | void xios_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; |
---|
[271] | 149 | |
---|
| 150 | fieldgroup_hdl->long_name.setValue(long_name_str); |
---|
[270] | 151 | } |
---|
| 152 | |
---|
| 153 | void xios_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; |
---|
[271] | 157 | |
---|
| 158 | fieldgroup_hdl->unit.setValue(unit_str); |
---|
[270] | 159 | } |
---|
| 160 | |
---|
| 161 | void xios_set_fieldgroup_operation(XFieldGroupPtr fieldgroup_hdl, const char * operation, int operation_size) |
---|
| 162 | { |
---|
| 163 | std::string operation_str; |
---|
[271] | 164 | if (!cstr2string(operation, operation_size, operation_str)) return; |
---|
| 165 | |
---|
| 166 | fieldgroup_hdl->operation.setValue(operation_str); |
---|
[270] | 167 | } |
---|
| 168 | |
---|
| 169 | void xios_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; |
---|
[271] | 173 | |
---|
| 174 | fieldgroup_hdl->freq_op.setValue(freq_op_str); |
---|
[270] | 175 | } |
---|
| 176 | |
---|
| 177 | void xios_set_fieldgroup_level(XFieldGroupPtr fieldgroup_hdl, int level) |
---|
| 178 | { |
---|
[271] | 179 | fieldgroup_hdl->level.setValue(level); |
---|
[270] | 180 | } |
---|
| 181 | |
---|
| 182 | void xios_set_fieldgroup_prec(XFieldGroupPtr fieldgroup_hdl, int prec) |
---|
| 183 | { |
---|
[271] | 184 | fieldgroup_hdl->prec.setValue(prec); |
---|
[270] | 185 | } |
---|
| 186 | |
---|
| 187 | void xios_set_fieldgroup_enabled(XFieldGroupPtr fieldgroup_hdl, bool enabled) |
---|
| 188 | { |
---|
[271] | 189 | fieldgroup_hdl->enabled.setValue(enabled); |
---|
[270] | 190 | } |
---|
| 191 | |
---|
| 192 | void xios_set_fieldgroup_domain_ref(XFieldGroupPtr fieldgroup_hdl, const char * domain_ref, int domain_ref_size) |
---|
| 193 | { |
---|
| 194 | std::string domain_ref_str; |
---|
[271] | 195 | if (!cstr2string(domain_ref, domain_ref_size, domain_ref_str)) return; |
---|
| 196 | |
---|
| 197 | fieldgroup_hdl->domain_ref.setValue(domain_ref_str); |
---|
[270] | 198 | } |
---|
| 199 | |
---|
| 200 | void xios_set_fieldgroup_axis_ref(XFieldGroupPtr fieldgroup_hdl, const char * axis_ref, int axis_ref_size) |
---|
| 201 | { |
---|
| 202 | std::string axis_ref_str; |
---|
[271] | 203 | if (!cstr2string(axis_ref, axis_ref_size, axis_ref_str)) return; |
---|
| 204 | |
---|
| 205 | fieldgroup_hdl->axis_ref.setValue(axis_ref_str); |
---|
[270] | 206 | } |
---|
| 207 | |
---|
| 208 | void xios_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; |
---|
[271] | 212 | |
---|
| 213 | fieldgroup_hdl->grid_ref.setValue(grid_ref_str); |
---|
[270] | 214 | } |
---|
| 215 | |
---|
| 216 | void xios_set_fieldgroup_field_ref(XFieldGroupPtr fieldgroup_hdl, const char * field_ref, int field_ref_size) |
---|
| 217 | { |
---|
| 218 | std::string field_ref_str; |
---|
[271] | 219 | if (!cstr2string(field_ref, field_ref_size, field_ref_str)) return; |
---|
| 220 | |
---|
| 221 | fieldgroup_hdl->field_ref.setValue(field_ref_str); |
---|
[270] | 222 | } |
---|
| 223 | |
---|
| 224 | void xios_set_fieldgroup_default_value(XFieldGroupPtr fieldgroup_hdl, double default_value) |
---|
| 225 | { |
---|
[271] | 226 | fieldgroup_hdl->default_value.setValue(default_value); |
---|
[270] | 227 | } |
---|
| 228 | |
---|
| 229 | // ------------------------ Création des handle ----------------------------- |
---|
| 230 | |
---|
| 231 | void xios_field_handle_create (XFieldPtr * _ret, const char * _id, int _id_len) |
---|
| 232 | { |
---|
| 233 | std::string id; |
---|
| 234 | if (!cstr2string(_id, _id_len, id)) return; |
---|
[271] | 235 | |
---|
| 236 | *_ret = xmlioserver::CObjectFactory::GetObject<xmlioserver::tree::CField>(id).get(); |
---|
[270] | 237 | } |
---|
| 238 | |
---|
| 239 | void xios_fieldgroup_handle_create (XFieldGroupPtr * _ret, const char * _id, int _id_len) |
---|
| 240 | { |
---|
| 241 | std::string id; |
---|
| 242 | if (!cstr2string(_id, _id_len, id)) return; |
---|
[271] | 243 | |
---|
| 244 | *_ret = xmlioserver::CObjectFactory::GetObject<xmlioserver::tree::CFieldGroup>(id).get(); |
---|
[270] | 245 | } |
---|
[285] | 246 | |
---|
| 247 | |
---|
| 248 | // -------------------- Vérification des identifiants ----------------------- |
---|
| 249 | |
---|
| 250 | void xios_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 xios_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 | } |
---|
[270] | 265 | |
---|
| 266 | } // extern "C" |
---|