vartable.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 DBA_VARTABLE_H
00023 #define DBA_VARTABLE_H
00024 
00025 #ifdef  __cplusplus
00026 extern "C" {
00027 #endif
00028 
00085 #include <dballe/core/error.h>
00086 
00090 typedef short unsigned int dba_varcode;
00091 
00097 typedef short unsigned int dba_alteration;
00098 
00106 struct _dba_varinfo
00107 {
00109     dba_varcode var;
00111     char desc[64];
00113     char unit[24];
00116     int scale;
00119     int ref;
00122     int len;
00125     int bit_ref;
00128     int bit_len;
00130     int is_string;
00132     int imin;
00134     int imax;
00136     double dmin;
00138     double dmax;
00140     dba_alteration alteration;
00142     struct _dba_varinfo* alterations;
00143 };
00145 typedef struct _dba_varinfo* dba_varinfo;
00146 
00154 struct _dba_vartable;
00156 typedef struct _dba_vartable* dba_vartable;
00157 
00161 #define DBA_VAR(f, x, y) ((dba_varcode)( ((unsigned)(f)<<14) | ((unsigned)(x)<<8) | (unsigned)(y) ))
00162 
00169 #define DBA_STRING_TO_VAR(str) ((dba_varcode)( \
00170         (( ((str)[0] - '0')*10 + ((str)[1] - '0') ) << 8) | \
00171         ( ((str)[2] - '0')*100 + ((str)[3] - '0')*10 + ((str)[4] - '0') ) \
00172 ))
00173 
00177 #define DBA_VAR_F(code) ((code) >> 14)
00178 
00181 #define DBA_VAR_X(code) ((code) >> 8 & 0x3f)
00182 
00185 #define DBA_VAR_Y(code) ((code) & 0xff)
00186 
00190 #define DBA_ALT(width, scale) (((width)+128) << 8 | ((scale)+128))
00191 
00195 #define DBA_ALT_WIDTH(code) (((code) >> 8) - 128)
00196 
00200 #define DBA_ALT_SCALE(code) (((code) & 0xff) - 128)
00201 
00214 dba_err dba_varinfo_query_local(dba_varcode code, dba_varinfo* info);
00215 
00230 dba_err dba_varinfo_query_local_altered(dba_varcode code, dba_alteration change, dba_varinfo* info);
00231 
00242 dba_err dba_varinfo_get_local_table(dba_vartable* table);
00243 
00254 dba_varcode dba_descriptor_code(const char* desc);
00255 
00268 dba_err dba_vartable_create(const char* id, dba_vartable* table);
00269 
00279 const char* dba_vartable_id(dba_vartable table);
00280 
00295 dba_err dba_vartable_query(dba_vartable table, dba_varcode var, dba_varinfo* info);
00296 
00313 dba_err dba_vartable_query_altered(dba_vartable table, dba_varcode var, dba_alteration change, dba_varinfo* info);
00314 
00323 typedef void (*dba_vartable_iterator)(dba_varinfo info, void* data);
00324 
00337 dba_err dba_vartable_iterate(dba_vartable table, dba_vartable_iterator func, void* data);
00338 
00339 #ifdef  __cplusplus
00340 }
00341 #endif
00342 
00343 #endif
00344 /* vim:set ts=4 sw=4: */

Generated on Thu Aug 30 14:59:05 2007 for libdballe-core by  doxygen 1.5.3