Version: 0.6.0
table.h
1 /******************************************************************************
2  * Project: wxGIS
3  * Purpose: Table class.
4  * Author: Dmitry Baryshnikov (aka Bishop), polimax@mail.ru
5  ******************************************************************************
6 * Copyright (C) 2010-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/datasource/dataset.h"
24 #include "wxgis/datasource/cursor.h"
25 #include "wxgis/datasource/filter.h"
26 #include "wxgis/datasource/spatialtree.h"
27 #include "wxgis/core/pointer.h"
28 
37 class WXDLLIMPEXP_GIS_DS wxGISTable :
38  public wxGISDataset,
40 {
41  DECLARE_CLASS(wxGISTable)
42  friend class wxGISSpatialTree;
43 public:
44  wxGISTable(const CPLString &sPath, int nSubType, OGRLayer* poLayer = NULL, OGRCompatibleDataSource* poDS = NULL);
45  virtual ~wxGISTable(void);
46  //wxGISDataset
47  virtual wxString GetName(void) const;
48  virtual void Close(void);
49  //wxGISTable
50  virtual bool Open(bool bUpdate = true, bool bShared = true);
51  virtual bool Open(int iLayer = 0, bool bUpdate = true, bool bShared = true, bool bCache = true, ITrackCancel* const pTrackCancel = NULL);
52  virtual size_t GetSubsetsCount(void) const;
53  virtual wxGISDataset* GetSubset(size_t nIndex);
54  virtual wxGISDataset* GetSubset(const wxString & sSubsetName);
55  //sysop
56  virtual char **GetFileList();
57  virtual void Cache(ITrackCancel* const pTrackCancel = NULL);
58  //rowop
59  virtual size_t GetFeatureCount(bool bForce = false, ITrackCancel* const pTrackCancel = NULL);
60  virtual bool CanDeleteFeature(void) const;
61  virtual OGRErr DeleteFeature(long nFID);
62  virtual OGRErr StoreFeature(wxGISFeature &Feature);
63  virtual wxGISFeature CreateFeature(void);
64  virtual OGRErr SetFeature(const wxGISFeature &Feature);
65  virtual OGRErr CommitTransaction(void);
66  virtual OGRErr StartTransaction(void);
67  virtual OGRErr RollbackTransaction(void);
68  //colop
69  virtual bool CanDeleteField(void) const;
70  virtual OGRErr DeleteField(int nIndex);
71  //
72  virtual void Reset(void);
73  virtual wxGISFeature Next(void);
74  virtual wxGISFeature GetFeatureByID(long nFID);
75  virtual wxGISFeature GetFeature(long nIndex);
76  virtual wxString GetFIDColumn(void) const;
77  //
78  virtual wxFontEncoding GetEncoding(void) const;
79  virtual void SetEncoding(const wxFontEncoding &oEncoding);
80  virtual bool HasFID(void) const {return m_bHasFID;};
81  virtual bool HasFilter(void) const { return m_bHasFilter; };
82  virtual wxArrayString GetFieldNames(void) const;
83  virtual wxString GetFieldName(int nIndex) const;
84  //
85  virtual wxFeatureCursor Search(const wxGISQueryFilter &QFilter = wxGISNullQueryFilter, bool bOnlyFirst = false, ITrackCancel* const pTrackCancel = NULL);
86  virtual OGRErr SetFilter(const wxGISQueryFilter &QFilter = wxGISNullQueryFilter);
87  virtual OGRErr SetIgnoredFields(const wxArrayString &saIgnoredFields);
88  virtual OGRCompatibleDataSource* const GetDataSourceRef(void) const {return m_poDS;};
89  virtual OGRLayer* const GetLayerRef(int iLayer = 0) const {return m_poLayer;};
90  virtual OGRFeatureDefn* const GetDefinition(void);
91  virtual OGRFeatureDefn* const GetDefinition(void) const;
92 protected:
93  virtual void SetInternalValues(void);
94  virtual bool IsContainer() const;
95 protected:
96  OGRCompatibleDataSource* m_poDS;
97  OGRLayer* m_poLayer;
98 
99  wxFontEncoding m_Encoding;
100  bool m_bRecodeToSystem;
101 
102  long m_nFeatureCount, m_nCurrentFID;
103  bool m_bOLCStringsAsUTF8;
104  bool m_bOLCFastFeatureCount;
105  bool m_bHasFID;
106  bool m_bHasFilter;
107 };
108 
109 //#define MAXSTRINGSTORE 1000000
110 
119 class WXDLLIMPEXP_GIS_DS wxGISTableCached :
120  public wxGISTable
121 {
122  DECLARE_CLASS(wxGISTableCached)
123 public:
124  wxGISTableCached(const CPLString &sPath, int nSubType, OGRLayer* poLayer = NULL, OGRCompatibleDataSource* poDS = NULL);
125  virtual ~wxGISTableCached(void);
126  //wxGISDataset
127  virtual void Close(void);
128  //wxGISTable
129  virtual void Reset(void);
130  virtual wxGISFeature Next(void);
131  virtual wxGISFeature GetFeatureByID(long nFID);
132  virtual wxGISFeature GetFeature(long nIndex);
133  //sysop
134  virtual void Cache(ITrackCancel* const pTrackCancel = NULL);
135  virtual bool IsCaching(void) const;
136  //rowop
137  virtual size_t GetFeatureCount(bool bForce = false, ITrackCancel* const pTrackCancel = NULL);
138  virtual OGRErr DeleteFeature(long nFID);
139  virtual OGRErr StoreFeature(wxGISFeature &Feature);
140  virtual OGRErr SetFeature(const wxGISFeature &Feature);
141  virtual wxFeatureCursor Search(const wxGISQueryFilter &QFilter = wxGISNullQueryFilter, bool bOnlyFirst = false, ITrackCancel* const pTrackCancel = NULL);
142 protected:
143  std::map<long, wxGISFeature> m_omFeatures;
144  bool m_bIsCaching;
145 };
146 
154 class WXDLLIMPEXP_GIS_DS wxGISTableQuery :
155  public wxGISTableCached
156 {
157  DECLARE_CLASS(wxGISTableQuery)
158 public:
159  wxGISTableQuery(const CPLString &sPath, int nSubType, OGRLayer* poLayer = NULL, OGRCompatibleDataSource* poDS = NULL);
160  virtual ~wxGISTableQuery(void);
161  virtual void Cache(ITrackCancel* const pTrackCancel = NULL);
162  virtual size_t GetFeatureCount(bool bForce = false, ITrackCancel* const pTrackCancel = NULL);
163 };
Attributes query filter.
Definition: filter.h:29
Definition: table.h:37
Definition: pointer.h:34
A TrackCancel interface class.
Definition: core.h:144
Definition: gdalinh.h:117
The class represents an array of OGRFeatures, received by some selection.
Definition: cursor.h:33
Definition: spatialtree.h:63
Definition: dataset.h:33
Definition: table.h:154
Definition: table.h:119