msg.h

Go to the documentation of this file.
00001 /*
00002  * DB-ALLe - Archive for punctual meteorological data
00003  *
00004  * Copyright (C) 2005,2006  ARPA-SIM <urpsim@smr.arpa.emr.it>
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00018  *
00019  * Author: Enrico Zini <enrico@enricozini.com>
00020  */
00021 
00022 #ifndef DBALLE_BUFREX_MSG_H
00023 #define DBALLE_BUFREX_MSG_H
00024 
00025 #ifdef  __cplusplus
00026 extern "C" {
00027 #endif
00028 
00035 #include <dballe/core/var.h>
00036 #include <dballe/core/rawmsg.h>
00037 #include <dballe/bufrex/dtable.h>
00038 #include <dballe/bufrex/subset.h>
00039 
00043 enum _bufrex_type {
00045     BUFREX_BUFR,
00047     BUFREX_CREX
00048 };
00050 typedef enum _bufrex_type bufrex_type;
00051 
00052 struct _bufrex_opcode;
00053 
00055 struct _bufrex_bufr_options {
00057     int origin;
00059     int master_table;
00061     int local_table;
00062 };
00064 struct _bufrex_crex_options {
00066     int master_table;
00068     int table;
00069 };
00070 
00074 struct _bufrex_msg
00075 {
00077     bufrex_type encoding_type;
00078 
00080     union {
00081         struct _bufrex_crex_options crex;
00082         struct _bufrex_bufr_options bufr;
00083     } opt;
00084 
00086     int type;
00088     int subtype;
00089 
00091     int edition;
00092 
00095     int rep_year;   
00096     int rep_month;  
00097     int rep_day;    
00098     int rep_hour;   
00099     int rep_minute; 
00103     dba_vartable btable;
00105     bufrex_dtable dtable;
00106 
00108     bufrex_subset* subsets;
00110     size_t subsets_count;
00112     size_t subsets_alloclen;
00113 
00115     bufrex_opcode datadesc;
00120     bufrex_opcode* datadesc_last;
00121 };
00123 typedef struct _bufrex_msg* bufrex_msg;
00124 
00135 dba_err bufrex_msg_create(bufrex_type type, bufrex_msg* msg);
00136 
00143 void bufrex_msg_delete(bufrex_msg msg);
00144 
00154 void bufrex_msg_reset(bufrex_msg msg);
00155 
00172 dba_err bufrex_msg_get_subset(bufrex_msg msg, int subsection, bufrex_subset* vars);
00173 
00183 dba_err bufrex_msg_get_table_id(bufrex_msg msg, const char** id);
00184 
00188 dba_err bufrex_msg_load_tables(bufrex_msg msg);
00189 
00203 dba_err bufrex_msg_query_btable(bufrex_msg msg, dba_varcode code, dba_varinfo* info);
00204 
00218 dba_err bufrex_msg_query_dtable(bufrex_msg msg, dba_varcode code, struct _bufrex_opcode** res);
00219 
00226 void bufrex_msg_reset_datadesc(bufrex_msg msg);
00227 
00240 dba_err bufrex_msg_get_datadesc(bufrex_msg msg, struct _bufrex_opcode** res);
00241 
00252 dba_err bufrex_msg_append_datadesc(bufrex_msg msg, dba_varcode varcode);
00253 
00263 dba_err bufrex_msg_generate_datadesc(bufrex_msg msg);
00264 
00268 dba_err bufrex_msg_decode(bufrex_msg msg, dba_rawmsg raw);
00269 
00273 dba_err bufrex_msg_encode(bufrex_msg msg, dba_rawmsg* raw);
00274 
00275 
00286 dba_err bufr_encoder_encode(bufrex_msg in, dba_rawmsg out);
00287 
00302 dba_err bufr_decoder_decode(dba_rawmsg in, bufrex_msg out);
00303 
00314 dba_err crex_encoder_encode(bufrex_msg in, dba_rawmsg out);
00315 
00330 dba_err crex_decoder_decode(dba_rawmsg in, bufrex_msg out);
00331 
00335 void bufrex_msg_print(bufrex_msg msg, FILE* out);
00336 
00340 void bufrex_msg_diff(bufrex_msg msg1, bufrex_msg msg2, int* diffs, FILE* out);
00341 
00342 #ifdef  __cplusplus
00343 }
00344 #endif
00345 
00346 /* vim:set ts=4 sw=4: */
00347 #endif

Generated on Fri Jun 22 15:34:02 2007 for libdballe-db by  doxygen 1.5.2