output-item: Add 'name' member to class structure.
[pspp] / src / output / group-item.c
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 2018 Free Sonftware 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 #include <config.h>
18
19 #include "output/group-item.h"
20
21 #include <stdlib.h>
22
23 #include "output/driver.h"
24 #include "output/output-item-provider.h"
25
26 #include "gl/xalloc.h"
27
28 struct group_open_item *
29 group_open_item_create (const char *command_name)
30 {
31   struct group_open_item *item;
32
33   item = xmalloc (sizeof *item);
34   output_item_init (&item->output_item, &group_open_item_class);
35   item->command_name = command_name ? xstrdup (command_name) : NULL;
36
37   return item;
38 }
39
40 /* Submits ITEM to the configured output drivers, and transfers ownership to
41    the output subsystem. */
42 void
43 group_open_item_submit (struct group_open_item *item)
44 {
45   output_submit (&item->output_item);
46 }
47
48 static void
49 group_open_item_destroy (struct output_item *output_item)
50 {
51   struct group_open_item *item = to_group_open_item (output_item);
52
53   free (item->command_name);
54   free (item);
55 }
56
57 const struct output_item_class group_open_item_class =
58   {
59     "group_open",
60     group_open_item_destroy,
61   };
62 \f
63 struct group_close_item *
64 group_close_item_create (void)
65 {
66   struct group_close_item *item;
67
68   item = xmalloc (sizeof *item);
69   output_item_init (&item->output_item, &group_close_item_class);
70
71   return item;
72 }
73
74 /* Submits ITEM to the configured output drivers, and transfers ownership to
75    the output subsystem. */
76 void
77 group_close_item_submit (struct group_close_item *item)
78 {
79   output_submit (&item->output_item);
80 }
81
82 static void
83 group_close_item_destroy (struct output_item *output_item)
84 {
85   struct group_close_item *item = to_group_close_item (output_item);
86
87   free (item);
88 }
89
90 const struct output_item_class group_close_item_class =
91   {
92     "group_close",
93     group_close_item_destroy,
94   };