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