1 /* PSPP - computes sample statistics.
2 Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
3 Written by Ben Pfaff <blp@gnu.org>.
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 /* This is the time at which vfm was last invoked. */
26 extern time_t last_vfm_invocation;
29 typedef struct write_case_data *write_case_data;
30 typedef int write_case_func (write_case_data);
32 /* The current active file, from which cases are read. */
33 extern struct case_source *vfm_source;
38 const struct case_source_class *class; /* Class. */
39 size_t value_cnt; /* Number of `union value's in case. */
40 void *aux; /* Auxiliary data. */
43 /* A case source class. */
44 struct case_source_class
46 const char *name; /* Identifying name. */
48 /* Returns the exact number of cases that READ will pass to
49 WRITE_CASE, if known, or -1 otherwise. */
50 int (*count) (const struct case_source *);
52 /* Reads the cases one by one into C and for each one calls
53 WRITE_CASE passing the given AUX data. */
54 void (*read) (struct case_source *,
56 write_case_func *write_case, write_case_data aux);
58 /* Destroys the source. */
59 void (*destroy) (struct case_source *);
62 extern const struct case_source_class storage_source_class;
63 extern const struct case_source_class data_list_source_class;
64 extern const struct case_source_class file_type_source_class;
65 extern const struct case_source_class input_program_source_class;
66 extern const struct case_source_class get_source_class;
67 extern const struct case_source_class import_source_class;
68 extern const struct case_source_class sort_source_class;
71 struct case_source *create_case_source (const struct case_source_class *,
72 const struct dictionary *,
74 int case_source_is_complex (const struct case_source *);
75 int case_source_is_class (const struct case_source *,
76 const struct case_source_class *);
78 int storage_source_on_disk (const struct case_source *);
79 struct case_list *storage_source_get_cases (const struct case_source *);
80 void storage_source_set_cases (const struct case_source *,
82 void storage_source_to_disk (struct case_source *source);
84 /* The replacement active file, to which cases are written. */
85 extern struct case_sink *vfm_sink;
90 const struct case_sink_class *class; /* Class. */
91 void *aux; /* Auxiliary data. */
93 /* Cases written to a case sink belong to a dictionary, but
94 their data is compacted to drop scratch variables. */
95 const struct dictionary *dict; /* Dictionary for cases. */
96 int *idx_to_fv; /* `dict' index -> case `data' index. */
97 size_t value_cnt; /* Number of `union value's in case. */
100 /* A case sink class. */
101 struct case_sink_class
103 const char *name; /* Identifying name. */
105 /* Opens the sink for writing. */
106 void (*open) (struct case_sink *);
108 /* Writes a case to the sink. */
109 void (*write) (struct case_sink *, const struct ccase *);
111 /* Closes and destroys the sink. */
112 void (*destroy) (struct case_sink *);
114 /* Closes and destroys the sink and returns a source that can
115 read back the cases that were written, perhaps transformed
117 struct case_source *(*make_source) (struct case_sink *);
120 extern const struct case_sink_class storage_sink_class;
121 extern const struct case_sink_class null_sink_class;
123 struct case_sink *create_case_sink (const struct case_sink_class *,
124 const struct dictionary *,
126 void free_case_sink (struct case_sink *);
128 /* Number of cases to lag. */
131 void procedure (int (*proc_func) (struct ccase *, void *aux), void *aux);
132 void procedure_with_splits (void (*begin_func) (void *aux),
133 int (*proc_func) (struct ccase *, void *aux),
134 void (*end_func) (void *aux),
136 struct ccase *lagged_case (int n_before);