3 * wavefile.h - definitions for WaveFile, routines and data structures
4 * for reading and working with entire datasets of waveform data.
6 * Copyright 1999,2005 Stephen G. Tell.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the Free
20 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include <spicestream.h>
30 typedef struct _WaveFile WaveFile
;
31 typedef struct _WaveVar WaveVar
;
32 typedef struct _WDataSet WDataSet
;
33 typedef struct _WvTable WvTable
;
36 * an array of double-precision floating-point values, used to store a
37 * column of values. Organized as a block structure because we don't know
38 * how many entries there will be without reading the file, and we don't
39 * want to read the whole thing twice.
41 * Depending on what the memory allocator does, this might even
42 * end up being relatively cache-friendly. TODO: think more about this.
45 #define DS_DBLKSIZE 8192
46 #define DS_INBLKS 1024
47 #define ds_blockno(n) ((n) / DS_DBLKSIZE)
48 #define ds_offset(n) ((n) % DS_DBLKSIZE)
54 /* remaining stuff is an array storage structure
55 * that could be abstracted out and/or replaced with somthing else */
56 /* pointer to array of pointers to blocks of doubles */
58 int bpsize
; /* size of array of pointers */
59 int bpused
; /* number of blocks actually allocated */
63 /* Wave Variable - used for independent or dependent variable.
67 WvTable
*wtable
; /* backpointer to file */
68 WDataSet
*wds
; /* data for one or more columns */
72 #define wv_name sv->name
73 #define wv_type sv->type
74 #define wv_ncols sv->ncols
75 #define wv_nvalues wtable->nvalues
76 #define wv_iv wtable->iv
77 #define wv_file wtable->wf
79 #define wv_is_multisweep(WV) ((WV)->wtable->wf->wf_ntables>1)
82 * Wave Table - association of one or more dependent variables with
83 * a contiguous, nondecreasing independent variable.
87 int swindex
; /* index of the sweep, 0-based */
88 char *name
; /* name of the sweep, if any, else NULL */
89 double swval
; /* value at which the sweep was taken */
90 int nvalues
; /* number of rows */
91 WaveVar
*iv
; /* pointer to single independent variable */
92 WaveVar
*dv
; /* pointer to array of dependent var info */
95 #define wt_ndv wf->ss->ndv
98 * WaveFile - data struture containing all of the data from a file.
102 GPtrArray
*tables
; /* array of WvTable* */
106 #define wf_filename ss->filename
107 #define wf_ndv ss->ndv
108 #define wf_ncols ss->ncols
109 #define wf_ntables tables->len
110 #define wf_wtable(WF,I) (WvTable*)g_ptr_array_index((WF)->tables, (I))
113 /* defined in wavefile.c */
114 extern WaveFile
*wf_read(char *name
, char *format
);
115 extern double wv_interp_value(WaveVar
*dv
, double ival
);
116 extern int wf_find_point(WaveVar
*iv
, double ival
);
117 extern double wds_get_point(WDataSet
*ds
, int n
);
118 extern void wf_free(WaveFile
*df
);
119 extern WaveVar
*wf_find_variable(WaveFile
*wf
, char *varname
, int swpno
);
120 extern void wf_foreach_wavevar(WaveFile
*wf
, GFunc func
, gpointer
*p
);
122 #endif /* WAVEFILE_H */