X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fvfm.h;h=cfd639a925ead255085b610cc7f6bb49aca25637;hb=053e7ff6e0a45a25d5604b211e9c950fff50e75d;hp=27cac23549f555418dfe1a0a00a1c626e88ec357;hpb=5906e30c29662d12594199e1652ba3a7e5670944;p=pspp diff --git a/src/vfm.h b/src/vfm.h index 27cac23549..cfd639a925 100644 --- a/src/vfm.h +++ b/src/vfm.h @@ -14,91 +14,120 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ #if !vfm_h #define vfm_h 1 -#include "cases.h" #include -/* This is the time at which vfm was last invoked. */ -extern time_t last_vfm_invocation; - -/* This is the case that is to be filled in by input programs. */ -extern struct ccase *temp_case; - -/* `value' indexes to initialize to particular values for certain cases. */ -extern struct long_vec reinit_sysmis; /* SYSMIS for every case. */ -extern struct long_vec reinit_blanks; /* Blanks for every case. */ -extern struct long_vec init_zero; /* Zero for first case only. */ -extern struct long_vec init_blanks; /* Blanks for first case only. */ - +struct ccase; typedef struct write_case_data *write_case_data; typedef int write_case_func (write_case_data); + +/* The current active file, from which cases are read. */ +extern struct case_source *vfm_source; -/* A case stream: either a source or a sink, depending on context. */ -struct case_stream +/* A case source. */ +struct case_source { - /* Initializes sink. */ - void (*init) (void); - - /* Reads all the cases and calls WRITE_CASE passing the given - AUX data for each one. */ - void (*read) (write_case_func *, write_case_data); - - /* Writes a single case, temp_case. */ - void (*write) (void); + const struct case_source_class *class; /* Class. */ + void *aux; /* Auxiliary data. */ + }; - /* Switches mode from sink to source. */ - void (*mode) (void); +/* A case source class. */ +struct case_source_class + { + const char *name; /* Identifying name. */ - /* Discards source's internal data. */ - void (*destroy_source) (void); + /* Returns the exact number of cases that READ will pass to + WRITE_CASE, if known, or -1 otherwise. */ + int (*count) (const struct case_source *); + + /* Reads the cases one by one into C and for each one calls + WRITE_CASE passing the given AUX data. */ + void (*read) (struct case_source *, + struct ccase *c, + write_case_func *write_case, write_case_data aux); + + /* Destroys the source. */ + void (*destroy) (struct case_source *); + }; - /* Discards sink's internal data. */ - void (*destroy_sink) (void); +extern const struct case_source_class storage_source_class; +extern const struct case_source_class file_type_source_class; +extern const struct case_source_class input_program_source_class; - /* Identifying name for the stream. */ - const char *name; - }; +struct dictionary; +struct case_source *create_case_source (const struct case_source_class *, + void *); +void free_case_source (struct case_source *); -/* This is used to read from the active file. */ -extern struct case_stream *vfm_source; +int case_source_is_complex (const struct case_source *); +int case_source_is_class (const struct case_source *, + const struct case_source_class *); -/* This is used to write to the replacement active file. */ -extern struct case_stream *vfm_sink; +struct casefile *storage_source_get_casefile (struct case_source *); +struct case_source *storage_source_create (struct casefile *); + +/* The replacement active file, to which cases are written. */ +extern struct case_sink *vfm_sink; -/* General data streams. */ -extern struct case_stream vfm_memory_stream; -extern struct case_stream vfm_disk_stream; -extern struct case_stream sort_stream; -extern struct case_stream flip_stream; +/* A case sink. */ +struct case_sink + { + const struct case_sink_class *class; /* Class. */ + void *aux; /* Auxiliary data. */ + size_t value_cnt; /* Number of `union value's in case. */ + }; -/* Streams that are only sources. */ -extern struct case_stream data_list_source; -extern struct case_stream input_program_source; -extern struct case_stream file_type_source; -extern struct case_stream get_source; -extern struct case_stream import_source; -extern struct case_stream matrix_data_source; +/* A case sink class. */ +struct case_sink_class + { + const char *name; /* Identifying name. */ + + /* Opens the sink for writing. */ + void (*open) (struct case_sink *); + + /* Writes a case to the sink. */ + void (*write) (struct case_sink *, const struct ccase *); + + /* Closes and destroys the sink. */ + void (*destroy) (struct case_sink *); + + /* Closes the sink and returns a source that can read back + the cases that were written, perhaps transformed in some + way. The sink must still be separately destroyed by + calling destroy(). */ + struct case_source *(*make_source) (struct case_sink *); + }; +extern const struct case_sink_class storage_sink_class; +extern const struct case_sink_class null_sink_class; + +struct case_sink *create_case_sink (const struct case_sink_class *, + const struct dictionary *, + void *); +void case_sink_open (struct case_sink *); +void case_sink_write (struct case_sink *, const struct ccase *); +void case_sink_destroy (struct case_sink *); +void free_case_sink (struct case_sink *); + /* Number of cases to lag. */ extern int n_lag; -void procedure (void (*beginfunc) (void *aux), - int (*procfunc) (struct ccase *curcase, void *aux), - void (*endfunc) (void *aux), - void *aux); +void procedure (int (*proc_func) (struct ccase *, void *aux), void *aux); +void procedure_with_splits (void (*begin_func) (void *aux), + int (*proc_func) (struct ccase *, void *aux), + void (*end_func) (void *aux), + void *aux); struct ccase *lagged_case (int n_before); -void compact_case (struct ccase *dest, const struct ccase *src); -void page_to_disk (void); - -void process_active_file (void (*beginfunc) (void *), - int (*casefunc) (struct ccase *curcase, void *), - void (*endfunc) (void *), - void *aux); -void process_active_file_output_case (void); + +void multipass_procedure_with_splits (void (*) (const struct casefile *, + void *), + void *aux); + +time_t vfm_last_invocation (void); #endif /* !vfm_h */