Remove "Written by Ben Pfaff <blp@gnu.org>" lines everywhere.
[pspp-builds.git] / src / data / case-source.h
1 /* PSPP - computes sample statistics.
2    Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
3
4    This program is free software; you can redistribute it and/or
5    modify it under the terms of the GNU General Public License as
6    published by the Free Software Foundation; either version 2 of the
7    License, or (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful, but
10    WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program; if not, write to the Free Software
16    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17    02110-1301, USA. */
18
19 #ifndef CASE_SOURCE_H
20 #define CASE_SOURCE_H 1
21
22 #include <stdbool.h>
23
24 struct ccase;
25
26 typedef struct write_case_data *write_case_data;
27 typedef bool write_case_func (write_case_data);
28
29 /* A case source. */
30 struct case_source 
31   {
32     const struct case_source_class *class;      /* Class. */
33     void *aux;          /* Auxiliary data. */
34   };
35
36 /* A case source class. */
37 struct case_source_class
38   {
39     const char *name;                   /* Identifying name. */
40     
41     /* Returns the exact number of cases that READ will pass to
42        WRITE_CASE, if known, or -1 otherwise. */
43     int (*count) (const struct case_source *);
44
45     /* Reads the cases one by one into C and for each one calls
46        WRITE_CASE passing the given AUX data.
47        Returns true if successful, false if an I/O error occurred. */
48     bool (*read) (struct case_source *,
49                   struct ccase *c,
50                   write_case_func *write_case, write_case_data aux);
51
52     /* Destroys the source. */
53     void (*destroy) (struct case_source *);
54   };
55
56
57 struct case_source *create_case_source (const struct case_source_class *,
58                                         void *);
59 void free_case_source (struct case_source *);
60
61 bool case_source_is_class (const struct case_source *,
62                           const struct case_source_class *);
63
64 #endif /* case-source.h */