1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2009 Free Software Foundation, Inc.
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.
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.
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/>. */
17 #ifndef OUTPUT_TABLE_ITEM_H
18 #define OUTPUT_TABLE_ITEM_H 1
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
26 #include <libpspp/compiler.h>
27 #include <output/output-item.h>
31 The members of struct table_item should not be accessed directly. Use one
32 of the accessor functions defined below. */
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. */
40 struct table_item *table_item_create (struct table *, const char *caption);
42 const struct table *table_item_get_table (const struct table_item *);
44 const char *table_item_get_caption (const struct table_item *);
45 void table_item_set_caption (struct table_item *, const char *);
47 /* This boilerplate for table_item, a subclass of output_item, was
48 autogenerated by mk-class-boilerplate. */
51 #include <libpspp/cast.h>
53 extern const struct output_item_class table_item_class;
55 /* Returns true if SUPER is a table_item, otherwise false. */
57 is_table_item (const struct output_item *super)
59 return super->class == &table_item_class;
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)
67 assert (is_table_item (super));
68 return UP_CAST (super, struct table_item, output_item);
71 /* Returns INSTANCE converted to output_item. */
72 static inline struct output_item *
73 table_item_super (const struct table_item *instance)
75 return CONST_CAST (struct output_item *, &instance->output_item);
78 /* Increments INSTANCE's reference count and returns INSTANCE. */
79 static inline struct table_item *
80 table_item_ref (const struct table_item *instance)
82 return to_table_item (output_item_ref (&instance->output_item));
85 /* Decrements INSTANCE's reference count, then destroys INSTANCE if
86 the reference count is now zero. */
88 table_item_unref (struct table_item *instance)
90 output_item_unref (&instance->output_item);
93 /* Returns true if INSTANCE's reference count is greater than 1,
96 table_item_is_shared (const struct table_item *instance)
98 return output_item_is_shared (&instance->output_item);
101 void table_item_submit (struct table_item *);
103 #endif /* output/table-item.h */