Version: 0.6.0
gxshellconn.h
1 /******************************************************************************
2  * Project: wxGIS (GIS Catalog)
3  * Purpose: Remote Connection classes.
4  * Author: Dmitry Baryshnikov (aka Bishop), polimax@mail.ru
5  ******************************************************************************
6 * Copyright (C) 2011,2013 Dmitry Baryshnikov
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  ****************************************************************************/
21 #pragma once
22 
23 /*
24 #include "wxgis/catalog/gxobject.h"
25 #include "wxgis/catalog/gxdataset.h"
26 
27 #ifdef wxGIS_USE_POSTGRES
28 
29 #include "wxgis/datasource/postgisdataset.h"
30 
31 class wxGxRemoteDBSchema;
32 
33 WX_DECLARE_HASH_MAP(int, wxString, wxIntegerHash, wxIntegerEqual, wxGISDBShemaMap);
34 
38 /*
39 class WXDLLIMPEXP_GIS_CLT wxGxRemoteConnection :
40  public wxGxObjectContainer,
41  public IGxObjectEdit,
42  public IGxRemoteConnection,
43  public wxThreadHelper,
44  public IGxObjectNoFilter
45 {
46  DECLARE_CLASS(wxGxRemoteConnection)
47 public:
48  wxGxRemoteConnection(wxGxObject *oParent, const wxString &soName = wxEmptyString, const CPLString &soPath = "");
49  virtual ~wxGxRemoteConnection(void);
50  //wxGxObject
51  virtual bool Destroy(void);
52  virtual wxString GetCategory(void) const { return wxString(_("Database Connection")); };
53  virtual void Refresh(void);
54  //IGxRemoteConnection
55  virtual bool Connect(void);
56  virtual bool Disconnect(void);
57  virtual bool IsConnected(void);
58  //IGxObjectEdit
59  virtual bool Delete(void);
60  virtual bool CanDelete(void){return true;};
61  virtual bool Rename(const wxString& NewName);
62  virtual bool CanRename(void){return true;};
63  virtual bool Copy(const CPLString &szDestPath, ITrackCancel* const pTrackCancel);
64  virtual bool CanCopy(const CPLString &szDestPath){return true;};
65  virtual bool Move(const CPLString &szDestPath, ITrackCancel* const pTrackCancel);
66  virtual bool CanMove(const CPLString &szDestPath){return CanCopy(szDestPath) & CanDelete();};
67  //wxGxObjectContainer
68  virtual bool AreChildrenViewable(void) const {return true;};
69  //virtual bool HasChildren(void);
70  virtual bool CanCreate(long nDataType, long DataSubtype);
71  //wxGxRemoteConnection
72  bool CreateSchema(const wxString& sSchemaName);
73  wxString CheckUniqSchemaName(const wxString& sSchemaName, const wxString& sAdd = wxT(" "), int nCounter = 0) const;
74 protected:
75  enum
76  {
77  EXIT_EVENT = wxID_HIGHEST + 1,
78  LOADED_EVENT
79  };
80 protected:
81  //wxGxRemoteConnection
82  virtual void LoadChildren(void);
83  virtual wxGxRemoteDBSchema* GetNewRemoteDBSchema(const wxString &sName, const CPLString &soPath, wxGISPostgresDataSource *pwxGISRemoteConn);
84  //create wxGISDataset without openning it
85  virtual wxGISDataset* const GetDatasetFast(void);
86  wxGISDBShemaMap FillSchemaNames(wxGISTableCached* pInfoSchema);
87  void DeleteSchema(const wxString& sSchemaName);
88  void RenameSchema(const wxString& sSchemaName, const wxString& sNewSchemaName);
89  virtual wxThread::ExitCode Entry();
90  virtual bool CreateAndRunThread(void);
91  virtual wxThread::ExitCode CheckChanges();
92  //events
93  virtual void OnThreadFinished(wxThreadEvent& event);
94 protected:
95  wxGISDataset* m_pwxGISDataset;
96  bool m_bIsConnected;
97  wxGISDBShemaMap m_saSchemas;
98  bool m_bHasGeom, m_bHasGeog, m_bHasRaster;
99  bool m_bChildrenLoaded;
100 private:
101  DECLARE_EVENT_TABLE()
102 };
103 
107 /*
108 class WXDLLIMPEXP_GIS_CLT wxGxRemoteDBSchema :
109  public wxGxObjectContainer,
110  public IGxObjectEdit,
111  public wxThreadHelper,
112  public IGxObjectNoFilter
113 {
114  DECLARE_CLASS(wxGxRemoteDBSchema)
115 public:
116  wxGxRemoteDBSchema(bool bHasGeom, bool bHasGeog, bool bHasRaster, wxGISPostgresDataSource* pwxGISRemoteConn, wxGxObject *oParent, const wxString &soName = wxEmptyString, const CPLString &soPath = "");
117  virtual ~wxGxRemoteDBSchema(void);
118  //wxGxObject
119  virtual bool Destroy();
120  virtual wxString GetCategory(void) const { return wxString(_("Remote Database Schema")); };
121  virtual void Refresh(void);
122  //wxGxObjectContainer
123  virtual bool AreChildrenViewable(void) const {return true;};
124  virtual bool HasChildren(void);
125  virtual bool CanCreate(long nDataType, long DataSubtype);
126  //IGxObjectEdit
127  virtual bool Delete(void);
128  virtual bool CanDelete(void);
129  virtual bool Rename(const wxString& NewName);
130  virtual bool CanRename(void);
131  virtual bool Copy(const CPLString &szDestPath, ITrackCancel* const pTrackCancel);
132  virtual bool CanCopy(const CPLString &szDestPath);
133  virtual bool Move(const CPLString &szDestPath, ITrackCancel* const pTrackCancel);
134  virtual bool CanMove(const CPLString &szDestPath);
135  wxString CheckUniqTableName(const wxString& sTableName, const wxString& sAdd = wxT(" "), int nCounter = 0) const;
136 protected:
137  enum
138  {
139  EXIT_EVENT = wxID_HIGHEST + 1,
140  LOADED_EVENT
141  };
142 protected:
143  //wxGxRemoteDBSchema
144  virtual void LoadChildren(void);
145  virtual wxArrayString FillTableNames(void);
146  virtual wxGxObject* AddTable(const wxString &sTableName, const wxGISEnumDatasetType eType);
147  virtual void DeleteTable(const wxString& sSchemaName);
148 
149  virtual bool CreateAndRunThread(void);
150  virtual void CheckChanges();
151  virtual wxThread::ExitCode Entry();
152  //events
153  virtual void OnThreadFinished(wxThreadEvent& event);
154 protected:
155  wxGISPostgresDataSource* m_pwxGISRemoteConn;
156  bool m_bChildrenLoaded;
157  wxCriticalSection m_CritSect;
158  bool m_bHasGeom, m_bHasGeog, m_bHasRaster;
159  wxArrayString m_saTables;
160 private:
161  DECLARE_EVENT_TABLE()
162 };
163 
164 #endif //wxGIS_USE_POSTGRES
165 
166 
170 /*
171 class WXDLLIMPEXP_GIS_CLT wxGxTMSWebService :
172  public wxGxRasterDataset
173 {
174  DECLARE_CLASS(wxGxRemoteConnection)
175 public:
176  wxGxTMSWebService(wxGxObject *oParent, const wxString &soName = wxEmptyString, const CPLString &soPath = "");
177  virtual ~wxGxTMSWebService(void);
178  //wxGxObject
179  virtual wxString GetCategory(void) const {return wxString(_("Web service"));};
180  //wxGxDataset
181  virtual void FillMetadata(bool bForce = false);
182 };
183 */