output-item: Collapse the inheritance hierarchy into a single struct.
[pspp] / src / output / charts / piechart.h
index 312a45ee08ce759f84e9c02e2991ca9acd3163f0..2602c71c32d670496c5a6daed0ec710f1b41ea54 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2004, 2009 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2009, 2011 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 #ifndef PIECHART_H
 #define PIECHART_H
 
-#include <libpspp/str.h>
-#include <output/chart-item.h>
+#include "libpspp/str.h"
+#include "output/chart.h"
+#include "language/stats/freq.h"
 
 struct piechart
   {
-    struct chart_item chart_item;
+    struct chart chart;
     struct slice *slices;
     int n_slices;
   };
@@ -33,20 +34,22 @@ struct slice
     double magnitude;
   };
 
-struct chart_item *piechart_create (const char *title,
-                                    const struct slice *, int n_slices);
+struct variable;
+
+struct chart *piechart_create (const struct variable *var,
+                                    const struct freq *, int n_slices);
 \f
-/* This boilerplate for piechart, a subclass of chart_item, was
+/* This boilerplate for piechart, a subclass of chart, was
    autogenerated by mk-class-boilerplate. */
 
 #include <assert.h>
-#include <libpspp/cast.h>
+#include "libpspp/cast.h"
 
-extern const struct chart_item_class piechart_class;
+extern const struct chart_class piechart_class;
 
 /* Returns true if SUPER is a piechart, otherwise false. */
 static inline bool
-is_piechart (const struct chart_item *super)
+is_piechart (const struct chart *super)
 {
   return super->class == &piechart_class;
 }
@@ -54,24 +57,24 @@ is_piechart (const struct chart_item *super)
 /* Returns SUPER converted to piechart.  SUPER must be a piechart, as
    reported by is_piechart. */
 static inline struct piechart *
-to_piechart (const struct chart_item *super)
+to_piechart (const struct chart *super)
 {
   assert (is_piechart (super));
-  return UP_CAST (super, struct piechart, chart_item);
+  return UP_CAST (super, struct piechart, chart);
 }
 
-/* Returns INSTANCE converted to chart_item. */
-static inline struct chart_item *
+/* Returns INSTANCE converted to chart. */
+static inline struct chart *
 piechart_super (const struct piechart *instance)
 {
-  return CONST_CAST (struct chart_item *, &instance->chart_item);
+  return CONST_CAST (struct chart *, &instance->chart);
 }
 
 /* Increments INSTANCE's reference count and returns INSTANCE. */
 static inline struct piechart *
 piechart_ref (const struct piechart *instance)
 {
-  return to_piechart (chart_item_ref (&instance->chart_item));
+  return to_piechart (chart_ref (&instance->chart));
 }
 
 /* Decrements INSTANCE's reference count, then destroys INSTANCE if
@@ -79,7 +82,7 @@ piechart_ref (const struct piechart *instance)
 static inline void
 piechart_unref (struct piechart *instance)
 {
-  chart_item_unref (&instance->chart_item);
+  chart_unref (&instance->chart);
 }
 
 /* Returns true if INSTANCE's reference count is greater than 1,
@@ -87,13 +90,13 @@ piechart_unref (struct piechart *instance)
 static inline bool
 piechart_is_shared (const struct piechart *instance)
 {
-  return chart_item_is_shared (&instance->chart_item);
+  return chart_is_shared (&instance->chart);
 }
 
 static inline void
 piechart_submit (struct piechart *instance)
 {
-  chart_item_submit (&instance->chart_item);
+  chart_submit (&instance->chart);
 }
 \f
 #endif /* output/charts/piechart.h */