Remove "Written by Ben Pfaff <blp@gnu.org>" lines everywhere.
[pspp-builds.git] / src / data / casefile-private.h
1 /* PSPP - computes sample statistics.
2    Copyright (C) 2004, 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 CASEFILE_PRIVATE_H
20 #define CASEFILE_PRIVATE_H
21
22 #include <config.h>
23 #include <stdbool.h>
24 #include <libpspp/ll.h>
25
26 struct ccase;
27 struct casereader;
28 struct casefile;
29 struct casefilter;
30
31 struct class_casefile
32 {
33   void (*destroy) (struct casefile *) ;
34
35   bool (*error) (const struct casefile *) ;
36
37   size_t (*get_value_cnt) (const struct casefile *) ;
38   unsigned long (*get_case_cnt) (const struct casefile *) ;
39
40   struct casereader * (*get_reader) (const struct casefile *) ; 
41
42   bool (*append) (struct casefile *, const struct ccase *) ;
43
44
45   bool (*in_core) (const struct casefile *) ;
46   bool (*to_disk) (const struct casefile *) ;
47   bool (*sleep) (const struct casefile *) ;
48 };
49
50 struct casefile
51 {
52   const struct class_casefile *class ;   /* Class pointer */
53
54   struct ll_list reader_list ;       /* List of our readers. */
55   struct ll ll ;                    /* Element in the class' list 
56                                        of casefiles. */
57   bool being_destroyed;            /* A destructive reader exists */
58 };
59
60
61 struct class_casereader
62 {
63   struct ccase * (*get_next_case) (struct casereader *);
64
65   unsigned long (*cnum) (const struct casereader *);
66
67   void (*destroy) (struct casereader * r);
68
69   struct casereader * (*clone) (const struct casereader *);
70 };
71
72
73 #define CLASS_CASEREADER(K) ( (struct class_casereader *) K)
74
75 struct casereader
76 {
77   const struct class_casereader *class;  /* Class pointer */
78
79   struct casefile *cf;   /* The casefile to which this reader belongs */
80   struct ll ll;          /* Element in the casefile's list of readers */
81
82   struct casefilter *filter; /* The filter to be used */
83   bool destructive;      /* True if this reader is destructive */
84 };
85
86
87 #define CASEFILE(C)        ( (struct casefile *) C)
88 #define CONST_CASEFILE(C) ( (const struct casefile *) C)
89
90 #define CASEFILEREADER(CR) ((struct casereader *) CR)
91
92
93 /* Functions for implementations' use  only */
94
95 void casefile_register (struct casefile *cf, 
96                         const struct class_casefile *k);
97
98 void casereader_register (struct casefile *cf, 
99                           struct casereader *reader, 
100                           const struct class_casereader *k);
101
102 #endif