1 /*
2  * Copyright (C) 2009 - 2011 Vivien Malerba <malerba@gnome-db.org>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (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, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18 
19 
20 #ifndef __BROWSER_VIRTUAL_CONNECTION_H_
21 #define __BROWSER_VIRTUAL_CONNECTION_H_
22 
23 #include <gtk/gtk.h>
24 #include "browser-connection.h"
25 
26 G_BEGIN_DECLS
27 
28 #define BROWSER_TYPE_VIRTUAL_CONNECTION          (browser_virtual_connection_get_type())
29 #define BROWSER_VIRTUAL_CONNECTION(obj)          G_TYPE_CHECK_INSTANCE_CAST (obj, browser_virtual_connection_get_type(), BrowserVirtualConnection)
30 #define BROWSER_VIRTUAL_CONNECTION_CLASS(klass)  G_TYPE_CHECK_CLASS_CAST (klass, browser_virtual_connection_get_type (), BrowserVirtualConnectionClass)
31 #define BROWSER_IS_VIRTUAL_CONNECTION(obj)       G_TYPE_CHECK_INSTANCE_TYPE (obj, browser_virtual_connection_get_type ())
32 
33 typedef struct _BrowserVirtualConnection BrowserVirtualConnection;
34 typedef struct _BrowserVirtualConnectionPrivate BrowserVirtualConnectionPrivate;
35 typedef struct _BrowserVirtualConnectionClass BrowserVirtualConnectionClass;
36 
37 /* struct for the object's data */
38 struct _BrowserVirtualConnection
39 {
40 	BrowserConnection                object;
41 	BrowserVirtualConnectionPrivate *priv;
42 };
43 
44 /* struct for the object's class */
45 struct _BrowserVirtualConnectionClass
46 {
47 	BrowserConnectionClass           parent_class;
48 };
49 
50 /* parts types */
51 typedef enum {
52 	BROWSER_VIRTUAL_CONNECTION_PART_MODEL,
53 	BROWSER_VIRTUAL_CONNECTION_PART_CNC,
54 } BrowserVirtualConnectionType;
55 
56 /* part: a table from a GdaDataModel */
57 typedef struct {
58 	gchar *table_name;
59 	GdaDataModel *model;
60 } BrowserVirtualConnectionModel;
61 
62 /* part: tables from a BrowserConnection */
63 typedef struct {
64 	gchar *table_schema;
65 	BrowserConnection *source_cnc;
66 } BrowserVirtualConnectionCnc;
67 
68 /* generic part */
69 typedef struct {
70 	BrowserVirtualConnectionType part_type;
71 	union {
72 		BrowserVirtualConnectionModel model;
73 		BrowserVirtualConnectionCnc   cnc;
74 	} u;
75 } BrowserVirtualConnectionPart;
76 BrowserVirtualConnectionPart *browser_virtual_connection_part_copy (const BrowserVirtualConnectionPart *part);
77 void                          browser_virtual_connection_part_free (BrowserVirtualConnectionPart *part);
78 
79 /* specs */
80 typedef struct {
81 	GSList *parts;
82 } BrowserVirtualConnectionSpecs;
83 BrowserVirtualConnectionSpecs *browser_virtual_connection_specs_copy (const BrowserVirtualConnectionSpecs *specs);
84 void                           browser_virtual_connection_specs_free (BrowserVirtualConnectionSpecs *specs);
85 
86 GType              browser_virtual_connection_get_type               (void) G_GNUC_CONST;
87 BrowserConnection *browser_virtual_connection_new                    (const BrowserVirtualConnectionSpecs *specs,
88 								      GError **error);
89 gboolean           browser_virtual_connection_modify_specs           (BrowserVirtualConnection *bcnc,
90 								      const BrowserVirtualConnectionSpecs *new_specs,
91 								      GError **error);
92 G_END_DECLS
93 
94 #endif
95