Isis Developer Reference
Database.h
Go to the documentation of this file.
1#ifndef Database_h
2#define Database_h
3
10/* SPDX-License-Identifier: CC0-1.0 */
11
12#include <string>
13#include <vector>
14#include <iostream>
15#include "DbProfile.h"
16#include "IException.h"
17#include <QSqlDatabase>
18
19namespace Isis {
20
70 class Database : public QSqlDatabase {
71 public:
73 typedef enum {
77
78 Database();
79 Database(Access dbConn);
80 Database(const QString &connName, const QString &driverType);
81 Database(const QString &name, Access dbConn = Connect);
82 Database(const DbProfile &profile, Access dbConn = Connect);
83 virtual ~Database();
84
90 QString Name() const {
91 return (_name);
92 }
93
94 void makePersistant();
95 bool isPersistant() const;
96 void setAsDefault();
97 Database clone(const QString &name) const;
98 QStringList getTables() const;
99 QStringList getViews() const;
101
102 static void remove(const QString &name);
103
104 static bool addAccessConfig(const QString &confFile);
105 static DbProfile getProfile(const QString &name);
106
107 protected:
108 Database(const QSqlDatabase &other, const QString &name);
109 QSqlDatabase init(const DbProfile &profile, Access dbConn = Connect);
110 QSqlDatabase init(const QString &name = "",
111 const QString &driverType = "");
112 void configureAccess(QSqlDatabase &db, const DbProfile &profile);
113
114 private:
115 static QString _actualConnectionName;
118 QString _name;
119
120 void tossDbError(const QString &message, const char *f, int l) const;
121 };
122
123}
124#endif
Isis database class providing generalized access to a variety of databases.
Definition Database.h:70
Database clone(const QString &name) const
Clones this database into another giving it another name.
Definition Database.cpp:499
virtual ~Database()
Database destructor.
Definition Database.cpp:160
bool isPersistant() const
Checks persistancy state of a database instantiation.
Definition Database.cpp:207
static void remove(const QString &name)
Removes the named database from pool.
Definition Database.cpp:254
QString Name() const
Return the name of this database as specifed upon creation.
Definition Database.h:90
QStringList getSystemTables() const
Returns vector strings of all available system tables in the database.
Definition Database.cpp:536
Access
Access status for database creation.
Definition Database.h:73
@ Connect
Connect to database immediately.
Definition Database.h:74
@ DoNotConnect
Do not connect to database.
Definition Database.h:75
QStringList getTables() const
Returns a vector string containing all the tables in the database.
Definition Database.cpp:511
static bool addAccessConfig(const QString &confFile)
Adds a user specifed access configuration file to system.
Definition Database.cpp:275
Database()
Default database constructor.
Definition Database.cpp:33
static DbProfile getProfile(const QString &name)
Retrieves the named database access profile.
Definition Database.cpp:312
void configureAccess(QSqlDatabase &db, const DbProfile &profile)
Set access parameters from a database DbProfile access specification.
Definition Database.cpp:455
void setAsDefault()
Sets this database connection/profile as the default.
Definition Database.cpp:226
QStringList getViews() const
Returns a vector string containing all views within the database.
Definition Database.cpp:524
QSqlDatabase init(const DbProfile &profile, Access dbConn=Connect)
Create and initialize a new database connection from a DbProfile.
Definition Database.cpp:403
void makePersistant()
Makes this instance persistant.
Definition Database.cpp:191
A DbProfile is a container for access parameters to a database.
Definition DbProfile.h:51
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16