SAGA API  v9.5
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 {
79 public:
80  CSG_Tool_Chain(void);
81  virtual ~CSG_Tool_Chain(void);
82 
83  CSG_Tool_Chain (const CSG_Tool_Chain &Tool, bool bWithGUI);
84  bool Create (const CSG_Tool_Chain &Tool, bool bWithGUI);
85 
86  CSG_Tool_Chain (const CSG_String &File);
87  bool Create (const CSG_String &File);
88 
89  CSG_Tool_Chain (const CSG_MetaData &Chain);
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 
107 protected:
108 
109  virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter);
110 
111  virtual bool On_Execute (void);
112 
113 
114 private:
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 
177 public:
178 
179  virtual TSG_Tool_Library_Type Get_Type (void) const { return( TOOL_CHAINS ); }
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);
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 
196 protected:
197 
198  CSG_Tool_Chains(const CSG_String &Library_Name, const CSG_String &Path);
199  virtual ~CSG_Tool_Chains(void);
200 
201 
202 private:
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
CSG_Tool_Chains
Definition: tool_chain.h:174
CSG_Tool_Chains::Add_Tool
bool Add_Tool(CSG_Tool_Chain *pTool)
TSG_Tool_Library_Type
TSG_Tool_Library_Type
Definition: tool_library.h:92
CSG_Tool_Chain::Get_Script
static CSG_String Get_Script(CSG_Tool *pTool, bool bHeader, bool bAllParameters=true)
TOOL_TYPE_Chain
@ TOOL_TYPE_Chain
Definition: tool.h:106
CSG_Tool_Chains::CSG_Tool_Chains
CSG_Tool_Chains(const CSG_String &Library_Name, const CSG_String &Path)
A
#define A
CSG_Tool_Library
Definition: tool_library.h:107
data_manager.h
CSG_Tool_Chains::Get_Info
virtual CSG_String Get_Info(int Type) const
CSG_Tool_Chain::do_Sync_Projections
virtual bool do_Sync_Projections(void) const
CSG_Tool_Chain::On_Parameters_Enable
virtual int On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
CSG_Tool::Reset
bool Reset(bool bManager=true)
Definition: tool.cpp:1211
CSG_Tool
Definition: tool.h:151
TSG_Tool_Type
TSG_Tool_Type
Definition: tool.h:101
CSG_Tool_Chain::Get_Type
virtual TSG_Tool_Type Get_Type(void) const
Definition: tool_chain.h:92
CSG_Tool_Chain::On_Execute
virtual bool On_Execute(void)
CSG_Tool_Chain::Get_Library_Name
const CSG_String & Get_Library_Name(void) const
Definition: tool_chain.h:100
CSG_Tool_Chains::Delete_Tools
virtual bool Delete_Tools(void)
CSG_Data_Object
Definition: dataobject.h:180
CSG_Parameter
Definition: parameters.h:207
CSG_Tool_Chains::Create_Tool
virtual CSG_Tool * Create_Tool(const CSG_String &Name, bool bWithGUI=false)
CSG_Tool_Library::Get_Count
virtual int Get_Count(void) const
Definition: tool_library.h:130
CSG_Tool_Chains::Get_File_Name
virtual CSG_String Get_File_Name(int Index) const
Definition: tool_chain.h:193
SAGA_API_DLL_EXPORT
#define SAGA_API_DLL_EXPORT
Definition: api_core.h:94
TOOL_CHAINS
@ TOOL_CHAINS
Definition: tool_library.h:94
CSG_Tool_Chains::Delete_Tool
virtual bool Delete_Tool(CSG_Tool *pTool)
CSG_Tool_Chain::Save_History_to_Model
static bool Save_History_to_Model(const CSG_MetaData &History, const CSG_String &File)
CSG_Tool_Chain
Definition: tool_chain.h:78
CSG_Tool_Chain::Get_MenuPath
virtual CSG_String Get_MenuPath(void)
Definition: tool_chain.h:99
B
#define B
CSG_String
Definition: api_core.h:563
CSG_Array_Pointer
Definition: api_core.h:368
CSG_Data_Manager
Definition: data_manager.h:129
CSG_MetaData
Definition: metadata.h:88
CSG_Tool_Chain::is_Okay
bool is_Okay(void) const
Definition: tool_chain.h:96
CSG_Tool::CSG_Tool_Chain
friend class CSG_Tool_Chain
Definition: tool.h:154
TOOL_TYPE_Base
@ TOOL_TYPE_Base
Definition: tool.h:102
CSG_Tool_Chains::Get_Tool
virtual CSG_Tool * Get_Tool(int Index, TSG_Tool_Type Type=TOOL_TYPE_Base) const
tool_library.h
CSG_Tool_Chains::~CSG_Tool_Chains
virtual ~CSG_Tool_Chains(void)
CSG_Parameters
Definition: parameters.h:1690
CSG_Tool_Chains::Get_Type
virtual TSG_Tool_Library_Type Get_Type(void) const
Definition: tool_chain.h:179
CSG_Tool_Chains::Get_Count
virtual int Get_Count(void) const
Definition: tool_chain.h:185
TSG_Parameter_Type
TSG_Parameter_Type
Definition: parameters.h:122
CSG_Tool_Library_Manager
Definition: tool_library.h:186