1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2004, 2009, 2011 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/>. */
19 #include "output/chart-item.h"
20 #include "output/chart-item-provider.h"
25 #include "libpspp/cast.h"
26 #include "libpspp/compiler.h"
27 #include "output/driver.h"
28 #include "output/output-item-provider.h"
30 #include "gl/xalloc.h"
32 /* Initializes ITEM as a chart item of the specified CLASS. The new chart item
33 initially has the specified TITLE, which may be NULL if no title is yet
34 available. The caller retains ownership of TITLE.
36 A chart item is an abstract class, that is, a plain chart_item is not useful
37 on its own. Thus, this function is normally called from the initialization
38 function of some subclass of chart_item. */
40 chart_item_init (struct chart_item *item, const struct chart_item_class *class,
43 output_item_init (&item->output_item, &chart_item_class);
45 item->title = title != NULL ? xstrdup (title) : NULL;
48 /* Returns ITEM's title, which is a null pointer if no title has been set. */
50 chart_item_get_title (const struct chart_item *item)
55 /* Sets ITEM's title to TITLE, replacing any previous title. Specify NULL for
56 TITLE to clear any title from ITEM. The caller retains ownership of
59 This function may only be used on a chart_item that is unshared. */
61 chart_item_set_title (struct chart_item *item, const char *title)
63 assert (!chart_item_is_shared (item));
65 item->title = title != NULL ? xstrdup (title) : NULL;
68 /* Submits ITEM to the configured output drivers, and transfers ownership to
69 the output subsystem. */
71 chart_item_submit (struct chart_item *item)
73 output_submit (&item->output_item);
77 chart_item_destroy (struct output_item *output_item)
79 struct chart_item *item = to_chart_item (output_item);
80 char *title = item->title;
81 item->class->destroy (item);
85 const struct output_item_class chart_item_class =