SAGA API  v9.2
data_manager.h
Go to the documentation of this file.
1 
3 // //
4 // SAGA //
5 // //
6 // System for Automated Geoscientific Analyses //
7 // //
8 // Application Programming Interface //
9 // //
10 // Library: SAGA_API //
11 // //
12 //-------------------------------------------------------//
13 // //
14 // data_manager.h //
15 // //
16 // Copyright (C) 2013 by Olaf Conrad //
17 // //
18 //-------------------------------------------------------//
19 // //
20 // This file is part of 'SAGA - System for Automated //
21 // Geoscientific Analyses'. //
22 // //
23 // This library is free software; you can redistribute //
24 // it and/or modify it under the terms of the GNU Lesser //
25 // General Public License as published by the Free //
26 // Software Foundation, either version 2.1 of the //
27 // License, or (at your option) any later version. //
28 // //
29 // This library is distributed in the hope that it will //
30 // be useful, but WITHOUT ANY WARRANTY; without even the //
31 // implied warranty of MERCHANTABILITY or FITNESS FOR A //
32 // PARTICULAR PURPOSE. See the GNU Lesser General Public //
33 // License for more details. //
34 // //
35 // You should have received a copy of the GNU Lesser //
36 // General Public License along with this program; if //
37 // not, see <http://www.gnu.org/licenses/>. //
38 // //
39 //-------------------------------------------------------//
40 // //
41 // contact: Olaf Conrad //
42 // Institute of Geography //
43 // University of Hamburg //
44 // Germany //
45 // //
46 // e-mail: oconrad@saga-gis.org //
47 // //
49 
50 //---------------------------------------------------------
51 #ifndef HEADER_INCLUDED__SAGA_API__data_manager_H
52 #define HEADER_INCLUDED__SAGA_API__data_manager_H
53 
54 
56 // //
57 // //
58 // //
60 
61 //---------------------------------------------------------
71 // //
73 // //
74 // //
76 
77 //---------------------------------------------------------
78 #include "parameters.h"
79 
80 
82 // //
83 // //
84 // //
86 
87 //---------------------------------------------------------
89 {
90  friend class CSG_Data_Manager;
91 
92 public:
93 
94  size_t Count (void) const { return( m_Objects.Get_Size() ); }
95 
96  CSG_Data_Object * Get (size_t i) const { return( i < Count() ? (CSG_Data_Object *)m_Objects[i] : NULL ); }
97  CSG_Data_Object * Get (const CSG_String &File, bool bNative = true) const;
98 
99  virtual bool Exists (CSG_Data_Object *pObject) const;
100 
101 
102 protected:
103 
105  virtual ~CSG_Data_Collection(void);
106 
107  virtual bool Add (CSG_Data_Object *pObject);
108  bool Delete (CSG_Data_Object *pObject, bool bDetach = false);
109  bool Delete (size_t i , bool bDetach = false);
110  bool Delete ( bool bDetach = false, bool bUnsaved = false);
111 
112  bool Delete_All ( bool bDetach = false); // deprecated
113  bool Delete_Unsaved ( bool bDetach = false); // deprecated
114 
115 
117 
119 
121 
122 };
123 
124 
126 // //
128 
129 //---------------------------------------------------------
131 {
132  friend class CSG_Data_Manager;
133 
134 public:
135 
136  virtual bool Exists (CSG_Data_Object *pObject) const;
137 
138  const CSG_Grid_System & Get_System (void) const { return( m_System ); }
139 
140  bool is_Equal (const CSG_Grid_System &System) const
141  {
142  return( Count() > 0 && m_System.is_Equal(System) );
143  }
144 
145 
146 protected:
147 
148  CSG_Grid_Collection(class CSG_Data_Manager *pManager);
149 
150  virtual bool Add (CSG_Data_Object *pObject);
151 
152 
154 
155 };
156 
157 
159 // //
161 
162 //---------------------------------------------------------
164 {
165 public:
166  CSG_Data_Manager(void);
167  virtual ~CSG_Data_Manager(void);
168 
169  CSG_Data_Collection * Get_Table (void) const { return( m_pTable ); }
170  CSG_Data_Collection * asTIN (void) const { return( m_pTIN ); }
171  CSG_Data_Collection * Get_Point_Cloud (void) const { return( m_pPoint_Cloud ); }
172  CSG_Data_Collection * Get_Shapes (void) const { return( m_pShapes ); }
173 
174  size_t Grid_System_Count (void) const { return( m_Grid_Systems.Get_Size() ); }
175  CSG_Grid_Collection * Get_Grid_System (size_t i) const { return( i < Grid_System_Count() ? (CSG_Grid_Collection *)m_Grid_Systems[i] : NULL ); }
176  CSG_Grid_Collection * Get_Grid_System (const CSG_Grid_System &System) const;
177 
178  bool Add (CSG_Data_Object *pObject);
179 
181  CSG_Data_Object * Add (const char *File, TSG_Data_Object_Type Type = SG_DATAOBJECT_TYPE_Undefined) { return( Add(CSG_String(File), Type) ); }
182  CSG_Data_Object * Add (const wchar_t *File, TSG_Data_Object_Type Type = SG_DATAOBJECT_TYPE_Undefined) { return( Add(CSG_String(File), Type) ); }
183 
184  CSG_Table * Add_Table (void);
185  CSG_Table * Add_Table (const CSG_String &File) { return( (CSG_Table *)Add(File, SG_DATAOBJECT_TYPE_Table ) ); }
186  CSG_Table * Add_Table (const char *File) { return( (CSG_Table *)Add(File, SG_DATAOBJECT_TYPE_Table ) ); }
187  CSG_Table * Add_Table (const wchar_t *File) { return( (CSG_Table *)Add(File, SG_DATAOBJECT_TYPE_Table ) ); }
188 
189  CSG_TIN * Add_TIN (void);
190  CSG_TIN * Add_TIN (const CSG_String &File) { return( (CSG_TIN *)Add(File, SG_DATAOBJECT_TYPE_TIN ) ); }
191  CSG_TIN * Add_TIN (const char *File) { return( (CSG_TIN *)Add(File, SG_DATAOBJECT_TYPE_TIN ) ); }
192  CSG_TIN * Add_TIN (const wchar_t *File) { return( (CSG_TIN *)Add(File, SG_DATAOBJECT_TYPE_TIN ) ); }
193 
194  CSG_PointCloud * Add_PointCloud (void);
196  CSG_PointCloud * Add_PointCloud (const char *File) { return( (CSG_PointCloud *)Add(File, SG_DATAOBJECT_TYPE_PointCloud) ); }
197  CSG_PointCloud * Add_PointCloud (const wchar_t *File) { return( (CSG_PointCloud *)Add(File, SG_DATAOBJECT_TYPE_PointCloud) ); }
198 
199  CSG_Shapes * Add_Shapes (TSG_Shape_Type Type = SHAPE_TYPE_Undefined);
200  CSG_Shapes * Add_Shapes (const CSG_String &File) { return( (CSG_Shapes *)Add(File, SG_DATAOBJECT_TYPE_Shapes ) ); }
201  CSG_Shapes * Add_Shapes (const char *File) { return( (CSG_Shapes *)Add(File, SG_DATAOBJECT_TYPE_Shapes ) ); }
202  CSG_Shapes * Add_Shapes (const wchar_t *File) { return( (CSG_Shapes *)Add(File, SG_DATAOBJECT_TYPE_Shapes ) ); }
203 
204  CSG_Grid * Add_Grid (const CSG_Grid_System &System, TSG_Data_Type Type = SG_DATATYPE_Undefined);
205  CSG_Grid * Add_Grid (int NX, int NY, double Cellsize = 0., double xMin = 0., double yMin = 0., TSG_Data_Type Type = SG_DATATYPE_Undefined);
206  CSG_Grid * Add_Grid (const CSG_String &File) { return( (CSG_Grid *)Add(File, SG_DATAOBJECT_TYPE_Grid ) ); }
207  CSG_Grid * Add_Grid (const char *File) { return( (CSG_Grid *)Add(File, SG_DATAOBJECT_TYPE_Grid ) ); }
208  CSG_Grid * Add_Grid (const wchar_t *File) { return( (CSG_Grid *)Add(File, SG_DATAOBJECT_TYPE_Grid ) ); }
209 
210  CSG_Grids * Add_Grids (const CSG_String &File) { return( (CSG_Grids *)Add(File, SG_DATAOBJECT_TYPE_Grids ) ); }
211  CSG_Grids * Add_Grids (const char *File) { return( (CSG_Grids *)Add(File, SG_DATAOBJECT_TYPE_Grids ) ); }
212  CSG_Grids * Add_Grids (const wchar_t *File) { return( (CSG_Grids *)Add(File, SG_DATAOBJECT_TYPE_Grids ) ); }
213 
214  bool Delete (CSG_Data_Collection *pCollection, bool bDetach = false);
215  bool Delete (CSG_Data_Object *pObject , bool bDetach = false);
216  bool Delete (const CSG_Grid_System &System , bool bDetach = false);
217  bool Delete ( bool bDetach = false, bool bUnsaved = false);
218 
219  bool Delete_All ( bool bDetach = false); // deprecated
220  bool Delete_Unsaved ( bool bDetach = false); // deprecated
221 
222  bool Exists (CSG_Data_Object *pObject) const;
223  bool Exists (const CSG_Grid_System &System) const;
224 
225  CSG_Data_Object * Find (const CSG_String &File, bool bNative = true) const;
226 
227  CSG_String Get_Summary (void) const;
228 
229 
230 private:
231 
232  CSG_Array_Pointer m_Grid_Systems;
233 
234  CSG_Data_Collection *m_pTable, *m_pTIN, *m_pPoint_Cloud, *m_pShapes;
235 
236 
237  CSG_Data_Collection * _Get_Collection (CSG_Data_Object *pObject) const;
238 
239  CSG_Data_Object * _Add_External (const CSG_String &File);
240 
241 };
242 
243 //---------------------------------------------------------
245 
246 
248 // //
249 // //
250 // //
252 
253 //---------------------------------------------------------
254 #endif // #ifndef HEADER_INCLUDED__SAGA_API__data_manager_H
CSG_Grid_Collection::is_Equal
bool is_Equal(const CSG_Grid_System &System) const
Definition: data_manager.h:140
SG_DATATYPE_Undefined
@ SG_DATATYPE_Undefined
Definition: api_core.h:1001
CSG_Data_Manager::Get_Shapes
CSG_Data_Collection * Get_Shapes(void) const
Definition: data_manager.h:172
CSG_Data_Manager::Get_Table
CSG_Data_Collection * Get_Table(void) const
Definition: data_manager.h:169
CSG_Data_Collection::Get
CSG_Data_Object * Get(size_t i) const
Definition: data_manager.h:96
CSG_Data_Collection::Count
size_t Count(void) const
Definition: data_manager.h:94
CSG_Data_Collection::Add
virtual bool Add(CSG_Data_Object *pObject)
Definition: data_manager.cpp:119
TSG_Shape_Type
TSG_Shape_Type
Definition: shapes.h:100
CSG_Grid_System
Definition: grid.h:200
CSG_Data_Manager::Add_Table
CSG_Table * Add_Table(const wchar_t *File)
Definition: data_manager.h:187
CSG_Data_Manager::Add_TIN
CSG_TIN * Add_TIN(const char *File)
Definition: data_manager.h:191
CSG_Data_Manager::Add_Grid
CSG_Grid * Add_Grid(const wchar_t *File)
Definition: data_manager.h:208
CSG_Data_Manager::Add
CSG_Data_Object * Add(const wchar_t *File, TSG_Data_Object_Type Type=SG_DATAOBJECT_TYPE_Undefined)
Definition: data_manager.h:182
CSG_Data_Collection
Definition: data_manager.h:89
SG_DATAOBJECT_TYPE_Grids
@ SG_DATAOBJECT_TYPE_Grids
Definition: dataobject.h:119
CSG_Data_Manager::Exists
bool Exists(CSG_Data_Object *pObject) const
Definition: data_manager.cpp:389
CSG_Grid_Collection::Get_System
const CSG_Grid_System & Get_System(void) const
Definition: data_manager.h:138
CSG_Data_Manager::Get_Grid_System
CSG_Grid_Collection * Get_Grid_System(size_t i) const
Definition: data_manager.h:175
CSG_Data_Manager::Add_Grid
CSG_Grid * Add_Grid(const CSG_String &File)
Definition: data_manager.h:206
CSG_TIN
Definition: tin.h:222
CSG_Data_Object
Definition: dataobject.h:180
CSG_Data_Collection::Exists
virtual bool Exists(CSG_Data_Object *pObject) const
Definition: data_manager.cpp:105
CSG_Data_Manager::asTIN
CSG_Data_Collection * asTIN(void) const
Definition: data_manager.h:170
CSG_Data_Manager::Delete_All
bool Delete_All(bool bDetach=false)
Definition: data_manager.cpp:782
CSG_Grid_Collection::m_System
CSG_Grid_System m_System
Definition: data_manager.h:153
CSG_Data_Manager::Add_Table
CSG_Table * Add_Table(const CSG_String &File)
Definition: data_manager.h:185
CSG_Data_Manager::Delete
bool Delete(CSG_Data_Collection *pCollection, bool bDetach=false)
Definition: data_manager.cpp:686
CSG_Data_Manager::Add_Shapes
CSG_Shapes * Add_Shapes(const char *File)
Definition: data_manager.h:201
CSG_Data_Manager::Add_Shapes
CSG_Shapes * Add_Shapes(const CSG_String &File)
Definition: data_manager.h:200
CSG_Data_Manager::Add_Grids
CSG_Grids * Add_Grids(const wchar_t *File)
Definition: data_manager.h:212
CSG_Data_Manager::Add_Grids
CSG_Grids * Add_Grids(const CSG_String &File)
Definition: data_manager.h:210
SAGA_API_DLL_EXPORT
#define SAGA_API_DLL_EXPORT
Definition: api_core.h:94
CSG_Data_Manager::Get_Point_Cloud
CSG_Data_Collection * Get_Point_Cloud(void) const
Definition: data_manager.h:171
SG_DATAOBJECT_TYPE_TIN
@ SG_DATAOBJECT_TYPE_TIN
Definition: dataobject.h:122
SG_DATAOBJECT_TYPE_Grid
@ SG_DATAOBJECT_TYPE_Grid
Definition: dataobject.h:118
parameters.h
CSG_Data_Manager::Add_Grid
CSG_Grid * Add_Grid(const char *File)
Definition: data_manager.h:207
CSG_Table
Definition: table.h:283
SG_Get_Data_Manager
SAGA_API_DLL_EXPORT CSG_Data_Manager & SG_Get_Data_Manager(void)
Definition: data_manager.cpp:65
SG_DATAOBJECT_TYPE_Shapes
@ SG_DATAOBJECT_TYPE_Shapes
Definition: dataobject.h:121
CSG_Data_Manager::Add_TIN
CSG_TIN * Add_TIN(const CSG_String &File)
Definition: data_manager.h:190
SG_DATAOBJECT_TYPE_Undefined
@ SG_DATAOBJECT_TYPE_Undefined
Definition: dataobject.h:124
CSG_Data_Manager::Add_PointCloud
CSG_PointCloud * Add_PointCloud(const wchar_t *File)
Definition: data_manager.h:197
CSG_Data_Collection::m_pManager
class CSG_Data_Manager * m_pManager
Definition: data_manager.h:116
CSG_Grid_Collection
Definition: data_manager.h:131
TSG_Data_Object_Type
TSG_Data_Object_Type
Definition: dataobject.h:117
CSG_String
Definition: api_core.h:557
CSG_Data_Manager::Add
bool Add(CSG_Data_Object *pObject)
Definition: data_manager.cpp:428
CSG_Array_Pointer
Definition: api_core.h:368
CSG_Data_Manager::Add_Shapes
CSG_Shapes * Add_Shapes(const wchar_t *File)
Definition: data_manager.h:202
SG_DATAOBJECT_TYPE_Table
@ SG_DATAOBJECT_TYPE_Table
Definition: dataobject.h:120
CSG_Data_Manager
Definition: data_manager.h:164
CSG_Data_Manager::Add_TIN
CSG_TIN * Add_TIN(const wchar_t *File)
Definition: data_manager.h:192
CSG_Data_Manager::Add_Table
CSG_Table * Add_Table(const char *File)
Definition: data_manager.h:186
CSG_Grid
Definition: grid.h:473
CSG_Data_Manager::Grid_System_Count
size_t Grid_System_Count(void) const
Definition: data_manager.h:174
CSG_Data_Manager::Add_PointCloud
CSG_PointCloud * Add_PointCloud(const char *File)
Definition: data_manager.h:196
CSG_Data_Manager::Add_Grids
CSG_Grids * Add_Grids(const char *File)
Definition: data_manager.h:211
CSG_Shapes
Definition: shapes.h:773
CSG_PointCloud
Definition: pointcloud.h:105
CSG_Data_Manager::Delete_Unsaved
bool Delete_Unsaved(bool bDetach=false)
Definition: data_manager.cpp:788
TSG_Data_Type
TSG_Data_Type
Definition: api_core.h:985
CSG_Data_Manager::Add
CSG_Data_Object * Add(const char *File, TSG_Data_Object_Type Type=SG_DATAOBJECT_TYPE_Undefined)
Definition: data_manager.h:181
CSG_Data_Collection::m_Objects
CSG_Array_Pointer m_Objects
Definition: data_manager.h:120
CSG_Data_Collection::m_Type
TSG_Data_Object_Type m_Type
Definition: data_manager.h:118
CSG_Grids
Definition: grids.h:119
CSG_Data_Manager::Add_PointCloud
CSG_PointCloud * Add_PointCloud(const CSG_String &File)
Definition: data_manager.h:195
SG_DATAOBJECT_TYPE_PointCloud
@ SG_DATAOBJECT_TYPE_PointCloud
Definition: dataobject.h:123
SHAPE_TYPE_Undefined
@ SHAPE_TYPE_Undefined
Definition: shapes.h:101