SAGA API  v9.6
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 //---------------------------------------------------------
71 // //
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 //---------------------------------------------------------
116 typedef enum
117 {
125 }
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 {
181  friend class CSG_Data_Collection;
182 
183 public:
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);
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 
241  CSG_Projection & Get_Projection (void);
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 
269 protected:
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 
291 private:
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
CSG_Rect
Definition: geo_tools.h:471
SG_Get_DataObject_Identifier
SAGA_API_DLL_EXPORT CSG_String SG_Get_DataObject_Identifier(TSG_Data_Object_Type Type)
Definition: dataobject.cpp:71
SG_Get_History_Ignore_Lists
SAGA_API_DLL_EXPORT int SG_Get_History_Ignore_Lists(void)
Definition: dataobject.cpp:172
CSG_Data_Object::Get_Max_Samples
sLong Get_Max_Samples(void) const
Definition: dataobject.h:263
CSG_Data_Object::m_pOwner
CSG_Data_Object * m_pOwner
Definition: dataobject.h:271
SG_DataObject_Set_Max_Samples
SAGA_API_DLL_EXPORT bool SG_DataObject_Set_Max_Samples(sLong Max_Samples)
Definition: dataobject.cpp:126
CSG_Data_Object::On_Reload
virtual bool On_Reload(void)=0
CSG_Data_Object::Set_File_Name
void Set_File_Name(const CSG_String &FileName)
Definition: dataobject.cpp:366
CSG_Data_Object::On_Delete
virtual bool On_Delete(void)=0
CSG_Data_Object::Get_History
CSG_MetaData & Get_History(void)
Definition: dataobject.h:236
CSG_Data_Object::Get_Managed
int Get_Managed(void) const
Definition: dataobject.h:192
CSG_Data_Object::Get_NoData_Value
double Get_NoData_Value(bool bUpper=false) const
Definition: dataobject.h:253
CSG_Data_Object::Save_MetaData
bool Save_MetaData(const CSG_String &FileName)
Definition: dataobject.cpp:677
CSG_Data_Object::Save
virtual bool Save(const wchar_t *File, int Format=0)=0
CSG_Data_Object::is_NoData_Value
bool is_NoData_Value(double Value) const
Definition: dataobject.h:255
SG_Get_DataObject_Class_Name
SAGA_API_DLL_EXPORT CSG_String SG_Get_DataObject_Class_Name(TSG_Data_Object_Type Type)
Definition: dataobject.cpp:101
CSG_Data_Object::Save
virtual bool Save(const CSG_String &File, int Format=0)=0
CSG_Data_Collection
Definition: data_manager.h:89
SG_DATAOBJECT_TYPE_Grids
@ SG_DATAOBJECT_TYPE_Grids
Definition: dataobject.h:119
CSG_Data_Object::asTIN
class CSG_TIN * asTIN(bool bPolymorph=false) const
Definition: dataobject.cpp:528
CSG_Data_Object::Get_ObjectType
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.
SG_Get_Create_Pointer
SAGA_API_DLL_EXPORT void * SG_Get_Create_Pointer(void)
Definition: dataobject.cpp:65
SG_Data_Object_Delete
SAGA_API_DLL_EXPORT bool SG_Data_Object_Delete(CSG_Data_Object *pObject)
Definition: dataobject.cpp:185
CSG_Data_Object::Set_Update_Flag
void Set_Update_Flag(bool bOn=true)
Definition: dataobject.h:285
CSG_File
Definition: api_core.h:1124
SG_Set_History_Depth
SAGA_API_DLL_EXPORT void SG_Set_History_Depth(int Depth)
Definition: dataobject.cpp:154
CSG_Data_Object::Get_Owner
CSG_Data_Object * Get_Owner(void) const
Definition: dataobject.h:231
CSG_Grids::Set_Max_Samples
virtual bool Set_Max_Samples(sLong Max_Samples)
Definition: grids.cpp:1559
mat_tools.h
CSG_Data_Object::asShapes
class CSG_Shapes * asShapes(bool bPolymorph=false) const
Definition: dataobject.cpp:509
SG_Get_History_Depth
SAGA_API_DLL_EXPORT int SG_Get_History_Depth(void)
Definition: dataobject.cpp:159
CSG_TIN
Definition: tin.h:222
CSG_Data_Object
Definition: dataobject.h:180
CSG_Data_Object::On_NoData_Changed
virtual bool On_NoData_Changed(void)
Definition: dataobject.cpp:601
CSG_Data_Object::asGrids
class CSG_Grids * asGrids(bool bPolymorph=false) const
Definition: dataobject.cpp:561
CSG_Data_Object::Get_Extent
virtual const CSG_Rect & Get_Extent(void)=0
sLong
signed long long sLong
Definition: api_core.h:158
CSG_Data_Object::On_Update
virtual bool On_Update(void)
Definition: dataobject.h:287
CSG_Data_Object::is_Modified
virtual bool is_Modified(void) const
Definition: dataobject.h:228
CSG_Data_Object::Set_File_Type
void Set_File_Type(int Type)
Definition: dataobject.h:275
SG_is_NaN
#define SG_is_NaN(x)
Definition: api_core.h:168
SAGA_API_DLL_EXPORT
#define SAGA_API_DLL_EXPORT
Definition: api_core.h:94
CSG_Data_Object::Set_Modified
virtual void Set_Modified(bool bOn=true)
Definition: dataobject.h:227
SG_DATAOBJECT_TYPE_TIN
@ SG_DATAOBJECT_TYPE_TIN
Definition: dataobject.h:122
CSG_Data_Object::asTable
class CSG_Table * asTable(bool bPolymorph=false) const
Definition: dataobject.cpp:487
SG_DATAOBJECT_TYPE_Grid
@ SG_DATAOBJECT_TYPE_Grid
Definition: dataobject.h:118
CSG_Projection
Definition: geo_tools.h:824
CSG_Data_Object::Get_RefID
int Get_RefID(void) const
Returns the object's reference id (unique).
Definition: dataobject.h:190
CSG_Table
Definition: table.h:283
SG_DATAOBJECT_TYPE_Shapes
@ SG_DATAOBJECT_TYPE_Shapes
Definition: dataobject.h:121
CSG_Data_Object::is_File_Native
bool is_File_Native(void) const
Definition: dataobject.h:213
CSG_Data_Object::Get_Update_Flag
bool Get_Update_Flag(void)
Definition: dataobject.h:286
CSG_Data_Object::Get_History
const CSG_MetaData & Get_History(void) const
Definition: dataobject.h:237
SG_DATAOBJECT_TYPE_Undefined
@ SG_DATAOBJECT_TYPE_Undefined
Definition: dataobject.h:124
SG_Char
#define SG_Char
Definition: api_core.h:536
TSG_Data_Object_Type
TSG_Data_Object_Type
Definition: dataobject.h:117
CSG_String
Definition: api_core.h:563
CSG_Data_Object::asGrid
class CSG_Grid * asGrid(bool bPolymorph=false) const
Definition: dataobject.cpp:550
SG_DATAOBJECT_TYPE_Table
@ SG_DATAOBJECT_TYPE_Table
Definition: dataobject.h:120
CSG_Data_Object::Save
virtual bool Save(const char *File, int Format=0)=0
CSG_MetaData
Definition: metadata.h:88
CSG_Data_Object::Save_History_to_Model
bool Save_History_to_Model(const CSG_String &File) const
Definition: dataobject.cpp:819
CSG_Data_Object::Get_MetaData_DB
CSG_MetaData & Get_MetaData_DB(void) const
Definition: dataobject.h:235
metadata.h
CSG_Data_Object::Get_MetaData
CSG_MetaData & Get_MetaData(void) const
Definition: dataobject.h:234
SG_Get_DataObject_Name
SAGA_API_DLL_EXPORT CSG_String SG_Get_DataObject_Name(TSG_Data_Object_Type Type)
Definition: dataobject.cpp:86
CSG_Data_Object::Load_MetaData
bool Load_MetaData(const CSG_String &FileName)
Definition: dataobject.cpp:654
CSG_Data_Object::asPointCloud
class CSG_PointCloud * asPointCloud(bool bPolymorph=false) const
Definition: dataobject.cpp:539
CSG_Data_Object::Set_Owner
void Set_Owner(CSG_Data_Object *pOwner)
Definition: dataobject.h:232
CSG_Grid
Definition: grid.h:475
CSG_Data_Object::Track
static void Track(bool Track=true, bool Offset=false)
Activate/deactivate lifetime tracking (data object construction/destruction). Needs compiler flag WIT...
Definition: dataobject.cpp:267
CSG_Data_Object::Set_NoData_Value
virtual bool Set_NoData_Value(double Value)
Definition: dataobject.cpp:572
CSG_Shapes
Definition: shapes.h:775
CSG_Grids::Set_NoData_Value_Range
virtual bool Set_NoData_Value_Range(double loValue, double hiValue)
Definition: grids.cpp:393
CSG_PointCloud
Definition: pointcloud.h:105
SG_DataObject_Get_Max_Samples
SAGA_API_DLL_EXPORT sLong SG_DataObject_Get_Max_Samples(void)
Definition: dataobject.cpp:139
CSG_Grids
Definition: grids.h:119
CSG_Data_Collection::Delete
bool Delete(CSG_Data_Object *pObject, bool bDetach=false)
Definition: data_manager.cpp:141
SG_Set_History_Ignore_Lists
SAGA_API_DLL_EXPORT void SG_Set_History_Ignore_Lists(int Ignore)
Definition: dataobject.cpp:167
SG_DATAOBJECT_TYPE_PointCloud
@ SG_DATAOBJECT_TYPE_PointCloud
Definition: dataobject.h:123
CSG_Data_Object::is_Valid
virtual bool is_Valid(void) const =0