Update all #include directives to the currently preferred style.
[pspp-builds.git] / src / output / chart-item.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_CHART_ITEM_H
18 #define OUTPUT_CHART_ITEM_H 1
19
20 /* Chart items.
21
22    A chart item is a subclass of an output item (see output/output-item.h).
23
24    A chart item is abstract.  Every actual chart is a subclass of
25    chart_item. */
26
27 #include <stdbool.h>
28 #include "output/output-item.h"
29
30 /* A chart item.
31
32    The members of struct chart_item should not be accessed directly.  Use one
33    of the accessor functions defined below. */
34 struct chart_item
35   {
36     struct output_item output_item; /* Superclass */
37     const struct chart_item_class *class; /* Subclass. */
38     char *title;                /* May be null if there is no title. */
39   };
40
41 const char *chart_item_get_title (const struct chart_item *);
42 void chart_item_set_title (struct chart_item *, const char *);
43 \f
44 /* This boilerplate for chart_item, a subclass of output_item, was
45    autogenerated by mk-class-boilerplate. */
46
47 #include <assert.h>
48 #include "libpspp/cast.h"
49
50 extern const struct output_item_class chart_item_class;
51
52 /* Returns true if SUPER is a chart_item, otherwise false. */
53 static inline bool
54 is_chart_item (const struct output_item *super)
55 {
56   return super->class == &chart_item_class;
57 }
58
59 /* Returns SUPER converted to chart_item.  SUPER must be a chart_item, as
60    reported by is_chart_item. */
61 static inline struct chart_item *
62 to_chart_item (const struct output_item *super)
63 {
64   assert (is_chart_item (super));
65   return UP_CAST (super, struct chart_item, output_item);
66 }
67
68 /* Returns INSTANCE converted to output_item. */
69 static inline struct output_item *
70 chart_item_super (const struct chart_item *instance)
71 {
72   return CONST_CAST (struct output_item *, &instance->output_item);
73 }
74
75 /* Increments INSTANCE's reference count and returns INSTANCE. */
76 static inline struct chart_item *
77 chart_item_ref (const struct chart_item *instance)
78 {
79   return to_chart_item (output_item_ref (&instance->output_item));
80 }
81
82 /* Decrements INSTANCE's reference count, then destroys INSTANCE if
83    the reference count is now zero. */
84 static inline void
85 chart_item_unref (struct chart_item *instance)
86 {
87   output_item_unref (&instance->output_item);
88 }
89
90 /* Returns true if INSTANCE's reference count is greater than 1,
91    false otherwise. */
92 static inline bool
93 chart_item_is_shared (const struct chart_item *instance)
94 {
95   return output_item_is_shared (&instance->output_item);
96 }
97
98 void chart_item_submit (struct chart_item *);
99 \f
100 #endif /* output/chart-item.h */