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 "object_template_impl.hpp" |
---|
11 | #include "group_template_impl.hpp" |
---|
12 | #include "attribute_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::CAxis * XAxisPtr; |
---|
23 | typedef xmlioserver::tree::CAxisGroup * XAxisGroupPtr; |
---|
24 | |
---|
25 | // ------------------------- Attributs des axes ----------------------------- |
---|
26 | void cxios_set_axis_name |
---|
27 | (XAxisPtr axis_hdl, const char * name , int name_size) |
---|
28 | { |
---|
29 | std::string name_str; |
---|
30 | if (!cstr2string(name, name_size, name_str)) return; |
---|
31 | |
---|
32 | axis_hdl->name.setValue(name_str); |
---|
33 | axis_hdl->sendAttributToServer(axis_hdl->name) ; |
---|
34 | } |
---|
35 | |
---|
36 | void cxios_set_axis_standard_name |
---|
37 | (XAxisPtr axis_hdl, const char * standard_name , int standard_name_size) |
---|
38 | { |
---|
39 | std::string standard_name_str; |
---|
40 | if (!cstr2string(standard_name, standard_name_size, standard_name_str)) return; |
---|
41 | |
---|
42 | axis_hdl->standard_name.setValue(standard_name_str); |
---|
43 | axis_hdl->sendAttributToServer(axis_hdl->standard_name); |
---|
44 | } |
---|
45 | |
---|
46 | void cxios_set_axis_long_name |
---|
47 | (XAxisPtr axis_hdl, const char * long_name , int long_name_size) |
---|
48 | { |
---|
49 | std::string long_name_str; |
---|
50 | if (!cstr2string(long_name, long_name_size, long_name_str)) return; |
---|
51 | |
---|
52 | axis_hdl->long_name.setValue(long_name_str); |
---|
53 | axis_hdl->sendAttributToServer(axis_hdl->long_name) ; |
---|
54 | } |
---|
55 | |
---|
56 | void cxios_set_axis_unit |
---|
57 | (XAxisPtr axis_hdl, const char * unit , int unit_size) |
---|
58 | { |
---|
59 | std::string unit_str; |
---|
60 | if (!cstr2string(unit, unit_size, unit_str)) return; |
---|
61 | |
---|
62 | axis_hdl->unit.setValue(unit_str); |
---|
63 | axis_hdl->sendAttributToServer(axis_hdl->unit) ; |
---|
64 | } |
---|
65 | |
---|
66 | void cxios_set_axis_size(XAxisPtr axis_hdl, int size) |
---|
67 | { |
---|
68 | axis_hdl->size.setValue(size); |
---|
69 | axis_hdl->sendAttributToServer(axis_hdl->size) ; |
---|
70 | } |
---|
71 | |
---|
72 | void cxios_set_axis_zvalue |
---|
73 | (XAxisPtr axis_hdl, const double * zvalue , int zvalue_extent1) |
---|
74 | { |
---|
75 | ARRAY(double, 1) zvalue_val(new CArray<double, 1>(boost::extents [zvalue_extent1])); |
---|
76 | std::copy(zvalue, &(zvalue[zvalue_val->num_elements()]), zvalue_val->data()); |
---|
77 | |
---|
78 | axis_hdl->zvalue.setValue(zvalue_val); |
---|
79 | axis_hdl->sendAttributToServer(axis_hdl->zvalue) ; |
---|
80 | |
---|
81 | } |
---|
82 | |
---|
83 | // -------------------- Attributs des groupes d'axes ------------------------- |
---|
84 | |
---|
85 | void cxios_set_axisgroup_name |
---|
86 | (XAxisGroupPtr axisgroup_hdl, const char * name , int name_size) |
---|
87 | { |
---|
88 | std::string name_str; |
---|
89 | if (!cstr2string(name, name_size, name_str)) return; |
---|
90 | |
---|
91 | axisgroup_hdl->name.setValue(name_str); |
---|
92 | axisgroup_hdl->sendAttributToServer(axisgroup_hdl->name) ; |
---|
93 | } |
---|
94 | |
---|
95 | void cxios_set_axisgroup_standard_name |
---|
96 | (XAxisGroupPtr axisgroup_hdl, const char * standard_name , int standard_name_size) |
---|
97 | { |
---|
98 | std::string standard_name_str; |
---|
99 | if (!cstr2string(standard_name, standard_name_size, standard_name_str)) return; |
---|
100 | |
---|
101 | axisgroup_hdl->standard_name.setValue(standard_name_str); |
---|
102 | axisgroup_hdl->sendAttributToServer(axisgroup_hdl->standard_name) ; |
---|
103 | } |
---|
104 | |
---|
105 | void cxios_set_axisgroup_long_name |
---|
106 | (XAxisGroupPtr axisgroup_hdl, const char * long_name , int long_name_size) |
---|
107 | { |
---|
108 | std::string long_name_str; |
---|
109 | if (!cstr2string(long_name, long_name_size, long_name_str)) return; |
---|
110 | |
---|
111 | axisgroup_hdl->long_name.setValue(long_name_str); |
---|
112 | axisgroup_hdl->sendAttributToServer(axisgroup_hdl->long_name) ; |
---|
113 | } |
---|
114 | |
---|
115 | void cxios_set_axisgroup_unit |
---|
116 | (XAxisGroupPtr axisgroup_hdl, const char * unit , int unit_size) |
---|
117 | { |
---|
118 | std::string unit_str; |
---|
119 | if (!cstr2string(unit, unit_size, unit_str)) return; |
---|
120 | |
---|
121 | axisgroup_hdl->unit.setValue(unit_str); |
---|
122 | axisgroup_hdl->sendAttributToServer(axisgroup_hdl->unit) ; |
---|
123 | } |
---|
124 | |
---|
125 | void cxios_set_axisgroup_size(XAxisGroupPtr axisgroup_hdl, int size) |
---|
126 | { |
---|
127 | axisgroup_hdl->size.setValue(size); |
---|
128 | axisgroup_hdl->sendAttributToServer(axisgroup_hdl->size) ; |
---|
129 | } |
---|
130 | |
---|
131 | void cxios_set_axisgroup_zvalue |
---|
132 | (XAxisGroupPtr axisgroup_hdl, const double * zvalue , int zvalue_extent1) |
---|
133 | { |
---|
134 | ARRAY(double, 1) zvalue_val(new CArray<double, 1>(boost::extents [zvalue_extent1])); |
---|
135 | std::copy(zvalue, &(zvalue[zvalue_val->num_elements()]), zvalue_val->data()); |
---|
136 | |
---|
137 | axisgroup_hdl->zvalue.setValue(zvalue_val); |
---|
138 | axisgroup_hdl->sendAttributToServer(axisgroup_hdl->zvalue) ; |
---|
139 | } |
---|
140 | |
---|
141 | // ------------------------ Création des handle ----------------------------- |
---|
142 | |
---|
143 | void cxios_axis_handle_create (XAxisPtr * _ret, const char * _id, int _id_len) |
---|
144 | { |
---|
145 | std::string id; |
---|
146 | if (!cstr2string(_id, _id_len, id)) return; |
---|
147 | |
---|
148 | *_ret = xmlioserver::CObjectFactory::GetObject<xmlioserver::tree::CAxis>(id).get(); |
---|
149 | } |
---|
150 | |
---|
151 | void cxios_axisgroup_handle_create (XAxisGroupPtr * _ret, const char * _id, int _id_len) |
---|
152 | { |
---|
153 | std::string id; |
---|
154 | if (!cstr2string(_id, _id_len, id)) return; |
---|
155 | |
---|
156 | *_ret = xmlioserver::CObjectFactory::GetObject<xmlioserver::tree::CAxisGroup>(id).get(); |
---|
157 | } |
---|
158 | |
---|
159 | // -------------------- Vérification des identifiants ----------------------- |
---|
160 | |
---|
161 | void cxios_axis_valid_id (bool * _ret, const char * _id, int _id_len) |
---|
162 | { |
---|
163 | std::string id; |
---|
164 | if (!cstr2string(_id, _id_len, id)) return; |
---|
165 | |
---|
166 | *_ret = xmlioserver::CObjectFactory::HasObject<xmlioserver::tree::CAxis>(id); |
---|
167 | } |
---|
168 | |
---|
169 | void cxios_axisgroup_valid_id (bool * _ret, const char * _id, int _id_len) |
---|
170 | { |
---|
171 | std::string id; |
---|
172 | if (!cstr2string(_id, _id_len, id)) return; |
---|
173 | |
---|
174 | *_ret = xmlioserver::CObjectFactory::HasObject<xmlioserver::tree::CAxisGroup>(id); |
---|
175 | } |
---|
176 | |
---|
177 | } // extern "C" |
---|