SAGA API v9.10
Loading...
Searching...
No Matches
tool_chain.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// tool_chain.h //
15// //
16// Copyright (C) 2014 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__tool_chain_H
52#define HEADER_INCLUDED__SAGA_API__tool_chain_H
53
54
56// //
57// //
58// //
60
61//---------------------------------------------------------
62#include "tool_library.h"
63#include "data_manager.h"
64
65
67// //
68// CSG_Tool_Chain //
69// //
71
72//---------------------------------------------------------
76//---------------------------------------------------------
78{
79public:
80 CSG_Tool_Chain(void);
81 virtual ~CSG_Tool_Chain(void);
82
83 CSG_Tool_Chain (const CSG_Tool_Chain &Tool, bool bWithGUI, bool bWithCMD);
84 bool Create (const CSG_Tool_Chain &Tool, bool bWithGUI, bool bWithCMD);
85
86 CSG_Tool_Chain (const CSG_String &File);
87 bool Create (const CSG_String &File);
88
90 bool Create (const CSG_MetaData &Chain);
91
92 virtual TSG_Tool_Type Get_Type (void) const { return( TOOL_TYPE_Chain ); }
93
94 virtual bool do_Sync_Projections (void) const;
95
96 bool is_Okay (void) const { return( m_Chain.Get_Children_Count() > 0 ); }
97
98 void Set_Library_Menu (const CSG_String &Menu);
99 virtual CSG_String Get_MenuPath (void) { return( m_Menu ); }
100 const CSG_String & Get_Library_Name (void) const { return( m_Library_Name ); }
101
102 static CSG_String Get_Script (CSG_Tool *pTool, bool bHeader, bool bAllParameters = true);
103
104 static bool Save_History_to_Model (const CSG_MetaData &History, const CSG_String &File);
105
106
107protected:
108
109 virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter);
110
111 virtual bool On_Execute (void);
112
113
114private:
115
116 bool m_bAddHistory;
117
118 CSG_String m_Library_Name, m_Menu;
119
120 CSG_MetaData m_Chain, m_Conditions;
121
122 CSG_Parameters m_Data;
123
124 CSG_Data_Manager m_Data_Manager;
125
126
127 void Reset (void);
128
129 void Add_References (void);
130
131 bool Data_Add (const CSG_String &ID, CSG_Parameter *pData);
132 bool Data_Add_TempList (const CSG_String &ID, const CSG_String &Type);
133 bool Data_Del_Temp (const CSG_String &ID, bool bData);
134 bool Data_Update (const CSG_String &ID, bool bShow);
135 bool Data_Exists (CSG_Data_Object *pData);
136 bool Data_Initialize (void);
137 bool Data_Finalize (void);
138
139 bool Parameter_isCompatible (TSG_Parameter_Type A, TSG_Parameter_Type B);
140
141 bool Message (const CSG_MetaData &Message);
142 bool Check_Condition (const CSG_MetaData &Condition, CSG_Parameters *pData);
143
144 bool ForEach (const CSG_MetaData &Commands);
145 bool ForEach_Iterator (const CSG_MetaData &Commands, const CSG_String & VarName, bool bIgnoreErrors);
146 bool ForEach_Object (const CSG_MetaData &Commands, const CSG_String &ListVarName, bool bIgnoreErrors);
147 bool ForEach_File (const CSG_MetaData &Commands, const CSG_String &ListVarName, bool bIgnoreErrors);
148
149 bool Tool_Run (const CSG_MetaData &Tool, bool bShowError = true);
150 bool Tool_Check_Condition (const CSG_MetaData &Tool);
151 bool Tool_Get_Parameter (const CSG_String ID, CSG_Parameters *pParameters, CSG_Parameter **ppParameter, CSG_Parameter **ppOwner = NULL);
152 bool Tool_Get_Parameter (const CSG_MetaData &Parameter, CSG_Tool *pTool , CSG_Parameter **ppParameter, CSG_Parameter **ppOwner = NULL);
153 bool Tool_Initialize (const CSG_MetaData &Tool, CSG_Tool *pTool);
154 bool Tool_Finalize (const CSG_MetaData &Tool, CSG_Tool *pTool);
155
156 //-----------------------------------------------------
157 static bool _Get_Script_Tool (CSG_MetaData &Tool , CSG_Parameters *pParameters, bool bAllParameters, const CSG_String &Prefix, bool bVarNames);
158 static bool _Get_Script_Parameters (CSG_MetaData &Parameters, CSG_Parameters *pParameters, const CSG_String &Prefix);
159
160 static bool _Save_History_Add_Tool (const CSG_MetaData &History, CSG_MetaData &Parms, CSG_MetaData &Tools, bool bAddOutput = false);
161 static bool _Save_History_Add_Input (const CSG_MetaData &History, CSG_MetaData &Parms, CSG_MetaData &Tool);
162
163};
164
165
167// //
168// //
169// //
171
172//---------------------------------------------------------
174{
176
177public:
178
179 virtual ESG_Library_Type Get_Type (void) const { return( ESG_Library_Type::Chain ); }
180
181 virtual CSG_String Get_Info (int Type) const;
182
183 bool Add_Tool (CSG_Tool_Chain *pTool);
184
185 virtual int Get_Count (void) const { return( (int)m_Tools.Get_Size() ); }
186
187 virtual CSG_Tool * Get_Tool (int Index, TSG_Tool_Type Type = TOOL_TYPE_Base) const;
188
189 virtual CSG_Tool * Create_Tool (const CSG_String &Name, bool bWithGUI = false, bool bWithCMD = true);
190 virtual bool Delete_Tool (CSG_Tool *pTool);
191 virtual bool Delete_Tools (void);
192
193 virtual CSG_String Get_File_Name (int Index) const { return( Index >= 0 && Index < Get_Count() ? ((CSG_Tool *)m_Tools[Index])->Get_File_Name() : "" ); }
194
195
196protected:
197
198 CSG_Tool_Chains(const CSG_String &Library_Name, const CSG_String &Path);
199 virtual ~CSG_Tool_Chains(void);
200
201
202private:
203
204 CSG_Array_Pointer m_Tools, m_xTools;
205
206 CSG_String m_Name, m_Description, m_Menu;
207
208};
209
210
212// //
213// //
214// //
216
217//---------------------------------------------------------
218#endif // #ifndef HEADER_INCLUDED__SAGA_API__tool_chain_H
#define SAGA_API_DLL_EXPORT
Definition api_core.h:94
virtual TSG_Tool_Type Get_Type(void) const
Definition tool_chain.h:92
bool is_Okay(void) const
Definition tool_chain.h:96
bool Create(const CSG_Tool_Chain &Tool, bool bWithGUI, bool bWithCMD)
virtual CSG_String Get_MenuPath(void)
Definition tool_chain.h:99
const CSG_String & Get_Library_Name(void) const
Definition tool_chain.h:100
friend class CSG_Tool_Library_Manager
Definition tool_chain.h:175
CSG_Tool_Chains(const CSG_String &Library_Name, const CSG_String &Path)
virtual int Get_Count(void) const
Definition tool_chain.h:185
virtual CSG_String Get_File_Name(int Index) const
Definition tool_chain.h:193
virtual ESG_Library_Type Get_Type(void) const
Definition tool_chain.h:179
CSG_String Get_Script(Script_Format Format, bool bHeader=true, int Arguments=0, bool bWrapArgs=true)
Definition tool.cpp:1466
virtual bool On_Execute(void)=0
friend class CSG_Tool_Chain
Definition tool.h:139
virtual bool do_Sync_Projections(void) const
Definition tool.h:216
CSG_Tool(void)
Definition tool.cpp:67
bool Reset(bool bManager=true)
Definition tool.cpp:1355
virtual int On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
Definition tool.cpp:482
#define B
#define A
TSG_Parameter_Type
Definition parameters.h:123
TSG_Tool_Type
Definition tool.h:101
@ TOOL_TYPE_Base
Definition tool.h:102
@ TOOL_TYPE_Chain
Definition tool.h:106
ESG_Library_Type