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;
28 /* This is the case that is to be filled in by input programs. */
29 extern struct ccase *temp_case;
31 typedef struct write_case_data *write_case_data;
32 typedef int write_case_func (write_case_data);
34 /* The current active file, from which cases are read. */
35 extern struct case_source *vfm_source;
40 const struct case_source_class *class; /* Class. */
41 void *aux; /* Auxiliary data. */
44 /* A case source class. */
45 struct case_source_class
47 const char *name; /* Identifying name. */
49 /* Returns the exact number of cases that READ will pass to
50 WRITE_CASE, if known, or -1 otherwise. */
51 int (*count) (const struct case_source *);
53 /* Reads all the cases and calls WRITE_CASE passing the given
54 AUX data for each one. */
55 void (*read) (struct case_source *, write_case_func *, write_case_data);
57 /* Destroys the source. */
58 void (*destroy) (struct case_source *);
61 extern const struct case_source_class memory_source_class;
62 extern const struct case_source_class disk_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;
70 struct case_source *create_case_source (const struct case_source_class *,
72 int case_source_is_complex (const struct case_source *);
73 int case_source_is_class (const struct case_source *,
74 const struct case_source_class *);
75 struct case_list *memory_source_get_cases (const struct case_source *);
76 void memory_source_set_cases (const struct case_source *,
79 /* The replacement active file, to which cases are written. */
80 extern struct case_sink *vfm_sink;
85 const struct case_sink_class *class; /* Class. */
86 void *aux; /* Auxiliary data. */
89 /* A case sink class. */
90 struct case_sink_class
92 const char *name; /* Identifying name. */
94 /* Creates the sink and opens it for writing. */
95 void (*open) (struct case_sink *);
97 /* Writes a case to the sink. */
98 void (*write) (struct case_sink *, struct ccase *);
100 /* Closes and destroys the sink. */
101 void (*destroy) (struct case_sink *);
103 /* Closes and destroys the sink and returns a source that can
104 read back the cases that were written, perhaps transformed
106 struct case_source *(*make_source) (struct case_sink *);
109 extern const struct case_sink_class memory_sink_class;
110 extern const struct case_sink_class disk_sink_class;
111 extern const struct case_sink_class sort_sink_class;
113 struct case_sink *create_case_sink (const struct case_sink_class *, void *);
115 /* Number of cases to lag. */
118 void procedure (void (*beginfunc) (void *aux),
119 int (*procfunc) (struct ccase *curcase, void *aux),
120 void (*endfunc) (void *aux),
122 struct ccase *lagged_case (int n_before);
123 void compact_case (struct ccase *dest, const struct ccase *src);
124 void write_active_file_to_disk (void);
126 void process_active_file (void (*beginfunc) (void *),
127 int (*casefunc) (struct ccase *curcase, void *),
128 void (*endfunc) (void *),
130 void process_active_file_output_case (void);