e6e707d3d47a2aa33311b443d6a46e9f15472cf8
[pspp-builds.git] / src / data / procedure.h
1 /* PSPP - computes sample statistics.
2    Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
3    Written by Ben Pfaff <blp@gnu.org>.
4
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.
9
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.
14
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., 51 Franklin Street, Fifth Floor, Boston, MA
18    02110-1301, USA. */
19
20 #ifndef PROCEDURE_H
21 #define PROCEDURE_H 1
22
23 #include <time.h>
24 #include <stdbool.h>
25
26 #include <data/transformations.h>
27 #include <libpspp/compiler.h>
28
29 struct ccase;
30 struct casefile;
31 struct case_sink;
32 struct case_source;
33
34 struct dataset;
35
36 \f
37 /* Transformations. */
38
39 void add_transformation (struct dataset *ds, 
40                          trns_proc_func *, trns_free_func *, void *);
41 void add_transformation_with_finalizer (struct dataset *ds, 
42                                         trns_finalize_func *,
43                                         trns_proc_func *,
44                                         trns_free_func *, void *);
45 size_t next_transformation (const struct dataset *ds);
46
47 void discard_variables (struct dataset *ds);
48
49
50
51 bool proc_cancel_all_transformations (struct dataset *ds);
52 struct trns_chain *proc_capture_transformations (struct dataset *ds);
53
54 void proc_start_temporary_transformations (struct dataset *ds);
55 bool proc_in_temporary_transformations (const struct dataset *ds);
56 bool proc_make_temporary_transformations_permanent (struct dataset *ds);
57 bool proc_cancel_temporary_transformations (struct dataset *ds);
58 \f
59 /* Procedures. */
60
61
62 struct dataset *create_dataset (void);
63 void destroy_dataset (struct dataset *);
64
65 void proc_set_source (struct dataset *ds, struct case_source *);
66 bool proc_has_source (const struct dataset *ds);
67
68 void proc_set_sink (struct dataset *ds, struct case_sink *);
69 struct casefile *proc_capture_output (struct dataset *ds);
70
71 typedef bool casefile_func (const struct casefile *, void *);
72 typedef bool case_func (const struct ccase *, void *, const struct dataset *);
73 typedef void begin_func (const struct ccase *, void *, const struct dataset*);
74
75 typedef bool end_func (void *, const struct dataset *);
76
77 typedef bool split_func (const struct ccase *, const struct casefile *,
78                               void *, const struct dataset *);
79
80
81
82 bool procedure (struct dataset *ds, case_func *, void *aux)  WARN_UNUSED_RESULT;
83
84 bool procedure_with_splits (struct dataset *ds, 
85                             begin_func *,
86                             case_func *,
87                             end_func *,
88                             void *aux)
89      WARN_UNUSED_RESULT;
90 bool multipass_procedure (struct dataset *ds, casefile_func *, void  *aux)
91      WARN_UNUSED_RESULT;
92 bool multipass_procedure_with_splits (struct dataset *ds,
93                                            split_func *,
94                                            void *aux)
95      WARN_UNUSED_RESULT;
96
97
98
99 time_t time_of_last_procedure (struct dataset *ds);
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 */