connection.h
Go to the documentation of this file.00001
00002
00003 #ifndef _LIBGDAMM_CONNECTION_H
00004 #define _LIBGDAMM_CONNECTION_H
00005
00006 #include <glibmm.h>
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include <libgdamm/transaction.h>
00031 #include <libgdamm/error.h>
00032 #include <libgdamm/command.h>
00033 #include <libgdamm/datamodel.h>
00034 #include <libgdamm/parameterlist.h>
00035 #include <libgda/gda-connection.h>
00036
00037
00038 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00039 typedef struct _GdaConnection GdaConnection;
00040 typedef struct _GdaConnectionClass GdaConnectionClass;
00041 #endif
00042
00043
00044 namespace Gnome
00045 {
00046
00047 namespace Gda
00048 { class Connection_Class; }
00049
00050 }
00051 namespace Gnome
00052 {
00053
00054 namespace Gda
00055 {
00056
00057 class Client;
00058
00064 enum ConnectionFeature
00065 {
00066 CONNECTION_FEATURE_AGGREGATES,
00067 CONNECTION_FEATURE_INDEXES,
00068 CONNECTION_FEATURE_INHERITANCE,
00069 CONNECTION_FEATURE_NAMESPACES,
00070 CONNECTION_FEATURE_PROCEDURES,
00071 CONNECTION_FEATURE_SEQUENCES,
00072 CONNECTION_FEATURE_SQL,
00073 CONNECTION_FEATURE_TRANSACTIONS,
00074 CONNECTION_FEATURE_TRIGGERS,
00075 CONNECTION_FEATURE_USERS,
00076 CONNECTION_FEATURE_VIEWS,
00077 CONNECTION_FEATURE_XML_QUERIES,
00078 CONNECTION_FEATURE_BLOBS
00079 };
00080
00081 }
00082
00083 }
00084
00085
00086 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00087 namespace Glib
00088 {
00089
00090 template <>
00091 class Value<Gnome::Gda::ConnectionFeature> : public Glib::Value_Enum<Gnome::Gda::ConnectionFeature>
00092 {
00093 public:
00094 static GType value_type() G_GNUC_CONST;
00095 };
00096
00097 }
00098 #endif
00099
00100
00101 namespace Gnome
00102 {
00103
00104 namespace Gda
00105 {
00106
00110 enum ConnectionSchema
00111 {
00112 CONNECTION_SCHEMA_AGGREGATES,
00113 CONNECTION_SCHEMA_DATABASES,
00114 CONNECTION_SCHEMA_FIELDS,
00115 CONNECTION_SCHEMA_INDEXES,
00116 CONNECTION_SCHEMA_LANGUAGES,
00117 CONNECTION_SCHEMA_NAMESPACES,
00118 CONNECTION_SCHEMA_PARENT_TABLES,
00119 CONNECTION_SCHEMA_PROCEDURES,
00120 CONNECTION_SCHEMA_SEQUENCES,
00121 CONNECTION_SCHEMA_TABLES,
00122 CONNECTION_SCHEMA_TRIGGERS,
00123 CONNECTION_SCHEMA_TYPES,
00124 CONNECTION_SCHEMA_USERS,
00125 CONNECTION_SCHEMA_VIEWS
00126 };
00127
00128 }
00129
00130 }
00131
00132
00133 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00134 namespace Glib
00135 {
00136
00137 template <>
00138 class Value<Gnome::Gda::ConnectionSchema> : public Glib::Value_Enum<Gnome::Gda::ConnectionSchema>
00139 {
00140 public:
00141 static GType value_type() G_GNUC_CONST;
00142 };
00143
00144 }
00145 #endif
00146
00147
00148 namespace Gnome
00149 {
00150
00151 namespace Gda
00152 {
00153
00165 enum ConnectionOptions
00166 {
00167 CONNECTION_OPTIONS_READ_ONLY = 1 << 0
00168 };
00169
00171 inline ConnectionOptions operator|(ConnectionOptions lhs, ConnectionOptions rhs)
00172 { return static_cast<ConnectionOptions>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); }
00173
00175 inline ConnectionOptions operator&(ConnectionOptions lhs, ConnectionOptions rhs)
00176 { return static_cast<ConnectionOptions>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs)); }
00177
00179 inline ConnectionOptions operator^(ConnectionOptions lhs, ConnectionOptions rhs)
00180 { return static_cast<ConnectionOptions>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs)); }
00181
00183 inline ConnectionOptions operator~(ConnectionOptions flags)
00184 { return static_cast<ConnectionOptions>(~static_cast<unsigned>(flags)); }
00185
00187 inline ConnectionOptions& operator|=(ConnectionOptions& lhs, ConnectionOptions rhs)
00188 { return (lhs = static_cast<ConnectionOptions>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs))); }
00189
00191 inline ConnectionOptions& operator&=(ConnectionOptions& lhs, ConnectionOptions rhs)
00192 { return (lhs = static_cast<ConnectionOptions>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs))); }
00193
00195 inline ConnectionOptions& operator^=(ConnectionOptions& lhs, ConnectionOptions rhs)
00196 { return (lhs = static_cast<ConnectionOptions>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs))); }
00197
00198 }
00199
00200 }
00201
00202
00203 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00204 namespace Glib
00205 {
00206
00207 template <>
00208 class Value<Gnome::Gda::ConnectionOptions> : public Glib::Value_Flags<Gnome::Gda::ConnectionOptions>
00209 {
00210 public:
00211 static GType value_type() G_GNUC_CONST;
00212 };
00213
00214 }
00215 #endif
00216
00217
00218 namespace Gnome
00219 {
00220
00221 namespace Gda
00222 {
00223
00224
00225 class Connection : public Glib::Object
00226 {
00227
00228 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00229
00230 public:
00231 typedef Connection CppObjectType;
00232 typedef Connection_Class CppClassType;
00233 typedef GdaConnection BaseObjectType;
00234 typedef GdaConnectionClass BaseClassType;
00235
00236 private: friend class Connection_Class;
00237 static CppClassType connection_class_;
00238
00239 private:
00240
00241 Connection(const Connection&);
00242 Connection& operator=(const Connection&);
00243
00244 protected:
00245 explicit Connection(const Glib::ConstructParams& construct_params);
00246 explicit Connection(GdaConnection* castitem);
00247
00248 #endif
00249
00250 public:
00251 virtual ~Connection();
00252
00253 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00254 static GType get_type() G_GNUC_CONST;
00255 static GType get_base_type() G_GNUC_CONST;
00256 #endif
00257
00259 GdaConnection* gobj() { return reinterpret_cast<GdaConnection*>(gobject_); }
00260
00262 const GdaConnection* gobj() const { return reinterpret_cast<GdaConnection*>(gobject_); }
00263
00265 GdaConnection* gobj_copy();
00266
00267 private:
00268
00269 protected:
00270
00271 Connection();
00272
00273
00274 public:
00275
00276 static Glib::RefPtr<Connection> create();
00277
00278
00279 bool close();
00280
00281
00282 bool is_open() const;
00283
00284
00285 Glib::RefPtr<Client> get_client();
00286
00287 Glib::RefPtr<const Client> get_client() const;
00288
00289
00290 void set_client(const Glib::RefPtr<Client>& client);
00291
00292
00293 ConnectionOptions get_options() const;
00294
00295 Glib::ustring get_server_version() const;
00296
00297
00298 Glib::ustring get_database() const;
00299
00300 Glib::ustring get_dsn() const;
00301
00302 Glib::ustring get_cnc_string() const;
00303
00304 Glib::ustring get_provider() const;
00305
00306 Glib::ustring get_username() const;
00307
00308 Glib::ustring get_password() const;
00309
00310
00311 void add_error(const Glib::RefPtr<Error>& error);
00312
00313 void add_error(const Glib::ustring& error);
00314
00315
00316 void add_error_list(GList *error_list);
00317
00318
00319 bool change_database(const Glib::ustring& name);
00320
00321 bool create_database(const Glib::ustring& name);
00322
00323 bool drop_database(const Glib::ustring& name);
00324
00325
00326
00327
00328
00329
00330 Glib::ListHandle< Glib::RefPtr<DataModel> > execute_command(const Command& cmd, const ParameterList& params);
00331 Glib::ListHandle< Glib::RefPtr<DataModel> > execute_command(const Command& cmd);
00332
00333
00334 Glib::RefPtr<DataModel> execute_single_command(const Command& cmd, const ParameterList& params);
00335 Glib::RefPtr<DataModel> execute_single_command(const Command& cmd);
00336 Glib::RefPtr<DataModel> execute_single_command(const Glib::ustring& cmd);
00337
00338
00339 int execute_non_query(const Command& cmd, const ParameterList& params);
00340 int execute_non_query(const Command& cmd);
00341
00342
00343 bool begin_transaction(const Glib::RefPtr<Transaction>& transaction);
00344
00345 bool commit_transaction(const Glib::RefPtr<Transaction>& transaction);
00346
00347 bool rollback_transaction(const Glib::RefPtr<Transaction>& transaction);
00348
00349
00350
00351
00352 Glib::ListHandle< Glib::RefPtr<Error> > get_errors();
00353
00354 Glib::ListHandle< Glib::RefPtr<const Error> > get_errors() const;
00355
00356
00357
00358 bool create_blob(GdaBlob* blob);
00359
00360
00361 bool supports(ConnectionFeature feature) const;
00362
00363
00364 Glib::RefPtr<DataModel> get_schema(ConnectionSchema schema, const ParameterList& params);
00365
00366 Glib::RefPtr<const DataModel> get_schema(ConnectionSchema schema, const ParameterList& params) const;
00367
00368 Glib::RefPtr<DataModel> get_schema(ConnectionSchema schema);
00369 Glib::RefPtr<const DataModel> get_schema(ConnectionSchema schema) const;
00370
00371
00372 Glib::ustring get_last_insert_id(const Glib::RefPtr<DataModel>& recset) const;
00373
00374
00375 Glib::SignalProxy1< void,GList* > signal_error();
00376
00377
00378 public:
00379
00380 public:
00381
00382
00383 protected:
00384
00385
00386
00387 virtual void on_error(GList* error_list);
00388
00389
00390 };
00391
00392 }
00393 }
00394
00395
00396 namespace Glib
00397 {
00403 Glib::RefPtr<Gnome::Gda::Connection> wrap(GdaConnection* object, bool take_copy = false);
00404 }
00405
00406
00407 #endif
00408