3
<TITLE>Source: toconnection.h</TITLE>
5
<META NAME="Generator" CONTENT="KDOC ">
7
<BODY bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#000099" alink= "#ffffff">
8
<TABLE WIDTH="100%" BORDER="0">
12
<TR><TD valign="top" align="left" cellspacing="10">
13
<h1>Source: toconnection.h</h1>
15
<TD valign="top" align="right" colspan="1"></TD></TR>
22
<TD align="right"><TABLE BORDER="0"><TR><TD><small><A HREF="index-long.html">Annotated List</A></small></TD></TR>
23
<TR><TD><small><A HREF="header-list.html">Files</A></small></TD></TR>
24
<TR><TD><small><A HREF="all-globals.html">Globals</A></small></TD></TR>
25
<TR><TD><small><A HREF="hier.html">Hierarchy</A></small></TD></TR>
26
<TR><TD><small><A HREF="index.html">Index</A></small></TD></TR>
27
</TABLE></TD></TR></TABLE>
31
* TOra - An Oracle Toolkit for DBA's and developers
32
* Copyright (C) 2003-2005 Quest Software, Inc
33
* Portions Copyright (C) 2005 Other Contributors
35
* This program is free software; you can redistribute it and/or
36
* modify it under the terms of the GNU General Public License
37
* as published by the Free Software Foundation; only version 2 of
38
* the License is valid for this program.
40
* This program is distributed in the hope that it will be useful,
41
* but WITHOUT ANY WARRANTY; without even the implied warranty of
42
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43
* GNU General Public License for more details.
45
* You should have received a copy of the GNU General Public License
46
* along with this program; if not, write to the Free Software
47
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
49
* As a special exception, you have permission to link this program
50
* with the Oracle Client libraries and distribute executables, as long
51
* as you follow the requirements of the GNU GPL in regard to all of the
52
* software in the executable aside from Oracle client libraries.
54
* Specifically you are not permitted to link this program with the
55
* Qt/UNIX, Qt/Windows or Qt Non Commercial products of TrollTech.
56
* And you are not permitted to distribute binaries compiled against
57
* these libraries without written consent from Quest Software, Inc.
58
* Observe that this does not disallow linking to the Qt Free Edition.
60
* You may link this product with any GPL'd Qt library such as Qt/Free
62
* All trademarks belong to their respective owners.
66
#ifndef TOCONNECTION_H
67
#define TOCONNECTION_H
80
class toConnectionProvider;
83
class toSyntaxAnalyzer;
85
/** This class is an abstract definition of an actual connection to a database.
86
* Each @ref toConnection object can have one or more actual connections to the
87
* database depending on long running queries. Normally you will never need to
88
* bother with this class if you aren't creating a new database provider
89
* (@ref toConnectionProvider).
92
class toConnectionSub {
95
/** Create connection to database.
101
virtual ~toConnectionSub()
103
/** Query current running on connection or NULL.
107
/** Set query currently running on connection. NULL means none.
109
void setQuery(toQuery *query)
111
/** Cancel anything running on this sub.
113
virtual void cancel(void)
117
/** This class is used to perform a query on a database connection.
122
/** Represent different modes to run a query in.
125
/** Run the query normally on the main connection of the @ref toConnection object.
128
/** Run the query normally on the main backgrround connection of the
129
* @ref toConnection object. This can be the same as the main connection depending
133
/** Run the query in a separate connection for long running queries.
136
/** Run the query on all non occupied connections of the @ref toConnection object.
141
/** This structure is used to describe the resultset of a query.
144
struct queryDescribe {
148
/** Datatype of string.
151
/** If column can contain null values.
154
/** Preferred alignment of this kind of value.
157
/** Comment on column (Only filled out in column cache.
161
/** Abstract parent of implementations of a query for a database provider
162
* (See @ref toConnection::connectionImpl and @ref toConnectionProvider)
167
/** Get the parent query object. All the parameters of the query must be read from here.
168
* nothing is passed to the functions.
173
/** Create a query implementation. The constructor must not perform any actions with the
174
* database that could block for a noticable time (Like execute or parse a query). The
175
* data for the query may not be available when this object created.
176
* @param query Parent query object.
178
queryImpl(toQuery *query)
181
/** Destroy query implementation.
185
/** Execute a query. Parameters can be gotten from the @ref toQuery object.
187
virtual void execute(void) = 0;
188
/** Read the next value from the stream.
189
* @return The value read from the query.
191
virtual toQValue readValue(void) = 0;
192
/** Check if the end of the query has been reached.
193
* @return True if all values have been read.
195
virtual bool eof(void) = 0;
196
/** Get the number of rows processed in the last executed query.
198
virtual int rowsProcessed(void) = 0;
199
/** Describe the currently running query.
200
* @return A list of column descriptions of the query.
202
virtual std::list<queryDescribe> describe(void) = 0;
203
/** Get number of columns in the resultset.
204
* @return Column number.
206
virtual int columns(void) = 0;
207
/** Cancel the current execution of a query. This will usually be called from another
208
* thread than is executing the query.
210
virtual void cancel(void) = 0;
214
toConnection &Connection;
215
toConnectionSub *ConnectionSub;
216
std::list<toQValue> Params;
221
toQuery(const toQuery &);
223
/** Create a normal query.
224
* @param conn Connection to create query on.
225
* @param sql SQL to run.
226
* @param params Parameters to pass to query.
228
toQuery(toConnection &conn,const toSQL &sql,const std::list<toQValue> ¶ms);
229
/** Create a normal query.
230
* @param conn Connection to create query on.
231
* @param sql SQL to run.
232
* @param params Parameters to pass to query.
234
toQuery(toConnection &conn,const QString &sql,const std::list<toQValue> ¶ms);
235
/** Create a normal query.
236
* @param conn Connection to create query on.
237
* @param sql SQL to run.
238
* @param arg1 Arguments to pass to query.
240
toQuery(toConnection &conn,const toSQL &sql,
241
const QString &arg1=QString::null,const QString &arg2=QString::null,
242
const QString &arg3=QString::null,const QString &arg4=QString::null,
243
const QString &arg5=QString::null,const QString &arg6=QString::null,
244
const QString &arg7=QString::null,const QString &arg8=QString::null,
245
const QString &arg9=QString::null);
246
/** Create a normal query.
247
* @param conn Connection to create query on.
248
* @param sql SQL to run.
249
* @param arg1 Arguments to pass to query.
251
toQuery(toConnection &conn,const QString &sql,
252
const QString &arg1=QString::null,const QString &arg2=QString::null,
253
const QString &arg3=QString::null,const QString &arg4=QString::null,
254
const QString &arg5=QString::null,const QString &arg6=QString::null,
255
const QString &arg7=QString::null,const QString &arg8=QString::null,
256
const QString &arg9=QString::null);
259
* @param conn Connection to create query on.
260
* @param mode Mode to run query in.
261
* @param sql SQL to run.
262
* @param params Arguments to pass to query.
264
toQuery(toConnection &conn,queryMode mode,const toSQL &sql,const std::list<toQValue> ¶ms);
266
* @param conn Connection to create query on.
267
* @param mode Mode to run query in.
268
* @param sql SQL to run.
269
* @param params Arguments to pass to query.
271
toQuery(toConnection &conn,queryMode mode,const QString &sql,const std::list<toQValue> ¶ms);
272
/** Create a query. Don't runn any SQL using it yet. Observe though that the @ref
273
* toConnectionSub object is assigned here so you know that all queries run using this
274
* query object will run on the same actual connection to the database (Unless mode is All off
276
* @param conn Connection to create query for.
277
* @param mode Mode to execute queries in.
279
toQuery(toConnection &conn,queryMode mode=Normal);
284
/** Execute an SQL statement using this query.
285
* @param sql SQL to run.
286
* @param params Parameters to pass to query.
288
void execute(const toSQL &sql,const std::list<toQValue> ¶ms);
289
/** Execute an SQL statement using this query.
290
* @param sql SQL to run.
291
* @param params Parameters to pass to query.
293
void execute(const QString &sql,const std::list<toQValue> ¶ms);
295
/** Connection object of this object.
297
toConnection &connection(void)
298
{ return Connection; }
299
/** Actual database connection that this query is currently using.
301
toConnectionSub *connectionSub(void)
302
{ return ConnectionSub; }
303
/** Parameters of the current query.
305
std::list<toQValue> ¶ms(void)
307
/** SQL to run. Observe that this string is in UTF8 format.
311
/** Get the mode this query is executed in.
313
toQuery::queryMode mode(void) const
316
/** Read a value from the query. Convert the value NULL to the string {null}.
317
* @return Value read.
319
toQValue readValue(void);
320
/** Read a value from the query. Nulls are returned as empty @ref toQValue.
321
* @return Value read.
323
toQValue readValueNull(void);
324
/** Check if end of query is reached.
325
* @return True if end of query is reached.
329
/** Get the number of rows processed by the query.
331
int rowsProcessed(void)
332
{ return Query->rowsProcessed(); }
333
/** Get a list of descriptions for the columns. This function is relatively slow.
335
std::list<queryDescribe> describe(void)
336
{ return Query->describe(); }
337
/** Get the number of columns in the resultset of the query.
340
{ return Query->columns(); }
342
/** Execute a query and return all the values returned by it.
343
* @param conn Connection to run query on.
344
* @param sql SQL to run.
345
* @param params Parameters to pass to query.
346
* @return A list of @ref toQValues:s read from the query.
348
static std::list<toQValue> readQuery(toConnection &conn,
350
std::list<toQValue> ¶ms);
351
/** Execute a query and return all the values returned by it.
352
* @param conn Connection to run query on.
353
* @param sql SQL to run.
354
* @param params Parameters to pass to query.
355
* @return A list of @ref toQValues:s read from the query.
357
static std::list<toQValue> readQuery(toConnection &conn,
359
std::list<toQValue> ¶ms);
360
/** Execute a query and return all the values returned by it.
361
* @param conn Connection to run query on.
362
* @param sql SQL to run.
363
* @param arg1 Parameters to pass to query.
364
* @return A list of @ref toQValues:s read from the query.
366
static std::list<toQValue> readQuery(toConnection &conn,const toSQL &sql,
367
const QString &arg1=QString::null,const QString &arg2=QString::null,
368
const QString &arg3=QString::null,const QString &arg4=QString::null,
369
const QString &arg5=QString::null,const QString &arg6=QString::null,
370
const QString &arg7=QString::null,const QString &arg8=QString::null,
371
const QString &arg9=QString::null);
372
/** Execute a query and return all the values returned by it.
373
* @param conn Connection to run query on.
374
* @param sql SQL to run.
375
* @param arg1 Parameters to pass to query.
376
* @return A list of @ref toQValues:s read from the query.
378
static std::list<toQValue> readQuery(toConnection &conn,const QString &sql,
379
const QString &arg1=QString::null,const QString &arg2=QString::null,
380
const QString &arg3=QString::null,const QString &arg4=QString::null,
381
const QString &arg5=QString::null,const QString &arg6=QString::null,
382
const QString &arg7=QString::null,const QString &arg8=QString::null,
383
const QString &arg9=QString::null);
384
/** Execute a query and return all the values returned by it.
385
* @param conn Connection to run query on.
386
* @param sql SQL to run.
387
* @param params Parameters to pass to query.
388
* @return A list of @ref toQValues:s read from the query.
390
static std::list<toQValue> readQueryNull(toConnection &conn,
392
std::list<toQValue> ¶ms);
393
/** Execute a query and return all the values returned by it.
394
* @param conn Connection to run query on.
395
* @param sql SQL to run.
396
* @param params Parameters to pass to query.
397
* @return A list of @ref toQValues:s read from the query.
399
static std::list<toQValue> readQueryNull(toConnection &conn,
401
std::list<toQValue> ¶ms);
402
/** Execute a query and return all the values returned by it.
403
* @param conn Connection to run query on.
404
* @param sql SQL to run.
405
* @param arg1 Parameters to pass to query.
406
* @return A list of @ref toQValues:s read from the query.
408
static std::list<toQValue> readQueryNull(toConnection &conn,const toSQL &sql,
409
const QString &arg1=QString::null,const QString &arg2=QString::null,
410
const QString &arg3=QString::null,const QString &arg4=QString::null,
411
const QString &arg5=QString::null,const QString &arg6=QString::null,
412
const QString &arg7=QString::null,const QString &arg8=QString::null,
413
const QString &arg9=QString::null);
414
/** Execute a query and return all the values returned by it.
415
* @param conn Connection to run query on.
416
* @param sql SQL to run.
417
* @param arg1 Parameters to pass to query.
418
* @return A list of @ref toQValues:s read from the query.
420
static std::list<toQValue> readQueryNull(toConnection &conn,const QString &sql,
421
const QString &arg1=QString::null,const QString &arg2=QString::null,
422
const QString &arg3=QString::null,const QString &arg4=QString::null,
423
const QString &arg5=QString::null,const QString &arg6=QString::null,
424
const QString &arg7=QString::null,const QString &arg8=QString::null,
425
const QString &arg9=QString::null);
426
/** Cancel the current execution of a query.
431
/** A short representation of a @ref toQuery::queryDescribe
433
typedef toQuery::queryDescribe toQDescribe;
434
/** A short representation of list<toQuery::queryDescribe>
436
typedef std::list<toQDescribe> toQDescList;
438
/** Represent a database connection in TOra. Observe that this can mean several actual
439
* connections to the database as queries that ae expected to run a long time are sometimes
440
* executed in their own connection to make sure the interface doesn't lock up for a long time.
449
std::list<QObject *> Widgets;
450
std::list<QString> InitStrings;
451
std::set<QString> Options;
453
std::list<toConnectionSub *> Connections;
454
std::list<toConnectionSub *> Running;
456
toConnectionSub *BackgroundConnection;
461
/** Class that could be used to throw exceptions in connection errors. Must use if you
462
* want to indicate error offset.
465
class exception : public QString {
468
/** Create an exception with a string description.
470
exception(const QString &str,int offset=-1)
473
/** Get the offset of the error of the current statement.
475
int offset(void) const
477
/** Set the offset of the error of the error.
479
void setOffset(int offset)
483
/** Contain information about a tablename.
489
/** The schema that owns it
495
/** Comment about this object
498
/** synonyms (used for faster disk caching...)
500
std::list <QString> Synonyms;
502
/** Create an object name with filled in values.
504
objectName(const QString &owner,const QString &name,const QString &type=QString("TABLE"),const QString &comment=QString::null)
505
: Name(name),Owner(owner),Type(type),Comment(comment)
508
/** Create an empty object name.
512
bool operator < (const objectName &) const;
513
bool operator == (const objectName &) const;
516
/** This class is an abstract baseclass to actually implement the comunication with the
518
* (See also @ref toQuery::queryImpl and @ref toConnectionProvider)
520
class connectionImpl {
521
toConnection *Connection;
523
/** Get the parent connection object of this connection.
525
toConnection &connection(void)
526
{ return *Connection; }
527
/** Create a new connection implementation for a connection.
528
* @param conn Connection to implement.
530
connectionImpl(toConnection *conn)
531
{ Connection=conn; };
534
virtual ~connectionImpl()
537
/** Commit the supplied actual database connection.
539
virtual void commit(toConnectionSub *) = 0;
540
/** Rollback the supplied actual database connection.
542
virtual void rollback(toConnectionSub *) = 0;
544
/** If not true can never run more than one query per connection sub and TOra will
545
* work around this limitation by opening more connections if needed.
547
virtual bool handleMultipleQueries()
550
/** Create a new connection to the database.
552
virtual toConnectionSub *createConnection(void) = 0;
553
/** Close a connection to the database.
555
virtual void closeConnection(toConnectionSub *) = 0;
557
/** Get the version of the database connected to.
559
virtual QCString version(toConnectionSub *) = 0;
561
/** Return a string representation to address an object.
562
* @param name The name to be quoted.
563
* @return String addressing table.
565
virtual QString quote(const QString &name)
567
/** Perform the opposite of @ref quote.
568
* @param name The name to be un-quoted.
569
* @return String addressing table.
571
virtual QString unQuote(const QString &name)
575
* Get syntax analyzer for connection
576
* @return A reference to the syntax analyzer to use for the connection.
578
virtual toSyntaxAnalyzer &analyzer();
580
/** Extract available objects to query for connection. Any access to the
581
* database should always be run using a long running query. If something
582
* goes wrong should throw exception.
583
* @return List of available objects.
585
virtual std::list<objectName> objectNames(void);
586
/** Get synonyms available for connection. Any access to the
587
* database should always be run using a long running query. If something
588
* goes wrong should throw exception.
589
* @param objects Available objects for the connection. Objects
590
* are sorted in owner and name order. Don't modify
592
* @return Map of synonyms to objectnames.
594
virtual std::map<QString,objectName> synonymMap(std::list<objectName> &objects);
595
/* Extract available columns to query for a table.
596
* @param table Table to get column for.
597
* @return List of columns for table or view.
599
virtual toQDescList columnDesc(const objectName &table);
601
/** Create a new query implementation for this connection.
602
* @return A query implementation, allocated with new.
604
virtual toQuery::queryImpl *createQuery(toQuery *query,toConnectionSub *conn) = 0;
605
/** Execute a query on an actual connection without caring about the result.
606
* @param conn Connection to execute on.
607
* @param sql SQL to execute.
608
* @param params Parameters to pass to query.
610
virtual void execute(toConnectionSub *conn,const QCString &sql,toQList ¶ms) = 0;
611
/** Parse a query on an actual connection and report any syntax problems encountered.
612
* Defaults to not implemented.
613
* @param conn Connection to execute on.
614
* @param sql SQL to parse
616
virtual void parse(toConnectionSub *conn,const QCString &sql);
621
void addConnection(void);
622
std::list<toConnectionSub *> &connections(void)
623
{ return Connections; }
625
connectionImpl *Connection;
627
class cacheObjects : public toTask {
628
toConnection &Connection;
630
cacheObjects(toConnection &conn)
633
virtual void run(void);
635
friend class cacheObjects;
638
toSemaphore ReadingValues;
640
std::map<objectName,toQDescList> ColumnCache;
641
std::list<objectName> ObjectNames;
642
std::map<QString,objectName> SynonymMap;
644
toConnectionSub *mainConnection(void);
645
toConnectionSub *longConnection(void);
646
toConnectionSub *backgroundConnection(void);
647
void freeConnection(toConnectionSub *);
648
void readObjects(void);
652
/** Create a new connection.
653
* @param provider Which database provider to use for this connection.
654
* (See @ref to toDatabaseConnection)
655
* @param user User to connect to the database with.
656
* @param password Password to connect with.
657
* @param host Host to connect to the database with.
658
* @param database Database to connect to.
659
* @param options Options used to connect to the database with.
660
* @param cache Enable object cache for this connection.
662
toConnection(const QCString &provider,const QString &user,const QString &password,
663
const QString &host,const QString &database,const std::set<QString> &options,
665
/** Create a copy of a connection. Will not cache objects, so objects will never be available
666
* in a subconnection.
667
* @param conn Connection to copy.
669
toConnection(const toConnection &conn);
670
/** Destroy connection.
672
virtual ~toConnection();
674
//* Get the options for the connection.
675
const std::set<QString> &options() const
677
/** Try to close all the widgets associated with this connection.
678
* @return True if all widgets agreed to close.
680
bool closeWidgets(void);
681
/** Get username of connection.
683
const QString &user() const
685
/** Get password of connection.
687
const QString &password() const
689
/** Change password of connection.
691
void setPassword(const QString &pwd)
693
/** Get host of connection.
695
const QString &host() const
697
/** Get database of connection.
699
const QString &database() const
701
/** Get version of connection.
703
const QCString &version() const
705
/** Get provider of connection.
707
const QCString &provider() const;
709
/** Change the current database. Observe that this only changes the record of what is the current database. You will still need
710
* to change the database oppinion on what database is the current one.
712
void setDatabase(const QString &database)
713
{ Database=database; }
715
/** Get a description of this connection.
716
* @version Include version in returned string.
718
virtual QString description(bool version=true) const;
720
/** Set if this connection needs to be commited.
722
void setNeedCommit(bool needCommit=true)
723
{ NeedCommit=needCommit; }
725
* Get information about if the connection has uncommited data.
727
* @return Whether uncommited data is available.
729
bool needCommit(void) const
730
{ return NeedCommit; }
732
* Commit connection. This will also close all extra connections except one.
734
virtual void commit(void);
736
* Rollback connection. This will also close all extra connections except one.
738
virtual void rollback(void);
740
/** Parse a query on an actual connection and report any syntax problems encountered.
741
* Defaults to not implemented.
742
* @param conn Connection to execute on.
743
* @param sql SQL to parse
745
void parse(const QString &sql);
746
/** Parse a query on an actual connection and report any syntax problems encountered.
747
* Defaults to not implemented.
748
* @param conn Connection to execute on.
749
* @param sql SQL to parse
751
void parse(const toSQL &sql);
753
/** Execute a statement without caring about the result.
754
* @param sql SQL to execute
755
* @param params Parameters to pass to query.
757
void execute(const toSQL &sql,
759
/** Execute a statement without caring about the result.
760
* @param sql SQL to execute
761
* @param params Parameters to pass to query.
763
void execute(const QString &sql,
765
/** Execute a statement without caring about the result.
766
* @param sql SQL to execute
767
* @param arg1 Parameters to pass to query.
769
void execute(const toSQL &sql,
770
const QString &arg1=QString::null,const QString &arg2=QString::null,
771
const QString &arg3=QString::null,const QString &arg4=QString::null,
772
const QString &arg5=QString::null,const QString &arg6=QString::null,
773
const QString &arg7=QString::null,const QString &arg8=QString::null,
774
const QString &arg9=QString::null);
775
/** Execute a statement without caring about the result.
776
* @param sql SQL to execute
777
* @param arg1 Parameters to pass to query.
779
void execute(const QString &sql,
780
const QString &arg1=QString::null,const QString &arg2=QString::null,
781
const QString &arg3=QString::null,const QString &arg4=QString::null,
782
const QString &arg5=QString::null,const QString &arg6=QString::null,
783
const QString &arg7=QString::null,const QString &arg8=QString::null,
784
const QString &arg9=QString::null);
786
/** Execute a statement without caring about the result on all open database connections.
787
* @param sql SQL to execute
788
* @param params Parameters to pass to query.
790
void allExecute(const toSQL &sql,
792
/** Execute a statement without caring about the result on all open database connections.
793
* @param sql SQL to execute
794
* @param params Parameters to pass to query.
796
void allExecute(const QString &sql,
798
/** Execute a statement without caring about the result on all open database connections.
799
* @param sql SQL to execute
800
* @param arg1 Parameters to pass to query.
802
void allExecute(const toSQL &sql,
803
const QString &arg1=QString::null,const QString &arg2=QString::null,
804
const QString &arg3=QString::null,const QString &arg4=QString::null,
805
const QString &arg5=QString::null,const QString &arg6=QString::null,
806
const QString &arg7=QString::null,const QString &arg8=QString::null,
807
const QString &arg9=QString::null);
808
/** Execute a statement without caring about the result on all open database connections.
809
* @param sql SQL to execute
810
* @param arg1 Parameters to pass to query.
812
void allExecute(const QString &sql,
813
const QString &arg1=QString::null,const QString &arg2=QString::null,
814
const QString &arg3=QString::null,const QString &arg4=QString::null,
815
const QString &arg5=QString::null,const QString &arg6=QString::null,
816
const QString &arg7=QString::null,const QString &arg8=QString::null,
817
const QString &arg9=QString::null);
820
* Add a object that uses this connection. This is needed to ensure that all widgets
821
* that make use of a connection are destroyed when the connection is closed. Usually
822
* tool windows need to call this function.
824
* @param widget The widget to add to the connection.
826
void addWidget(QObject *widget)
827
{ Widgets.insert(Widgets.end(),widget); }
829
* Remove a widget from this connection. Should be called by the destructor of the
830
* widget that has called addWidget.
833
* @param widget Widget to remove from the widget list.
835
void delWidget(QObject *widget);
838
* Add a statement to be run uppon making new connections.
839
* @param sql Statement to run.
841
void addInit(const QString &sql);
843
* Remove a statement that was added using @ref addInit.
845
void delInit(const QString &sql);
847
* Get a list of the current init strings.
849
const std::list<QString> &toConnection::initStrings() const;
851
/** Return a string representation to address an object.
852
* @param name The name to be quoted.
853
* @return String addressing table.
855
QString quote(const QString &name);
856
/** Perform the opposite of @ref quote.
857
* @param name The name to be un-quoted.
858
* @return String addressing table.
860
QString unQuote(const QString &name);
863
* Get the objects available for the current user. Do not modify the returned list.
864
* @param block Indicate wether or not to block until cached objects are available.
865
* @return A list of object available for the current user. The list is sorted in
866
* owner and name order.
868
std::list<objectName> &objects(bool block);
870
/** Add a new object to the objectlist if it doesn't exist already.
871
* @param object The object to add
873
void addIfNotExists(objectName &object);
876
* Get syntax analyzer for connection
877
* @return A reference to the syntax analyzer to use for the connection.
879
virtual toSyntaxAnalyzer &analyzer();
882
* Get the synonyms available for objects. Do not modify the returned list.
883
* @param block Indicate wether or not to block until cached objects are available.
884
* @return A list of synonyms to objects available for the current user.
886
std::map<QString,objectName> &synonyms(bool block);
888
* Get a list of the available columns for a table. This function caches the responses
889
* and should be fairly fast after the first call. Do not modify the returned list.
890
* @param table The table to describe.
891
* @param nocache Don't use cached values even if they are available.
892
* @return A list of the columns for a table.
894
toQDescList &columns(const objectName &table,bool nocache=false);
896
* Reread the object and column cache.
898
void rereadCache(void);
900
* Get the real object name of an object.
901
* @param object Object name
902
* @param block Block if not done caching object.
904
const objectName &realName(const QString &object,bool block);
906
* Get the real object name of a synonym.
907
* @param object Object name
908
* @param synonym Filled with the synonym used to access the object returned or empty.
909
* @param block Block if not done caching object.
911
const objectName &realName(const QString &object,QString &synonym,bool block);
912
/** Check if cache is available or not.
913
* @param synonyms If synonyms are needed or not.
914
* @param block Block until cache is done.
915
* @param true True if you need the cache, or just checking.
916
* @return True if cache is available.
918
bool cacheAvailable(bool synonyms,bool block=false,bool need=true);
920
/** Try to stop all running queries.
922
void cancelAll(void);
927
bool loadDiskCache(void);
932
void writeDiskCache(void);
934
/** Get a list of currently running SQL.
936
std::list<QString> running(void);
938
static QString cacheDir();
940
friend class toQuery;
943
/** This class is used to implement new database providers.
946
class toConnectionProvider {
947
static std::map<QCString,toConnectionProvider *> *Providers;
948
static std::map<QCString,toConnectionProvider *> *Types;
950
static void checkAlloc(void);
952
/** Get the provider object for a given provider name.
953
* @param provider Name of provider.
954
* @return Reference to provider object.
956
static toConnectionProvider &fetchProvider(const QCString &provider);
958
/** Add a provider to the list that this provider can handle.
960
void addProvider(const QCString &provider);
961
/** Remove a provider from the list that this provider can handle.
963
void removeProvider(const QCString &provider);
965
/** Create a new provider with the specified name.
966
* @param provider Name of the provider.
968
toConnectionProvider(const QCString &provider,bool add=true);
971
virtual ~toConnectionProvider();
973
/** Create an implementation of a connection to this database.
974
* @param provider Provider to use for connection.
975
* @param conn The connection object to use the created connection.
976
* @return A connection implementation created with new.
978
virtual toConnection::connectionImpl *provideConnection(const QCString &provider,
979
toConnection *conn)=0;
980
/** List the available hosts this database provider knows about.
981
* @return A list of hosts.
983
virtual std::list<QString> providedHosts(const QCString &provider);
984
/** List the available databases this provider knows about for a given host.
985
* @param host Host to return connections for.
986
* @param user That might be needed.
987
* @param password That might be needed.
988
* @return A list of databases available for a given host.
990
virtual std::list<QString> providedDatabases(const QCString &provider,
993
const QString &pwd)=0;
994
/** Will be called after program has been started and before connections have been opened.
995
* Use for initialization.
997
virtual void initialize(void)
1000
/** Get a list of options available for the connection. An option with the name
1001
* "-" indicates a break should be made to separate the rest of the options from the previous
1002
* options. An option preceeded by "*" means selected by default. The * shoul be stripped before
1003
* before passing it to the connection call.
1005
virtual std::list<QString> providedOptions(const QCString &provider);
1008
* Create and return configuration tab for this connectiontype. The returned widget should also
1009
* be a childclass of @ref toSettingTab.
1011
* @return A pointer to the widget containing the setup tab for this tool or NULL of
1012
* no settings are available.
1014
virtual QWidget *providerConfigurationTab(const QCString &provider,QWidget *parent);
1016
/** Get a list of names for providers.
1018
static QWidget *configurationTab(const QCString &provider,QWidget *parent);
1019
/** Get a list of names for providers.
1021
static std::list<QCString> providers();
1022
/** Get a list of options for a given provider.
1024
static std::list<QString> options(const QCString &provider);
1025
/** Implement a connection for a given provider.
1026
* @param provider Provider to implement.
1027
* @param conn Connection to create implementation for.
1029
static toConnection::connectionImpl *connection(const QCString &provider,toConnection *conn);
1030
/** Get a list of hosts this provider knows about.
1032
static std::list<QString> hosts(const QCString &provider);
1033
/** Get a list of databases for a given provider and host.
1034
* @param provider Provider to fetch databases for.
1035
* @param host Host to fetch databases for.
1036
* @param user That might be needed.
1037
* @param password That might be needed.
1038
* @return List of known databases.
1040
static std::list<QString> databases(const QCString &provider,const QString &host,
1041
const QString &user,const QString &pwd);
1043
* Get connection specific settings.
1045
* Setting names are hierachical separated by ':' instead of '/' usually used
1046
* in filenames. As an example all settings for the tool 'Example' would be
1047
* under the 'Example:{settingname}' name. Observe that the settings are stored
1048
* under the main provider name as passed to the toConnectionProvider constructor.
1050
* @param tag The name of the configuration setting.
1051
* @param def Contents of this setting.
1053
const QString &config(const QCString &tag,const QCString &def);
1055
* Change connectionspecific setting. Depending on the implementation this can change the
1056
* contents on disk or not.
1058
* Setting names are hierachical separated by ':' instead of '/' usually used
1059
* in filenames. As an example all settings for the tool 'Example' would be
1060
* under the 'Example:{settingname}' name. Observe that the settings are stored
1061
* under the main provider name as passed to the toConnectionProvider constructor.
1063
* @param tag The name of the configuration setting.
1064
* @param def Default value of the setting, if it is not available.
1066
void setConfig(const QCString &tag,const QCString &value);
1068
/** Call all initializers
1070
static void initializeAll(void);
1077
<tr><td><small>Generated by: nneul on skyhawk on Wed Feb 23 19:49:58 2005, using kdoc 2.0a54.</small></td></tr>