Version: 0.6.0
gxremoteconn.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,2014 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 #include "wxgis/catalog/gxobject.h"
24 #include "wxgis/catalog/gxdataset.h"
25 #include "wxgis/core/json/jsonval.h"
26 #include "wxgis/catalog/contupdater.h"
27 
28 #ifdef wxGIS_USE_POSTGRES
29 
30 #include "wxgis/datasource/postgisdataset.h"
31 
32 class wxGxRemoteDBSchema;
33 
42 class WXDLLIMPEXP_GIS_CLT wxGxRemoteConnection :
43  public IGxObjectEdit,
44  public IGxRemoteConnection,
45  public IGxObjectNoFilter,
47 {
48  DECLARE_CLASS(wxGxRemoteConnection)
49 public:
50  wxGxRemoteConnection(wxGxObject *oParent, const wxString &soName = wxEmptyString, const CPLString &soPath = "");
51  virtual ~wxGxRemoteConnection(void);
52  //wxGxObject
53  virtual bool Destroy(void);
54  virtual wxString GetCategory(void) const { return wxString(_("Database Connection")); };
55  virtual void Refresh(void);
56  //IGxRemoteConnection
57  virtual bool Connect(void);
58  virtual bool Disconnect(void);
59  virtual bool IsConnected(void);
60  //IGxObjectEdit
61  virtual bool Delete(void);
62  virtual bool CanDelete(void) {return true;};
63  virtual bool Rename(const wxString& NewName);
64  virtual bool CanRename(void) { return true; };
65  virtual bool Copy(const CPLString &szDestPath, ITrackCancel* const pTrackCancel);
66  virtual bool CanCopy(const CPLString &szDestPath) { return true; };
67  virtual bool Move(const CPLString &szDestPath, ITrackCancel* const pTrackCancel);
68  virtual bool CanMove(const CPLString &szDestPath) { return CanCopy(szDestPath) & CanDelete(); };
69  //wxGxObjectContainer
70  virtual bool AreChildrenViewable(void) const {return true;};
71  virtual bool CanCreate(long nDataType, long DataSubtype);
72  //wxGxRemoteConnection
73  bool CreateSchema(const wxString& sSchemaName);
74  wxString CheckUniqSchemaName(const wxString& sSchemaName, const wxString& sAdd = wxT(" "), int nCounter = 0) const;
75 protected:
76  //wxGxRemoteConnection
77  virtual void LoadChildren(void);
78  virtual wxGxRemoteDBSchema* GetNewRemoteDBSchema(int nRemoteId, const wxString &sName, const CPLString &soPath, wxGISPostgresDataSource *pwxGISRemoteConn);
79  //create wxGISDataset without openning it
80  virtual wxGISDataset* const GetDatasetFast(void);
81  //wxGxObjectContainerUpdater
82  virtual wxGxObjectMap GetRemoteObjects();
83  virtual void AddObject(int nRemoteId, const wxString &sName);
84 protected:
85  wxGISDataset* m_pwxGISDataset;
86  bool m_bIsConnected;
87 };
88 
96 class WXDLLIMPEXP_GIS_CLT wxGxRemoteDBSchema :
97  public IGxObjectEdit,
98  public IGxObjectNoFilter,
100  public wxGxRemoteId
101 {
102  DECLARE_CLASS(wxGxRemoteDBSchema)
103 public:
104  wxGxRemoteDBSchema(int nRemoteId, wxGISPostgresDataSource* pwxGISRemoteConn, wxGxObject *oParent, const wxString &soName = wxEmptyString, const CPLString &soPath = "");
105  virtual ~wxGxRemoteDBSchema(void);
106  //wxGxObject
107  virtual bool Destroy();
108  virtual wxString GetCategory(void) const { return wxString(_("Remote Database Schema")); };
109  virtual void Refresh(void);
110  //wxGxObjectContainer
111  virtual bool AreChildrenViewable(void) const {return true;};
112  virtual bool HasChildren(void);
113  virtual bool CanCreate(long nDataType, long DataSubtype);
114  //IGxObjectEdit
115  virtual bool Delete(void);
116  virtual bool CanDelete(void);
117  virtual bool Rename(const wxString& NewName);
118  virtual bool CanRename(void);
119  virtual bool Copy(const CPLString &szDestPath, ITrackCancel* const pTrackCancel);
120  virtual bool CanCopy(const CPLString &szDestPath);
121  virtual bool Move(const CPLString &szDestPath, ITrackCancel* const pTrackCancel);
122  virtual bool CanMove(const CPLString &szDestPath);
123  wxString CheckUniqTableName(const wxString& sTableName, const wxString& sAdd = wxT(" "), int nCounter = 0) const;
124 protected:
125  //wxGxRemoteDBSchema
126  virtual void LoadChildren(void);
127  virtual wxGxObject* GetNewTable(int nRemoteId, const wxString &sTableName, const wxGISEnumDatasetType eType);
128  //wxGxObjectContainerUpdater
129  virtual wxGxObjectMap GetRemoteObjects();
130  virtual void AddObject(int nRemoteId, const wxString &sName);
131 protected:
132  wxGISPostgresDataSource* m_pwxGISRemoteConn;
133 };
134 
135 #endif //wxGIS_USE_POSTGRES
136 
137 
145 class WXDLLIMPEXP_GIS_CLT wxGxTMSWebService :
146  public wxGxRasterDataset
147 {
148  DECLARE_CLASS(wxGxTMSWebService)
149 public:
150  wxGxTMSWebService(wxGxObject *oParent, const wxString &soName = wxEmptyString, const CPLString &soPath = "");
151  virtual ~wxGxTMSWebService(void);
152  //wxGxObject
153  virtual wxString GetCategory(void) const {return wxString(_("Tile Map service"));};
154  //wxGxDataset
155  virtual void FillMetadata(bool bForce = false);
156 };
157 
Definition: gxremoteconn.h:145
Definition: catalog.h:87
A TrackCancel interface class.
Definition: core.h:144
Definition: dataset.h:33
Definition: contupdater.h:70
Definition: contupdater.h:36
Definition: catalog.h:51
Definition: gxdataset.h:177
Definition: catalog.h:123
Definition: gxobject.h:37