1 /*
2  * Copyright (C) 2007 - 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_VCONNECTION_HUB_H__
21 #define __GDA_VCONNECTION_HUB_H__
22 
23 #include <virtual/gda-vconnection-data-model.h>
24 
25 #define GDA_TYPE_VCONNECTION_HUB            (gda_vconnection_hub_get_type())
26 #define GDA_VCONNECTION_HUB(obj)            (G_TYPE_CHECK_INSTANCE_CAST (obj, GDA_TYPE_VCONNECTION_HUB, GdaVconnectionHub))
27 #define GDA_VCONNECTION_HUB_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST (klass, GDA_TYPE_VCONNECTION_HUB, GdaVconnectionHubClass))
28 #define GDA_IS_VCONNECTION_HUB(obj)         (G_TYPE_CHECK_INSTANCE_TYPE (obj, GDA_TYPE_VCONNECTION_HUB))
29 #define GDA_IS_VCONNECTION_HUB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDA_TYPE_VCONNECTION_HUB))
30 
31 G_BEGIN_DECLS
32 
33 typedef struct _GdaVconnectionHub      GdaVconnectionHub;
34 typedef struct _GdaVconnectionHubClass GdaVconnectionHubClass;
35 typedef struct _GdaVconnectionHubPrivate GdaVconnectionHubPrivate;
36 
37 typedef void (*GdaVConnectionHubFunc) (GdaConnection *cnc, const gchar *ns, gpointer data);
38 
39 struct _GdaVconnectionHub {
40 	GdaVconnectionDataModel      parent;
41 	GdaVconnectionHubPrivate    *priv;
42 };
43 
44 struct _GdaVconnectionHubClass {
45 	GdaVconnectionDataModelClass parent_class;
46 
47 	/*< private >*/
48 	/* Padding for future expansion */
49 	void (*_gda_reserved1) (void);
50 	void (*_gda_reserved2) (void);
51 	void (*_gda_reserved3) (void);
52 	void (*_gda_reserved4) (void);
53 };
54 
55 /**
56  * SECTION:gda-vconnection-hub
57  * @short_description: Virtual connection which bind together connections
58  * @title: GdaVconnectionHub
59  * @stability: Stable
60  * @see_also:
61  *
62  * The #GdaVconnectionHub object "binds" together the tables from other (opened) connections to make it possible to run
63  * SQL queries on data from several connections at once.
64  *
65  * A #GdaVconnectionHub connection can bind several other connections, each separated in its own namespace (which is specified
66  * when adding a connection using gda_vconnection_hub_add()).
67  *
68  * For example if a connection A has two tables 'table_1' and 'table_2', then after gda_vconnection_hub_add() has been called
69  * with A as connection argument and with a "c1" namespace, then in the corresponding #GdaVconnectionHub connection, table
70  * 'table_1' must be referred to as 'c1.table_1' and 'table_2' must be referred to as 'c1.table_2'.
71  */
72 
73 GType               gda_vconnection_hub_get_type       (void) G_GNUC_CONST;
74 
75 gboolean            gda_vconnection_hub_add            (GdaVconnectionHub *hub,
76 							GdaConnection *cnc, const gchar *ns, GError **error);
77 gboolean            gda_vconnection_hub_remove         (GdaVconnectionHub *hub, GdaConnection *cnc, GError **error);
78 GdaConnection      *gda_vconnection_hub_get_connection (GdaVconnectionHub *hub, const gchar *ns);
79 void                gda_vconnection_hub_foreach        (GdaVconnectionHub *hub,
80 							GdaVConnectionHubFunc func, gpointer data);
81 
82 G_END_DECLS
83 
84 #endif
85