SAGA API v9.10
Loading...
Searching...
No Matches
dataobject.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// dataobject.h //
15// //
16// Copyright (C) 2005 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 Goettingen //
44// Goldschmidtstr. 5 //
45// 37077 Goettingen //
46// Germany //
47// //
48// e-mail: oconrad@saga-gis.org //
49// //
51
52//---------------------------------------------------------
53#ifndef HEADER_INCLUDED__SAGA_API__dataobject_H
54#define HEADER_INCLUDED__SAGA_API__dataobject_H
55
56
58// //
59// //
60// //
62
63//---------------------------------------------------------
69
70
72// //
73// //
74// //
76
77//---------------------------------------------------------
78#include "mat_tools.h"
79#include "metadata.h"
80
81
83// //
84// Meta-Data //
85// //
87
88//---------------------------------------------------------
89#define SG_META_SOURCE "SOURCE"
90#define SG_META_FILEPATH "FILE"
91#define SG_META_DATABASE "DATABASE"
92#define SG_META_PROJECTION "PROJECTION"
93#define SG_META_HISTORY "HISTORY"
94
95
97// //
98// Data Objects //
99// //
101
102//---------------------------------------------------------
115//---------------------------------------------------------
127
128//---------------------------------------------------------
129#define DATAOBJECT_NOTSET ((void *)NULL)
130#define DATAOBJECT_CREATE ((void *)1)
131
133
134//---------------------------------------------------------
138
139
141// //
143
144//---------------------------------------------------------
147
150
151
153// //
155
156//---------------------------------------------------------
161
162
164// //
166
167//---------------------------------------------------------
178//---------------------------------------------------------
180{
182
183public:
184 CSG_Data_Object(void);
185 virtual ~CSG_Data_Object(void);
186
187 virtual bool Destroy (void);
188
190 int Get_RefID (void) const { return( m_RefID ); }
191
192 int Get_Managed (void) const { return( m_Managed ); }
193
195 virtual TSG_Data_Object_Type Get_ObjectType (void) const = 0;
196
197 virtual bool is_Valid (void) const = 0;
198
199 virtual bool Save (const CSG_String &File, int Format = 0) = 0;
200 virtual bool Save (const char *File, int Format = 0) = 0;
201 virtual bool Save (const wchar_t *File, int Format = 0) = 0;
202
204 bool Reload (void);
205
207 bool Delete (void);
208
209 void Set_File_Name (const CSG_String &FileName);
210 const SG_Char * Get_File_Name (bool bNative = true) const;
211 int Get_File_Type (void) const;
212
213 bool is_File_Native (void) const { return( m_File_bNative ); }
214
215 virtual bool Assign (CSG_Data_Object *pObject, bool bProgress = false);
216
217 void Set_Name (const CSG_String &Name);
218 void Set_Name (const char *Name);
219 void Set_Name (const wchar_t *Name);
220 void Fmt_Name (const char *Format, ...);
221 void Fmt_Name (const wchar_t *Format, ...);
222 const SG_Char * Get_Name (void) const;
223
224 void Set_Description (const CSG_String &Description);
225 const SG_Char * Get_Description (void) const;
226
227 virtual void Set_Modified (bool bOn = true) { m_bModified = bOn; if( bOn && m_pOwner ) m_pOwner->Set_Modified(bOn); }
228 virtual bool is_Modified (void) const { return( m_bModified ); }
229 bool Update (bool bForce = false);
230
231 CSG_Data_Object * Get_Owner (void) const { return( m_pOwner ); }
232 void Set_Owner (CSG_Data_Object *pOwner) { m_pOwner = pOwner; }
233
234 CSG_MetaData & Get_MetaData (void) const { return( *m_pMD_Source ); }
235 CSG_MetaData & Get_MetaData_DB (void) const { return( *m_pMD_Database ); }
236 CSG_MetaData & Get_History (void) { return( *m_pMD_History ); }
237 const CSG_MetaData & Get_History (void) const { return( *m_pMD_History ); }
238
239 virtual const CSG_Rect & Get_Extent (void) = 0;
240
242 const CSG_Projection & Get_Projection (void) const;
243
244 class CSG_Table * asTable (bool bPolymorph = false) const;
245 class CSG_Shapes * asShapes (bool bPolymorph = false) const;
246 class CSG_TIN * asTIN (bool bPolymorph = false) const;
247 class CSG_PointCloud * asPointCloud (bool bPolymorph = false) const;
248 class CSG_Grid * asGrid (bool bPolymorph = false) const;
249 class CSG_Grids * asGrids (bool bPolymorph = false) const;
250
251 virtual bool Set_NoData_Value (double Value);
252 virtual bool Set_NoData_Value_Range (double Lower, double Upper);
253 double Get_NoData_Value (bool bUpper = false) const { return( m_NoData_Value[bUpper ? 1 : 0] ); }
254
255 bool is_NoData_Value (double Value) const
256 {
257 return( SG_is_NaN(Value) || (m_NoData_Value[0] < m_NoData_Value[1] ? m_NoData_Value[0] <= Value && Value <= m_NoData_Value[1] : Value == m_NoData_Value[0]) );
258 }
259
260 bool Save_History_to_Model (const CSG_String &File) const;
261
262 virtual bool Set_Max_Samples (sLong Max_Samples);
263 sLong Get_Max_Samples (void) const { return( m_Max_Samples ); }
264
266 static void Track (bool Track = true, bool Offset = false);
267
268
269protected:
270
272
273
274 void Set_File_Name (const CSG_String &FileName, bool bNative);
275 void Set_File_Type (int Type) { m_File_Type = Type; }
276
277 virtual bool On_Reload (void) = 0;
278 virtual bool On_Delete (void) = 0;
279
280 bool Load_MetaData (const CSG_String &FileName);
281 bool Load_MetaData (CSG_File &Stream);
282 bool Save_MetaData (const CSG_String &FileName);
283 bool Save_MetaData (CSG_File &Stream);
284
285 void Set_Update_Flag (bool bOn = true) { m_bUpdate = bOn; }
286 bool Get_Update_Flag (void) { return( m_bUpdate ); }
287 virtual bool On_Update (void) { return( true ); }
288 virtual bool On_NoData_Changed (void);
289
290
291private:
292
293 static bool m_Track;
294 static int m_Track_nObjects;
295 static int m_Track_Offset;
296
297 bool m_bModified, m_bUpdate, m_File_bNative;
298
299 int m_RefID, m_File_Type, m_Managed{0};
300
301 sLong m_Max_Samples;
302
303 double m_NoData_Value[2];
304
305 CSG_String m_FileName, m_Name, m_Description;
306
307
308 CSG_MetaData m_MetaData, *m_pMD_Source, *m_pMD_History, *m_pMD_Database;
309
310 CSG_Projection m_Projection;
311
312};
313
314
316// //
318
319//---------------------------------------------------------
322
323
325// //
326// //
327// //
329
330//---------------------------------------------------------
331#endif // #ifndef HEADER_INCLUDED__SAGA_API__dataobject_H
signed long long sLong
Definition api_core.h:158
#define SAGA_API_DLL_EXPORT
Definition api_core.h:94
#define SG_Char
Definition api_core.h:536
#define SG_is_NaN(x)
Definition api_core.h:168
virtual bool is_Modified(void) const
Definition dataobject.h:228
CSG_Data_Object * m_pOwner
Definition dataobject.h:271
int Get_File_Type(void) const
bool is_NoData_Value(double Value) const
Definition dataobject.h:255
virtual bool is_Valid(void) const =0
int Get_RefID(void) const
Returns the object's reference id (unique).
Definition dataobject.h:190
void Set_Update_Flag(bool bOn=true)
Definition dataobject.h:285
friend class CSG_Data_Collection
Definition dataobject.h:181
int Get_Managed(void) const
Definition dataobject.h:192
bool Save_MetaData(const CSG_String &FileName)
double Get_NoData_Value(bool bUpper=false) const
Definition dataobject.h:253
bool Get_Update_Flag(void)
Definition dataobject.h:286
CSG_MetaData & Get_MetaData(void) const
Definition dataobject.h:234
virtual bool Set_NoData_Value_Range(double Lower, double Upper)
const SG_Char * Get_File_Name(bool bNative=true) const
virtual bool Save(const char *File, int Format=0)=0
bool Load_MetaData(const CSG_String &FileName)
virtual bool Destroy(void)
class CSG_PointCloud * asPointCloud(bool bPolymorph=false) const
class CSG_TIN * asTIN(bool bPolymorph=false) const
bool is_File_Native(void) const
Definition dataobject.h:213
virtual bool Save(const CSG_String &File, int Format=0)=0
virtual bool Save(const wchar_t *File, int Format=0)=0
virtual void Set_Modified(bool bOn=true)
Definition dataobject.h:227
class CSG_Shapes * asShapes(bool bPolymorph=false) const
void Set_File_Type(int Type)
Definition dataobject.h:275
CSG_MetaData & Get_History(void)
Definition dataobject.h:236
virtual bool Set_NoData_Value(double Value)
CSG_Data_Object * Get_Owner(void) const
Definition dataobject.h:231
void Set_Owner(CSG_Data_Object *pOwner)
Definition dataobject.h:232
sLong Get_Max_Samples(void) const
Definition dataobject.h:263
virtual bool On_Update(void)
Definition dataobject.h:287
CSG_Projection & Get_Projection(void)
virtual bool On_Delete(void)=0
class CSG_Grids * asGrids(bool bPolymorph=false) const
virtual TSG_Data_Object_Type Get_ObjectType(void) const =0
Returns the object type as defined by TSG_Data_Object_Type. Used for run time type checking.
class CSG_Grid * asGrid(bool bPolymorph=false) const
virtual bool On_Reload(void)=0
CSG_MetaData & Get_MetaData_DB(void) const
Definition dataobject.h:235
void Set_File_Name(const CSG_String &FileName)
virtual const CSG_Rect & Get_Extent(void)=0
bool Delete(void)
Deletes all files associated with this data object if possible. Works only with native SAGA files....
const CSG_MetaData & Get_History(void) const
Definition dataobject.h:237
class CSG_Table * asTable(bool bPolymorph=false) const
bool Reload(void)
If there is an associated file data can be reloaded with this command.
Definition tin.h:222
SAGA_API_DLL_EXPORT bool SG_Data_Object_Delete(CSG_Data_Object *pObject)
SAGA_API_DLL_EXPORT CSG_String SG_Get_DataObject_Class_Name(TSG_Data_Object_Type Type)
TSG_Data_Object_Type
Definition dataobject.h:117
@ SG_DATAOBJECT_TYPE_Undefined
Definition dataobject.h:124
@ SG_DATAOBJECT_TYPE_PointCloud
Definition dataobject.h:123
@ SG_DATAOBJECT_TYPE_Grids
Definition dataobject.h:119
@ SG_DATAOBJECT_TYPE_TIN
Definition dataobject.h:122
@ SG_DATAOBJECT_TYPE_Shapes
Definition dataobject.h:121
@ SG_DATAOBJECT_TYPE_Grid
Definition dataobject.h:118
@ SG_DATAOBJECT_TYPE_Table
Definition dataobject.h:120
SAGA_API_DLL_EXPORT int SG_Get_History_Depth(void)
SAGA_API_DLL_EXPORT CSG_String SG_Get_DataObject_Identifier(TSG_Data_Object_Type Type)
SAGA_API_DLL_EXPORT void SG_Set_History_Depth(int Depth)
SAGA_API_DLL_EXPORT void SG_Set_History_Ignore_Lists(int Ignore)
SAGA_API_DLL_EXPORT sLong SG_DataObject_Get_Max_Samples(void)
SAGA_API_DLL_EXPORT int SG_Get_History_Ignore_Lists(void)
SAGA_API_DLL_EXPORT CSG_String SG_Get_DataObject_Name(TSG_Data_Object_Type Type)
SAGA_API_DLL_EXPORT bool SG_DataObject_Set_Max_Samples(sLong Max_Samples)
SAGA_API_DLL_EXPORT void * SG_Get_Create_Pointer(void)