1 2 /////////////////////////////////////////////////////////// 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 // // 48 /////////////////////////////////////////////////////////// 49 50 //--------------------------------------------------------- 51 #ifndef HEADER_INCLUDED__SAGA_API__data_manager_H 52 #define HEADER_INCLUDED__SAGA_API__data_manager_H 53 54 55 /////////////////////////////////////////////////////////// 56 // // 57 // // 58 // // 59 /////////////////////////////////////////////////////////// 60 61 //--------------------------------------------------------- 62 /** \file data_manager.h 63 * Classes for data object management and declaration of the 64 * SAGA API's default data manager. 65 * @see SG_Get_Data_Manager 66 * @see CSG_Data_Manager 67 * @see CSG_Data_Object 68 */ 69 70 71 /////////////////////////////////////////////////////////// 72 // // 73 // // 74 // // 75 /////////////////////////////////////////////////////////// 76 77 //--------------------------------------------------------- 78 #include "parameters.h" 79 80 81 /////////////////////////////////////////////////////////// 82 // // 83 // // 84 // // 85 /////////////////////////////////////////////////////////// 86 87 //--------------------------------------------------------- 88 class SAGA_API_DLL_EXPORT CSG_Data_Collection 89 { 90 friend class CSG_Data_Manager; 91 92 public: 93 Count(void)94 size_t Count (void) const { return( m_Objects.Get_Size() ); } 95 Get(size_t i)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 104 CSG_Data_Collection(class CSG_Data_Manager *pManager, TSG_Data_Object_Type Type); 105 virtual ~CSG_Data_Collection(void); 106 107 virtual bool Add (CSG_Data_Object *pObject); 108 bool Delete (CSG_Data_Object *pObject, bool bDetachOnly = false); 109 bool Delete (size_t i , bool bDetachOnly = false); 110 bool Delete_All ( bool bDetachOnly = false); 111 bool Delete_Unsaved ( bool bDetachOnly = false); 112 113 114 class CSG_Data_Manager *m_pManager; 115 116 TSG_Data_Object_Type m_Type; 117 118 CSG_Array_Pointer m_Objects; 119 120 }; 121 122 123 /////////////////////////////////////////////////////////// 124 // // 125 /////////////////////////////////////////////////////////// 126 127 //--------------------------------------------------------- 128 class SAGA_API_DLL_EXPORT CSG_Grid_Collection : public CSG_Data_Collection 129 { 130 friend class CSG_Data_Manager; 131 132 public: 133 134 virtual bool Exists (CSG_Data_Object *pObject) const; 135 Get_System(void)136 const CSG_Grid_System & Get_System (void) const { return( m_System ); } 137 is_Equal(const CSG_Grid_System & System)138 bool is_Equal (const CSG_Grid_System &System) const 139 { 140 return( Count() > 0 && m_System.is_Equal(System) ); 141 } 142 143 144 protected: 145 146 CSG_Grid_Collection(class CSG_Data_Manager *pManager); 147 148 virtual bool Add (CSG_Data_Object *pObject); 149 150 151 CSG_Grid_System m_System; 152 153 }; 154 155 156 /////////////////////////////////////////////////////////// 157 // // 158 /////////////////////////////////////////////////////////// 159 160 //--------------------------------------------------------- 161 class SAGA_API_DLL_EXPORT CSG_Data_Manager 162 { 163 public: 164 CSG_Data_Manager(void); 165 virtual ~CSG_Data_Manager(void); 166 Get_Table(void)167 CSG_Data_Collection * Get_Table (void) const { return( m_pTable ); } asTIN(void)168 CSG_Data_Collection * asTIN (void) const { return( m_pTIN ); } Get_Point_Cloud(void)169 CSG_Data_Collection * Get_Point_Cloud (void) const { return( m_pPoint_Cloud ); } Get_Shapes(void)170 CSG_Data_Collection * Get_Shapes (void) const { return( m_pShapes ); } 171 Grid_System_Count(void)172 size_t Grid_System_Count (void) const { return( m_Grid_Systems.Get_Size() ); } Get_Grid_System(size_t i)173 CSG_Grid_Collection * Get_Grid_System (size_t i) const { return( i < Grid_System_Count() ? (CSG_Grid_Collection *)m_Grid_Systems[i] : NULL ); } 174 CSG_Grid_Collection * Get_Grid_System (const CSG_Grid_System &System) const; 175 176 bool Add (CSG_Data_Object *pObject); 177 CSG_Data_Object * Add (const CSG_String &File, TSG_Data_Object_Type Type = SG_DATAOBJECT_TYPE_Undefined); 178 CSG_Data_Object * Add (const char *File, TSG_Data_Object_Type Type = SG_DATAOBJECT_TYPE_Undefined) { return( Add(CSG_String(File), Type) ); } 179 CSG_Data_Object * Add (const wchar_t *File, TSG_Data_Object_Type Type = SG_DATAOBJECT_TYPE_Undefined) { return( Add(CSG_String(File), Type) ); } 180 Add_Table(const CSG_String & File)181 CSG_Table * Add_Table (const CSG_String &File) { return( (CSG_Table *)Add(File, SG_DATAOBJECT_TYPE_Table ) ); } Add_Table(const char * File)182 CSG_Table * Add_Table (const char *File) { return( (CSG_Table *)Add(File, SG_DATAOBJECT_TYPE_Table ) ); } Add_Table(const wchar_t * File)183 CSG_Table * Add_Table (const wchar_t *File) { return( (CSG_Table *)Add(File, SG_DATAOBJECT_TYPE_Table ) ); } Add_TIN(const CSG_String & File)184 CSG_TIN * Add_TIN (const CSG_String &File) { return( (CSG_TIN *)Add(File, SG_DATAOBJECT_TYPE_TIN ) ); } Add_TIN(const char * File)185 CSG_TIN * Add_TIN (const char *File) { return( (CSG_TIN *)Add(File, SG_DATAOBJECT_TYPE_TIN ) ); } Add_TIN(const wchar_t * File)186 CSG_TIN * Add_TIN (const wchar_t *File) { return( (CSG_TIN *)Add(File, SG_DATAOBJECT_TYPE_TIN ) ); } Add_PointCloud(const CSG_String & File)187 CSG_PointCloud * Add_PointCloud (const CSG_String &File) { return( (CSG_PointCloud *)Add(File, SG_DATAOBJECT_TYPE_PointCloud) ); } Add_PointCloud(const char * File)188 CSG_PointCloud * Add_PointCloud (const char *File) { return( (CSG_PointCloud *)Add(File, SG_DATAOBJECT_TYPE_PointCloud) ); } Add_PointCloud(const wchar_t * File)189 CSG_PointCloud * Add_PointCloud (const wchar_t *File) { return( (CSG_PointCloud *)Add(File, SG_DATAOBJECT_TYPE_PointCloud) ); } Add_Shapes(const CSG_String & File)190 CSG_Shapes * Add_Shapes (const CSG_String &File) { return( (CSG_Shapes *)Add(File, SG_DATAOBJECT_TYPE_Shapes ) ); } Add_Shapes(const char * File)191 CSG_Shapes * Add_Shapes (const char *File) { return( (CSG_Shapes *)Add(File, SG_DATAOBJECT_TYPE_Shapes ) ); } Add_Shapes(const wchar_t * File)192 CSG_Shapes * Add_Shapes (const wchar_t *File) { return( (CSG_Shapes *)Add(File, SG_DATAOBJECT_TYPE_Shapes ) ); } Add_Grid(const CSG_String & File)193 CSG_Grid * Add_Grid (const CSG_String &File) { return( (CSG_Grid *)Add(File, SG_DATAOBJECT_TYPE_Grid ) ); } Add_Grid(const char * File)194 CSG_Grid * Add_Grid (const char *File) { return( (CSG_Grid *)Add(File, SG_DATAOBJECT_TYPE_Grid ) ); } Add_Grid(const wchar_t * File)195 CSG_Grid * Add_Grid (const wchar_t *File) { return( (CSG_Grid *)Add(File, SG_DATAOBJECT_TYPE_Grid ) ); } Add_Grids(const CSG_String & File)196 CSG_Grids * Add_Grids (const CSG_String &File) { return( (CSG_Grids *)Add(File, SG_DATAOBJECT_TYPE_Grids ) ); } Add_Grids(const char * File)197 CSG_Grids * Add_Grids (const char *File) { return( (CSG_Grids *)Add(File, SG_DATAOBJECT_TYPE_Grids ) ); } Add_Grids(const wchar_t * File)198 CSG_Grids * Add_Grids (const wchar_t *File) { return( (CSG_Grids *)Add(File, SG_DATAOBJECT_TYPE_Grids ) ); } 199 200 CSG_Table * Add_Table (void); 201 CSG_TIN * Add_TIN (void); 202 CSG_PointCloud * Add_PointCloud (void); 203 CSG_Shapes * Add_Shapes (TSG_Shape_Type Type = SHAPE_TYPE_Undefined); 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.0, double xMin = 0.0, double yMin = 0.0, TSG_Data_Type Type = SG_DATATYPE_Undefined); 206 207 bool Delete (CSG_Data_Collection *pCollection, bool bDetachOnly = false); 208 bool Delete (CSG_Data_Object *pObject , bool bDetachOnly = false); 209 bool Delete (const CSG_Grid_System &System , bool bDetachOnly = false); 210 bool Delete_All ( bool bDetachOnly = false); 211 bool Delete_Unsaved ( bool bDetachOnly = false); 212 213 bool Exists (CSG_Data_Object *pObject) const; 214 bool Exists (const CSG_Grid_System &System) const; 215 216 CSG_Data_Object * Find (const CSG_String &File, bool bNative = true) const; 217 218 CSG_String Get_Summary (void) const; 219 220 221 private: 222 223 CSG_Array_Pointer m_Grid_Systems; 224 225 CSG_Data_Collection *m_pTable, *m_pTIN, *m_pPoint_Cloud, *m_pShapes; 226 227 228 CSG_Data_Collection * _Get_Collection (CSG_Data_Object *pObject) const; 229 230 CSG_Data_Object * _Add_External (const CSG_String &File); 231 232 }; 233 234 //--------------------------------------------------------- 235 SAGA_API_DLL_EXPORT CSG_Data_Manager & SG_Get_Data_Manager (void); 236 237 238 /////////////////////////////////////////////////////////// 239 // // 240 // // 241 // // 242 /////////////////////////////////////////////////////////// 243 244 //--------------------------------------------------------- 245 #endif // #ifndef HEADER_INCLUDED__SAGA_API__data_manager_H 246