3b501df90b8cb96b1675e508fae662de5eba5c85
[pspp-builds.git] / src / data / procedure.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 PROCEDURE_H
20 #define PROCEDURE_H 1
21
22 #include <time.h>
23 #include <stdbool.h>
24
25 #include <data/transformations.h>
26 #include <libpspp/compiler.h>
27
28 struct ccase;
29 struct casefile;
30 struct case_sink;
31 struct case_source;
32
33 struct dataset;
34
35 \f
36 /* Transformations. */
37
38 void add_transformation (struct dataset *ds, 
39                          trns_proc_func *, trns_free_func *, void *);
40 void add_transformation_with_finalizer (struct dataset *ds, 
41                                         trns_finalize_func *,
42                                         trns_proc_func *,
43                                         trns_free_func *, void *);
44 size_t next_transformation (const struct dataset *ds);
45
46 void discard_variables (struct dataset *ds);
47
48
49
50 bool proc_cancel_all_transformations (struct dataset *ds);
51 struct trns_chain *proc_capture_transformations (struct dataset *ds);
52
53 void proc_start_temporary_transformations (struct dataset *ds);
54 bool proc_in_temporary_transformations (const struct dataset *ds);
55 bool proc_make_temporary_transformations_permanent (struct dataset *ds);
56 bool proc_cancel_temporary_transformations (struct dataset *ds);
57 \f
58 /* Procedures. */
59
60 struct dataset * create_dataset (void);
61 void destroy_dataset (struct dataset *);
62
63 void proc_set_source (struct dataset *ds, struct case_source *);
64 bool proc_has_source (const struct dataset *ds);
65
66 void proc_set_sink (struct dataset *ds, struct case_sink *);
67 struct casefile *proc_capture_output (struct dataset *ds);
68
69 typedef bool casefile_func (const struct casefile *, void *);
70 typedef bool case_func (const struct ccase *, void *, const struct dataset *);
71 typedef void begin_func (const struct ccase *, void *, const struct dataset*);
72
73 typedef bool end_func (void *, const struct dataset *);
74
75 typedef bool split_func (const struct ccase *, const struct casefile *,
76                               void *, const struct dataset *);
77
78
79
80 bool procedure (struct dataset *ds, case_func *, void *aux)  WARN_UNUSED_RESULT;
81
82 bool procedure_with_splits (struct dataset *ds, 
83                             begin_func *,
84                             case_func *,
85                             end_func *,
86                             void *aux)
87      WARN_UNUSED_RESULT;
88 bool multipass_procedure (struct dataset *ds, casefile_func *, void  *aux)
89      WARN_UNUSED_RESULT;
90 bool multipass_procedure_with_splits (struct dataset *ds,
91                                            split_func *,
92                                            void *aux)
93      WARN_UNUSED_RESULT;
94
95 time_t time_of_last_procedure (struct dataset *ds);
96
97 void proc_open (struct dataset *);
98 bool proc_read (struct dataset *, struct ccase **);
99 bool proc_close (struct dataset *);
100 \f
101
102 struct ccase *lagged_case (const struct dataset *ds, int n_before);
103
104 inline struct dictionary *dataset_dict (const struct dataset *ds);
105 inline void dataset_set_dict ( struct dataset *ds, struct dictionary *dict);
106
107 inline int dataset_n_lag (const struct dataset *ds);
108 inline void dataset_set_n_lag (struct dataset *ds, int n_lag);
109
110
111 #endif /* procedure.h */