Update all #include directives to the currently preferred style.
[pspp-builds.git] / src / output / charts / roc-chart.h
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 2009, 2011 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 OUTPUT_CHARTS_ROC_CHART_H
18 #define OUTPUT_CHARTS_ROC_CHART_H 1
19
20 #include <stdbool.h>
21 #include <stddef.h>
22 #include "output/chart-item.h"
23
24 struct roc_chart
25   {
26     struct chart_item chart_item;
27     bool reference;
28     struct roc_var *vars;
29     size_t n_vars;
30     size_t allocated_vars;
31   };
32
33 struct roc_var
34   {
35     char *name;
36     struct casereader *cutpoint_reader;
37   };
38
39 struct roc_chart *roc_chart_create (bool reference);
40 void roc_chart_add_var (struct roc_chart *, const char *var_name,
41                         const struct casereader *cutpoint_reader);
42 \f
43 /* This boilerplate for roc_chart, a subclass of chart_item, was
44    autogenerated by mk-class-boilerplate. */
45
46 #include <assert.h>
47 #include "libpspp/cast.h"
48
49 extern const struct chart_item_class roc_chart_class;
50
51 /* Returns true if SUPER is a roc_chart, otherwise false. */
52 static inline bool
53 is_roc_chart (const struct chart_item *super)
54 {
55   return super->class == &roc_chart_class;
56 }
57
58 /* Returns SUPER converted to roc_chart.  SUPER must be a roc_chart, as
59    reported by is_roc_chart. */
60 static inline struct roc_chart *
61 to_roc_chart (const struct chart_item *super)
62 {
63   assert (is_roc_chart (super));
64   return UP_CAST (super, struct roc_chart, chart_item);
65 }
66
67 /* Returns INSTANCE converted to chart_item. */
68 static inline struct chart_item *
69 roc_chart_super (const struct roc_chart *instance)
70 {
71   return CONST_CAST (struct chart_item *, &instance->chart_item);
72 }
73
74 /* Increments INSTANCE's reference count and returns INSTANCE. */
75 static inline struct roc_chart *
76 roc_chart_ref (const struct roc_chart *instance)
77 {
78   return to_roc_chart (chart_item_ref (&instance->chart_item));
79 }
80
81 /* Decrements INSTANCE's reference count, then destroys INSTANCE if
82    the reference count is now zero. */
83 static inline void
84 roc_chart_unref (struct roc_chart *instance)
85 {
86   chart_item_unref (&instance->chart_item);
87 }
88
89 /* Returns true if INSTANCE's reference count is greater than 1,
90    false otherwise. */
91 static inline bool
92 roc_chart_is_shared (const struct roc_chart *instance)
93 {
94   return chart_item_is_shared (&instance->chart_item);
95 }
96
97 static inline void
98 roc_chart_submit (struct roc_chart *instance)
99 {
100   chart_item_submit (&instance->chart_item);
101 }
102 \f
103 #endif /* output/charts/roc-chart.h */