1 /*
2  * Copyright (C) 2009 - 2011 Vivien Malerba <malerba@gnome-db.org>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library 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 GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA  02110-1301, USA.
18  */
19 
20 #ifndef __GDA_TREE_H__
21 #define __GDA_TREE_H__
22 
23 #include <glib-object.h>
24 #include <stdio.h>
25 #include "gda-decl.h"
26 
27 G_BEGIN_DECLS
28 
29 #define GDA_TYPE_TREE            (gda_tree_get_type())
30 #define GDA_TREE(obj)            (G_TYPE_CHECK_INSTANCE_CAST (obj, GDA_TYPE_TREE, GdaTree))
31 #define GDA_TREE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST (klass, GDA_TYPE_TREE, GdaTreeClass))
32 #define GDA_IS_TREE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE(obj, GDA_TYPE_TREE))
33 #define GDA_IS_TREE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GDA_TYPE_TREE))
34 #define GDA_TREE_GET_CLASS(o)	 (G_TYPE_INSTANCE_GET_CLASS ((o), GDA_TYPE_TREE, GdaTreeClass))
35 
36 /* error reporting */
37 extern GQuark gda_tree_error_quark (void);
38 #define GDA_TREE_ERROR gda_tree_error_quark ()
39 
40 typedef enum {
41 	GDA_TREE_UNKNOWN_ERROR
42 } GdaTreeError;
43 
44 struct _GdaTree {
45 	GObject           object;
46 	GdaTreePrivate   *priv;
47 };
48 
49 struct _GdaTreeClass {
50 	GObjectClass      object_class;
51 
52 	/* signals */
53 	void         (* node_changed)           (GdaTree *tree, GdaTreeNode *node);
54 	void         (* node_inserted)          (GdaTree *tree, GdaTreeNode *node);
55 	void         (* node_has_child_toggled) (GdaTree *tree, GdaTreeNode *node);
56 	void         (* node_deleted)           (GdaTree *tree, const gchar *node_path);
57 
58 	/*< private >*/
59 	/* Padding for future expansion */
60 	void (*_gda_reserved1) (void);
61 	void (*_gda_reserved2) (void);
62 	void (*_gda_reserved3) (void);
63 	void (*_gda_reserved4) (void);
64 };
65 
66 /**
67  * SECTION:gda-tree
68  * @short_description: A tree-structure
69  * @title: GdaTree
70  * @stability: Stable
71  * @see_also:
72  *
73  * The #GdaTree is the top level object representing hierarchically structured data. From this object it
74  * is also possible (depending on the tree managers it uses), to clean (remove all the nodes) the whole tree,
75  * or to request a complete or partial update of the nodes.
76  *
77  * It is also possible to set attributes to the tree itself (as it is possible to do for tree nodes),
78  * or to dump the whole or part of a tree in an indented and easy to read fashion.
79  */
80 
81 GType              gda_tree_get_type      (void) G_GNUC_CONST;
82 GdaTree*           gda_tree_new           (void);
83 void               gda_tree_add_manager   (GdaTree *tree, GdaTreeManager *manager);
84 
85 void               gda_tree_clean         (GdaTree *tree);
86 gboolean           gda_tree_update_all    (GdaTree *tree, GError **error);
87 gboolean           gda_tree_update_part   (GdaTree *tree, GdaTreeNode *node, GError **error);
88 gboolean           gda_tree_update_children (GdaTree *tree, GdaTreeNode *node, GError **error);
89 
90 GSList            *gda_tree_get_nodes_in_path (GdaTree *tree, const gchar *tree_path, gboolean use_names);
91 GdaTreeNode       *gda_tree_get_node      (GdaTree *tree, const gchar *tree_path, gboolean use_names);
92 gchar             *gda_tree_get_node_path (GdaTree *tree, GdaTreeNode *node);
93 GdaTreeManager    *gda_tree_get_node_manager (GdaTree *tree, GdaTreeNode *node);
94 
95 void               gda_tree_set_attribute (GdaTree *tree, const gchar *attribute, const GValue *value,
96 					   GDestroyNotify destroy);
97 
98 void               gda_tree_dump          (GdaTree *tree, GdaTreeNode *node, FILE *stream);
99 
100 G_END_DECLS
101 
102 #endif
103