66ddb4e0fb63a4688f05b7f70e78d5000b0a5040
[pspp] / src / data / transformations.h
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 1997-9, 2000, 2006, 2009, 2011, 2013 Free Software Foundation, Inc.
3
4    This program is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation, either version 3 of the License, or
7    (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU 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, see <http://www.gnu.org/licenses/>. */
16
17 #ifndef TRANSFORMATIONS_H
18 #define TRANSFORMATIONS_H 1
19
20 #include <limits.h>
21 #include <stdbool.h>
22 #include <stddef.h>
23 #include "data/case.h"
24
25 /* trns_proc_func return values. */
26 enum trns_result
27   {
28     TRNS_CONTINUE = INT_MIN,    /* Continue to next transformation. */
29     TRNS_DROP_CASE,             /* Drop this case. */
30     TRNS_ERROR,                 /* A serious error, so stop the procedure. */
31     TRNS_END_CASE,              /* Skip to next case.  INPUT PROGRAM only. */
32     TRNS_END_FILE               /* End of input.  INPUT PROGRAM only. */
33   };
34
35 struct ccase;
36 typedef int trns_proc_func (void *, struct ccase **, casenumber);
37 typedef bool trns_free_func (void *);
38 typedef struct pxd_object *trns_save_func (void *, struct pxd *);
39 typedef void *trns_load_func (struct pxd_object *, const struct pxd *);
40
41 #if 0
42 struct trns_class
43   {
44     int (*execute) (struct trns_class *, struct ccase **, casenumber);
45     bool (*destroy) (struct ccase *);
46   };
47 #endif
48 \f
49 /* Transformation chains. */
50
51 struct trns_chain *trns_chain_create (void);
52 void trns_chain_finalize (struct trns_chain *);
53 bool trns_chain_destroy (struct trns_chain *);
54
55 bool trns_chain_is_empty (const struct trns_chain *);
56
57 void trns_chain_append (struct trns_chain *,
58                         trns_proc_func *, trns_free_func *, void *);
59 size_t trns_chain_next (struct trns_chain *);
60 enum trns_result trns_chain_execute (const struct trns_chain *,
61                                      enum trns_result, struct ccase **,
62                                      casenumber case_nr);
63
64 void trns_chain_splice (struct trns_chain *, struct trns_chain *);
65
66 #endif /* transformations.h */