source: XMLIO_V2/dev/dev_rv/src/XMLIO/c_interface.hpp @ 137

Last change on this file since 137 was 137, checked in by hozdoba, 14 years ago

mise à jour

File size: 5.5 KB
Line 
1#ifndef __C_INTERFACE__
2#define __C_INTERFACE__
3
4#include "xmlio.hpp"
5
6using namespace XMLIOSERVER;
7using namespace XMLIOSERVER::XML;
8
9typedef long int XInt, XSize; // Integer
10typedef bool     XBool;       // Logical
11typedef void   * XPtr;        // Pointeur C non typé
12typedef char   * XString;     // Pointeur C non typé
13
14typedef enum
15{
16   NOTYPE = 0,
17   DTREATMENT/* UNUSED */, DATE, CALENDAR, ECONTEXT,
18   EAXIS, EDOMAIN, EFIELD, EFILE, EGRID,
19   GAXIS, GDOMAIN, GFIELD, GFILE, GGRID
20} XDType;
21
22typedef enum
23{
24   NETCDF4 = 0
25} XFileType;
26
27typedef enum
28 { D360 = 0 , ALLLEAP, NOLEAP, JULIAN, GREGORIAN } XCalendarType ;
29
30typedef struct // Référence C à une objet de la bibliothÚque.
31{ XDType data_type; XPtr data_ptr; } XHandle;
32
33#define MAKE_STRING(var_name, str_arg, int_arg)             \
34      std::string var_name##temp;                           \
35      var_name##temp.append (str_arg, int_arg);             \
36      size_t d = var_name##temp.find_first_not_of(' ');     \
37      size_t f = var_name##temp.find_last_not_of (' ');     \
38      std::string var_name = var_name##temp.substr(d, f-d+1)
39
40#define XML_SET(type, type_var, var, long_var) \
41   void xios_xml_set_##type##_##var(XPtr const _##type, XDType _dtype, type_var var)
42
43#define XML_SET_STRING(type, var, long_var) \
44   void xios_xml_set_##type##_##var(XPtr const _##type, XDType _dtype, const XString _##var, XSize _##var##_len)
45
46#ifdef __cplusplus
47extern"C"
48{
49#endif //__cplusplus
50
51/* ******************** HANDLE INTERFACE ******************** */
52void xios_handle_create (XPtr * const _ret, XDType _dtype, const XString _id, XSize _id_len);
53
54/* ******************** XML INTERFACE *********************** */
55void xios_xml_parse_file  (const XString _filename, XSize _filename_len);
56void xios_xml_parse_string(const XString _xmlcontent, XSize _xmlcontent_len);
57
58/* ******************** CONTEXT INTERFACE ******************* */
59void xios_context_set_current (XPtr const _ctx, bool _wswap);
60void xios_context_create (XPtr * _ctx, const XString _ctx_id, XSize _ctx_id_len, XCalendarType _calType);
61
62/* ******************  XML TREE INTERFACE ******************* */
63void xios_xml_tree_add(const XPtr _parent, XDType _parent_type, XPtr * _child,
64                       XDType _child_type, const XString _child_id, XSize _child_id_len);
65void xios_xml_tree_show(const XString _filename, XSize _filename_len);
66
67// Attributs de field ou field_group
68XML_SET_STRING(field, name, name);
69XML_SET_STRING(field, sname, standard_name);
70XML_SET_STRING(field, lname, long_name);
71XML_SET_STRING(field, unit, unit);
72XML_SET_STRING(field, operation, operation);
73
74void xios_xml_set_field_freq_op(XPtr const _field, XDType _dtype,
75                                 double year, double month, double day,
76                                 double hour, double minute, double second);
77
78XML_SET(field, int, level, level);
79XML_SET(field, int, prec, prec);
80XML_SET(field, bool, enabled, enabled);
81
82XML_SET_STRING(field, dref, domain_ref);
83XML_SET_STRING(field, aref, axis_ref);
84XML_SET_STRING(field, gref, grid_ref);
85XML_SET_STRING(field, zref, zoom_ref);
86XML_SET_STRING(field, fref, field_ref);
87
88// Attributs de file ou file_group
89XML_SET_STRING(file, name, name) ;
90XML_SET_STRING(file, description, description);
91void xios_xml_set_file_output_freq(XPtr const _file, XDType _dtype,
92                                   double year, double month, double day,
93                                   double hour, double minute, double second);
94
95XML_SET(file, int, olevel, output_level);
96XML_SET(file, bool, enabled, enabled);
97
98// Attributs de grid ou grid_group
99XML_SET_STRING(grid, name, name) ;
100XML_SET_STRING(grid, description, description) ;
101XML_SET_STRING(grid, dref, domain_ref) ;
102XML_SET_STRING(grid, aref, axis_ref) ;
103
104// Attribut de axis ou axis_group
105XML_SET_STRING(axis, name, name) ;
106XML_SET_STRING(axis, sname, standard_name) ;
107XML_SET_STRING(axis, lname, long_name) ;
108
109XML_SET_STRING(axis, unit, unit) ;
110
111void xios_xml_set_axis_value(XPtr const _file, XDType _dtype, double value[], XSize value_size);
112
113
114// Attribut de domain ou domain_group
115XML_SET_STRING(domain, name, name) ;
116XML_SET_STRING(domain, sname, standard_name) ;
117XML_SET_STRING(domain, lname, long_name) ;
118
119XML_SET(domain, int, niglo, ni_glo);
120XML_SET(domain, int, njglo, nj_glo);
121
122XML_SET(domain, int, ibegin, ibegin);
123XML_SET(domain, int, iend, iend);
124XML_SET(domain, int, ni, ni);
125
126XML_SET(domain, int, jbegin, jbegin);
127XML_SET(domain, int, jend, jend);
128XML_SET(domain, int, nj, nj);
129
130void xios_xml_set_domain_mask(XPtr const _domain, XDType _dtype, bool * _mask , XSize _maskXsize, XSize _maskYsize);
131
132XML_SET(domain, int, ddim, data_dim);
133XML_SET(domain, int, dni, data_ni);
134XML_SET(domain, int, dnj, data_nj);
135XML_SET(domain, int, dibegin, data_ibegin);
136XML_SET(domain, int, djbegin, data_jbegin);
137
138XML_SET(domain, int, dnindex, data_n_index);
139
140void xios_xml_set_domain_diindex(XPtr const _domain, XDType _dtype, int _diindex[], XSize _diindex_size);
141void xios_xml_set_domain_djindex(XPtr const _domain, XDType _dtype, int _djindex[], XSize _djindex_size);
142
143void xios_xml_set_domain_lonvalue(XPtr const _domain, XDType _dtype, double _lonvalue[], XSize _lonvalue_Xsize, XSize _lonvalue_Ysize);
144void xios_xml_set_domain_latvalue(XPtr const _domain, XDType _dtype, double _latvalue[], XSize _latvalue_Xsize, XSize _latvalue_Ysize);
145
146XML_SET_STRING(domain, domtype, domtype) ;
147
148/* ******************  DATA TREATMENT INTERFACE ******************* */
149void xios_dtreatment_start(XPtr const _context, XFileType filetype);
150
151#ifdef __cplusplus
152}
153#endif //__cplusplus
154
155
156#endif //__C_INTERFACE__
Note: See TracBrowser for help on using the repository browser.