1 /*
2  * go-data-impl.h :
3  *
4  * Copyright (C) 2003-2004 Jody Goldberg (jody@gnome.org)
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of the
9  * License, or (at your option) version 3.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
19  * USA
20  */
21 #ifndef GO_DATA_IMPL_H
22 #define GO_DATA_IMPL_H
23 
24 #include <goffice/data/goffice-data.h>
25 #include <goffice/data/go-data.h>
26 #include <goffice/utils/go-format.h>
27 #include <glib-object.h>
28 
29 G_BEGIN_DECLS
30 
31 typedef enum {
32 	GO_DATA_CACHE_IS_VALID =	1 << 0,
33 	GO_DATA_IS_EDITABLE =		1 << 1,
34 	GO_DATA_SIZE_CACHED =		1 << 2,
35 	GO_DATA_HAS_VALUE = 1 << 3
36 } GODataFlags;
37 
38 struct _GOData {
39 	GObject		base;
40 	gint32		flags; /* dunno what to do with these yet */
41 };
42 
43 typedef struct {
44 	GObjectClass base;
45 
46 	GOData *	(*dup)	    		(GOData const *src);
47 	gboolean 	(*eq)	    		(GOData const *a, GOData const *b);
48 	GOFormat *	(*preferred_fmt) 	(GOData const *dat);
49 	GODateConventions const *(*date_conv) 	(GOData const *dat);
50 
51 	char *		(*serialize)	    	(GOData const *dat, gpointer user);
52 	gboolean   	(*unserialize)	    	(GOData *dat, char const *str, gpointer user);
53 	void	   	(*emit_changed)  	(GOData *dat);
54 
55 	unsigned int	(*get_n_dimensions)	(GOData *data);
56 	void		(*get_sizes)		(GOData *data, unsigned int *sizes);
57 	double *	(*get_values)		(GOData *data);
58 	void		(*get_bounds)		(GOData *data, double *minimum, double *maximum);
59 	double		(*get_value)		(GOData *data, unsigned int *coordinates);
60 	char *		(*get_string)		(GOData *data, unsigned int *coordinates);
61 	PangoAttrList * (*get_markup)		(GOData *data, unsigned int *coordinates);
62 	gboolean	(*is_valid)		(GOData const *data);
63 
64 	/* signals */
65 	void (*changed)	(GOData *dat);
66 } GODataClass;
67 
68 struct _GODataScalar {
69 	GOData base;
70 
71 	double value;
72 };
73 
74 typedef struct {
75 	GODataClass base;
76 	double       (*get_value)  (GODataScalar *scalar);
77 	char const  *(*get_str)	   (GODataScalar *scalar);
78 	PangoAttrList const *(*get_markup) (GODataScalar *data);
79 } GODataScalarClass;
80 
81 #define GO_DATA_VECTOR_LEN_CACHED GO_DATA_SIZE_CACHED
82 
83 struct _GODataVector {
84 	GOData base;
85 
86 	int len;	/* negative if dirty, includes missing values */
87 	double *values;	/* NULL = inititialized/unsupported, nan = missing */
88 	double minimum, maximum;
89 };
90 typedef struct {
91 	GODataClass base;
92 
93 	void	 (*load_len)    (GODataVector *vec);
94 	void	 (*load_values) (GODataVector *vec);
95 	double	 (*get_value)   (GODataVector *vec, unsigned i);
96 	char	*(*get_str)	(GODataVector *vec, unsigned i);
97 	PangoAttrList *(*get_markup) (GODataVector *data, unsigned i);
98 } GODataVectorClass;
99 
100 #define	GO_DATA_MATRIX_SIZE_CACHED GO_DATA_SIZE_CACHED
101 
102 struct _GODataMatrix {
103 	GOData base;
104 
105 	GODataMatrixSize size;	/* negative if dirty, includes missing values */
106 	double *values;	/* NULL = uninitialized/unsupported, nan = missing */
107 	double minimum, maximum;
108 };
109 
110 typedef struct {
111 	GODataClass base;
112 
113 	void	 (*load_size)    (GODataMatrix *vec);
114 	void	 (*load_values) (GODataMatrix *vec);
115 	double	 (*get_value)   (GODataMatrix *mat, unsigned i, unsigned j);
116 	char	*(*get_str)	(GODataMatrix *mat, unsigned i, unsigned j);
117 	PangoAttrList *(*get_markup) (GODataMatrix *mat, unsigned i, unsigned j);
118 } GODataMatrixClass;
119 
120 G_END_DECLS
121 
122 #endif /* GO_DATA_IMPL_H */
123