it works!!
[pspp] / src / data / dataset.h
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 1997-9, 2000, 2006, 2007, 2009, 2010, 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 PROCEDURE_H
18 #define PROCEDURE_H 1
19
20 #include <time.h>
21 #include <stdbool.h>
22
23 #include "data/transformations.h"
24
25 struct casereader;
26 struct casereader_translator_class;
27 struct dataset;
28 struct dictionary;
29 struct session;
30 struct transformation;
31 \f
32 struct dataset *dataset_create (struct session *, const char *);
33 struct dataset *dataset_clone (struct dataset *, const char *);
34 void dataset_destroy (struct dataset *);
35
36 void dataset_clear (struct dataset *);
37
38 const char *dataset_name (const struct dataset *);
39 void dataset_set_name (struct dataset *, const char *);
40
41 struct session *dataset_session (const struct dataset *);
42 void dataset_set_session (struct dataset *, struct session *);
43
44 struct dictionary *dataset_dict (const struct dataset *);
45 void dataset_set_dict (struct dataset *, struct dictionary *);
46
47 const struct casereader *dataset_source (const struct dataset *);
48 bool dataset_has_source (const struct dataset *ds);
49 bool dataset_set_source (struct dataset *, struct casereader *);
50 struct casereader *dataset_steal_source (struct dataset *);
51
52 unsigned int dataset_seqno (const struct dataset *);
53
54 struct dataset_callbacks
55   {
56     /* Called whenever a procedure completes execution or whenever the
57        dictionary within the dataset is modified (though not when it is
58        replaced by a new dictionary). */
59     void (*changed) (void *aux);
60
61     /* Called whenever a transformation is added or removed.  NON_EMPTY is true
62        if after the change there is at least one transformation, false if there
63        are no transformations. */
64     void (*transformations_changed) (bool non_empty, void *aux);
65   };
66
67 void dataset_set_callbacks (struct dataset *, const struct dataset_callbacks *,
68                             void *aux);
69
70 /* Dataset GUI window display status. */
71 enum dataset_display
72   {
73     DATASET_ASIS,               /* Current state unchanged. */
74     DATASET_FRONT,              /* Display and raise to top. */
75     DATASET_MINIMIZED,          /* Display as icon. */
76     DATASET_HIDDEN              /* Do not display. */
77   };
78 enum dataset_display dataset_get_display (const struct dataset *);
79 void dataset_set_display (struct dataset *, enum dataset_display);
80 \f
81 /* Transformations. */
82
83 void add_transformation (struct dataset *ds, const struct trns_class *, void *);
84
85 bool proc_cancel_all_transformations (struct dataset *ds);
86 void proc_push_transformations (struct dataset *);
87 void proc_pop_transformations (struct dataset *, struct trns_chain *);
88 bool proc_has_transformations (const struct dataset *);
89
90 void proc_start_temporary_transformations (struct dataset *ds);
91 bool proc_in_temporary_transformations (const struct dataset *ds);
92 bool proc_make_temporary_transformations_permanent (struct dataset *ds);
93 bool proc_cancel_temporary_transformations (struct dataset *ds);
94 struct variable *add_permanent_ordering_transformation (struct dataset *);
95
96 bool dataset_transform_source (struct dataset *,
97                                const struct casereader_translator_class *,
98                                void *aux);
99 bool dataset_delete_vars (struct dataset *, struct variable **, size_t n);
100 \f
101 /* Procedures. */
102
103 void proc_discard_output (struct dataset *ds);
104
105 bool proc_execute (struct dataset *ds);
106 time_t time_of_last_procedure (struct dataset *ds);
107
108 struct casereader *proc_open_filtering (struct dataset *, bool filter);
109 struct casereader *proc_open (struct dataset *);
110 bool proc_is_open (const struct dataset *);
111 bool proc_commit (struct dataset *);
112
113 bool dataset_end_of_command (struct dataset *);
114 \f
115 struct measure_guesser *measure_guesser_create (struct dataset *);
116 void measure_guesser_run (struct measure_guesser *, const struct casereader *);
117 void measure_guesser_destroy (struct measure_guesser *);
118 \f
119 const struct ccase *lagged_case (const struct dataset *ds, int n_before);
120 void dataset_need_lag (struct dataset *ds, int n_before);
121 \f
122 /* Private interface for use by session code. */
123
124 void dataset_set_session__(struct dataset *, struct session *);
125
126 #endif /* dataset.h */