Debian Codegraph @

DatabaseExplorer/IDbAdapter.h

raw
1 //////////////////////////////////////////////////////////////////////////////
2 //////////////////////////////////////////////////////////////////////////////
3 //
4 // copyright : (C) 2014 Eran Ifrah
5 // file name : IDbAdapter.h
6 //
7 // -------------------------------------------------------------------------
8 // A
9 // _____ _ _ _ _
10 // / __ \ | | | | (_) |
11 // | / \/ ___ __| | ___| | _| |_ ___
12 // | | / _ \ / _ |/ _ \ | | | __/ _ )
13 // | \__/\ (_) | (_| | __/ |___| | || __/
14 // \____/\___/ \__,_|\___\_____/_|\__\___|
15 //
16 // F i l e
17 //
18 // This program is free software; you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation; either version 2 of the License, or
21 // (at your option) any later version.
22 //
23 //////////////////////////////////////////////////////////////////////////////
24 //////////////////////////////////////////////////////////////////////////////
25
26 #ifndef IDBADAPTER_H
27 #define IDBADAPTER_H
28 #include <wx/wx.h>
29 #include "smart_ptr.h"
30 #include <wx/dynarray.h>
31 #include <wx/dblayer/include/DatabaseLayer.h>
32 #include "IDbType.h"
33 //#include "columncol.h"
34 //#include "tablecol.h"
35 //#include "databasecol.h"
36 class DbConnection;
37 class Database;
38 class Table;
39 class View;
40 class IDbType;
41
42
43 typedef SmartPtr<DatabaseLayer> DatabaseLayerPtr;
44
45 /*! \brief Basic virtual class for creating universal interface between different database servers. */
46 class IDbAdapter
47 {
48
49 public:
50 enum TYPE {
51 atUNKNOWN = 0,
52 atSQLITE,
53 atMYSQL,
54 atPOSTGRES
55 };
56
57 IDbAdapter()
58 : m_adapterType(atUNKNOWN)
59 {
60 }
61
62 virtual ~IDbAdapter() {}
63
64 /*! \brief Return opened DatabaseLayer for selected database. If dbName is empty, DatabaseLayer will be opend without defalut database. */
65 virtual DatabaseLayerPtr GetDatabaseLayer(const wxString& dbName) = 0;
66
67 /*! \brief Return true if dbAdapter is connected. DEPRECATED!!! */
68 virtual bool IsConnected() = 0;
69
70 /*! \brief Clone DbAdapter and return new object */
71 virtual IDbAdapter* Clone() = 0;
72
73 /*! \brief Return true if adapter settings are set and adapter can connect to the database */
74 virtual bool CanConnect() = 0;
75
76 /*! \brief Function connect databases to the DbConnection */
77 virtual void GetDatabases(DbConnection* dbCon) = 0;
78
79 /*! \brief Function connect tables to the Database */
80 virtual void GetTables(Database* db, bool includeViews) = 0;
81
82 /*! \brief Function connect views to the Database */
83 virtual void GetViews(Database* db) = 0;
84
85 /*! \brief Function connect columns to the DBETable */
86 virtual bool GetColumns(Table* pTab) = 0;
87
88
89 /*! \brief Return wxString with USE DB statement for dbName */
90 virtual wxString GetUseDb(const wxString& dbName) = 0;
91 /*! \brief Return wxString with defalut SELECT for defined table and db */
92 virtual wxString GetDefaultSelect(const wxString& dbName, const wxString& tableName) = 0;
93 virtual wxString GetDefaultSelect(const wxString& cols, const wxString& dbName, const wxString& tableName) = 0;
94 /*! \brief Return Create table sql statement */
95 virtual wxString GetCreateTableSql(Table* tab, bool dropTable) = 0;
96 /*! \brief Return Create view sql statement */
97 virtual wxString GetCreateViewSql(View* view, bool dropView) = 0;
98 /*! \brief Return Create update table SQL statement for adding constraints */
99 virtual wxString GetAlterTableConstraintSql(Table* tab) = 0;
100 /*! \brief Return Create database SQL statement. */
101 virtual wxString GetCreateDatabaseSql(const wxString& dbName) = 0;
102 /*! \brief Return Drop table SQL statement. */
103 virtual wxString GetDropTableSql(Table* pTab) = 0;
104 /*! \brief Return Drop view SQL statement. */
105 virtual wxString GetDropViewSql(View* pView) = 0;
106 /*! \brief Return Drop database SQL statement. */
107 virtual wxString GetDropDatabaseSql(Database* pDb) = 0;
108
109 virtual void CloseConnection() = 0;
110
111 /*! \brief Return IDbType by name string */
112 virtual IDbType* GetDbTypeByName(const wxString& typeName) = 0;
113 /*! \brief Return IDbType by name universal name */
114 virtual IDbType* GetDbTypeByUniversalName(IDbType::UNIVERSAL_TYPE type) = 0;
115 /*! \brief Return wxArrayString of possible db types */
116 virtual wxArrayString* GetDbTypes () = 0;
117
118 /*! \brief Convert IDbType to the special db type. (!!! Old type is deleted !!!) */
119 virtual IDbType* ConvertType (IDbType* pType) = 0;
120 /*! \brief Return wxArrayString of possible db types */
121 virtual void ConvertTable(Table* pTab) = 0;
122
123 const TYPE& GetAdapterType() const {
124 return m_adapterType;
125 }
126
127 protected:
128 TYPE m_adapterType;
129
130 };
131
132 #endif // IDBADAPTER_H