Isis Developer Reference
PipelineApplication.h
Go to the documentation of this file.
1 #ifndef PipelineApplication_h
2 #define PipelineApplication_h
3 
8 /* SPDX-License-Identifier: CC0-1.0 */
9 
10 #include <vector>
11 
12 #include <QString>
13 
14 #include "IException.h"
15 
16 namespace Isis {
17  class Pipeline;
18  class PipelineParameter;
19 
47  public:
48  PipelineApplication(QString appName, Pipeline *pipe);
49  PipelineApplication(QString appName, PipelineApplication *previous);
50 
53 
61  };
62 
70  // Implies branches will be merged if this is set as an input parameter.
73  // Implies branches will NOT be merged if this is set as an input parameter.
75  };
76 
78  const QString &Name() const {
79  return p_name;
80  }
82  const std::vector<QString> &ParamString() const {
83  return p_paramString;
84  }
86  const std::vector<QString> &InputBranches() const {
87  return p_inBranches;
88  }
90  const std::vector<QString> &OutputBranches() const {
91  if(!Enabled() && Previous()) {
92  return Previous()->OutputBranches();
93  }
94  else if(Enabled()) {
95  return p_outBranches;
96  }
97  else {
98  return p_inBranches;
99  }
100  }
101 
103  void Enable() {
104  p_enabled = true;
105  };
106 
108  void Disable() {
109  p_enabled = false;
110  };
111 
113  const bool &Enabled() const {
114  return p_enabled;
115  }
116 
117  void SetInputParameter(const QString &inputParamName, bool supportsVirtualBands);
118  void SetInputParameter(const QString &inputParamName, CustomParameterValue value, bool supportsVirtualBands);
119 
120  void SetOutputParameter(const QString &outputParamName, const QString &outNameModifier, const QString &outFileExtension = "cub");
121  void SetOutputParameter(const QString &branch, const QString &outputParamName,
122  const QString &outNameModifier, const QString &outFileExtension);
123 
124  void AddBranch(const QString &modString, NameModifierType type);
125 
126  void AddParameter(const QString &inputParamName, const QString &appParamName);
127  void AddParameter(const QString &branch, const QString &inputParamName, const QString &appParamName);
128 
129  void AddConstParameter(const QString &appParamName, const QString &appParamValue);
130  void AddConstParameter(const QString &branch, const QString &appParamName, const QString &appParamValue);
131 
132  void AddParameter(const QString &appParamName, CustomParameterValue value);
133  void AddParameter(const QString &branch, const QString &appParamName, CustomParameterValue value);
134 
136  QString OutputNameModifier() {
137  return (!p_outputMod.isEmpty() || !Previous()) ? p_outputMod : Previous()->OutputNameModifier();
138  }
140  QString OutputExtension() {
141  return (!p_outputExtension.isEmpty() || !Previous()) ? p_outputExtension : Previous()->OutputExtension();
142  }
144  std::vector<QString> &GetOutputs();
145 
146  std::vector<QString> TemporaryFiles();
147 
154  p_next = next;
155  }
156 
157 
164  p_previous = prev;
165  }
166 
167  void BuildParamString();
168 
171  if(p_next == NULL) return p_next;
172  if(!p_next->Enabled()) return p_next->Next();
173  return p_next;
174  }
175 
178  if(p_previous == NULL) return p_previous;
179  if(!p_previous->Enabled()) return p_previous->Previous();
180  return p_previous;
181  }
182 
185  if(p_previous == NULL) return p_previous;
186  if(!p_previous->Enabled()) return p_previous->Previous();
187  if(p_previous->p_output.empty()) return p_previous->Previous();
188  return p_previous;
189  }
190 
191  bool SupportsVirtualBands();
192  void SetVirtualBands(std::vector<QString> bands);
193 
202  void EnableBranch(QString branch, bool flag) {
203  for(int i=0; i<(int)p_inBranches.size(); i++) {
204  if (p_inBranches[i].contains(branch))
205  p_enableBranch[i] = flag;
206  }
207  }
208 
218  bool BranchEnabled(int branch){
219  if (branch >= 0 && branch >= (int)p_enableBranch.size())
220  return false;
221  return p_enableBranch[branch] ;
222  }
223 
231  void SetContinue(bool pbFlag){
232  p_continue = pbFlag;
233  };
234 
242  bool Continue(void) {
243  return p_continue;
244  };
245 
246  private:
247  bool FutureOutputFileCreated();
248  bool LastApplicationWithOutput();
250  Pipeline *GetPipeline() {
251  return p_pipeline;
252  }
253 
255  bool Branches() {
256  if(p_inBranches.size() >= p_outBranches.size()) return false;
257  return true;
258  }
259 
261  bool Merges() {
262  if(p_inBranches.size() == 1) return false;
263  if(p_outBranches.size() == 1) return true;
264  return false;
265  }
266 
273  bool StringStartsWith(QString from, QString compare) {
274  if(compare.size() > from.size()) return false;
275 
276  for(int index = 0; index < compare.size(); index++)
277  if(from[index] != compare[index]) return false;
278 
279  return true;
280  }
281 
282  QString CalculateInputFile(int branch);
283  QString CalculateOutputFile(int branch);
284  QString GetRealLastOutput(bool skipOne = false);
285  PipelineParameter &GetInputParameter(int branch);
286 
287  int FindBranch(QString name, bool input = true);
288 
289  bool p_continue;
290  bool p_enabled;
291  bool p_supportsVirtualBands;
292  QString p_name;
293  std::vector<QString> p_outputs;
294  std::vector<QString> p_tempFiles;
295  std::vector<QString> p_paramString;
296  std::vector<QString> p_inBranches;
297  std::vector<QString> p_outBranches;
298  std::vector<bool> p_enableBranch;
299 
300  std::vector<PipelineParameter> p_output;
301  QString p_outputMod;
302  QString p_outputExtension;
303  std::vector<QString> p_virtualBands;
304 
305  std::vector<PipelineParameter> p_input;
306  std::vector<PipelineParameter> p_params;
307 
308  PipelineApplication *p_previous;
309  PipelineApplication *p_next;
310  Pipeline *p_pipeline;
311  };
312 
324  public:
331  PipelineParameter(QString paramName) {
332  p_paramName = paramName;
334  p_branch = -1;
335  }
336 
337 
345  PipelineParameter(QString paramName, QString value) {
346  p_paramName = paramName;
347  p_paramValue = value;
349  p_branch = -1;
350  }
351 
352 
360  PipelineParameter(int branch, QString paramName) {
361  p_branch = branch;
362  p_paramName = paramName;
364  }
365 
366 
375  PipelineParameter(int branch, QString paramName, QString paramValue) {
376  p_branch = branch;
377  p_paramValue = paramValue;
378  p_paramName = paramName;
380  }
381 
382 
391  p_paramName = paramName;
392  p_special = special;
393  p_branch = -1;
394  }
395 
396 
405  PipelineParameter(int branch, QString paramName, PipelineApplication::CustomParameterValue special) {
406  p_paramName = paramName;
407  p_special = special;
408  p_branch = branch;
409  }
410 
411 
419  bool AppliesToBranch(int branch) {
420  return (p_branch == -1 || p_branch == branch);
421  }
422 
424  QString Name() {
425  return p_paramName;
426  }
428  QString Value() {
429  return p_paramValue;
430  }
432  bool IsSpecial() {
433  return (p_special != (PipelineApplication::CustomParameterValue) - 1);
434  };
437  return p_special;
438  }
441  return p_branch == -1;
442  }
443 
444  private:
445  int p_branch;
446  QString p_paramName;
447  QString p_paramValue;
449  };
450 };
451 #endif
Isis::PipelineApplication::SetNext
void SetNext(PipelineApplication *next)
Link to the next application in the pipeline.
Definition: PipelineApplication.h:153
Isis::PipelineApplication
This class represents one application in the pipeline.
Definition: PipelineApplication.h:46
Isis::PipelineParameter::AffectsAllBranches
bool AffectsAllBranches()
True if branch-independant.
Definition: PipelineApplication.h:440
Isis::PipelineApplication::ConstantStrings
@ ConstantStrings
Known strings.
Definition: PipelineApplication.h:60
IsisAml::GetAsString
QString GetAsString(const QString &paramName) const
Allows the retrieval of a value for a parameter of any type.
Definition: IsisAml.cpp:537
Isis::PipelineParameter::AppliesToBranch
bool AppliesToBranch(int branch)
Returns whether or not the specified branch is affected.
Definition: PipelineApplication.h:419
Isis::PipelineApplication::Continue
bool Continue(void)
Get the continue flag status.
Definition: PipelineApplication.h:242
Isis::FileName
File name manipulation and expansion.
Definition: FileName.h:100
Isis::PipelineParameter::Name
QString Name()
Name of the parameter.
Definition: PipelineApplication.h:424
Isis::PipelineApplication::CustomParameterValue
CustomParameterValue
This is used to set custom values that must be calculated on the fly.
Definition: PipelineApplication.h:66
PipelineApplication.h
Isis::PipelineApplication::SetContinue
void SetContinue(bool pbFlag)
Set the continue flag status.
Definition: PipelineApplication.h:231
Isis::PipelineApplication::Previous
PipelineApplication * Previous() const
This returns the last enabled pipeline application or null.
Definition: PipelineApplication.h:177
Isis::PipelineApplication::AddConstParameter
void AddConstParameter(const QString &appParamName, const QString &appParamValue)
This method adds a parameter to this application with a known value (does not get it from the user in...
Definition: PipelineApplication.cpp:244
Isis::PipelineApplication::PreviousOutputer
PipelineApplication * PreviousOutputer() const
This returns the previous enabled pipeline application that makes output or null.
Definition: PipelineApplication.h:184
Pipeline.h
Isis::PipelineApplication::LastAppOutputList
@ LastAppOutputList
A list of files from the last run application's output.
Definition: PipelineApplication.h:71
Isis::PipelineApplication::TemporaryFiles
std::vector< QString > TemporaryFiles()
This method returns a list of the temporary files generated by this program.
Definition: PipelineApplication.cpp:799
Isis::PipelineApplication::LastAppOutputListNoMerge
@ LastAppOutputListNoMerge
A list of files from the last run application's output.
Definition: PipelineApplication.h:74
Isis::PipelineApplication::OutputExtension
QString OutputExtension()
This returns this application's output file name's extension.
Definition: PipelineApplication.h:140
Isis::PipelineParameter::Value
QString Value()
Non-special value of the parameter.
Definition: PipelineApplication.h:428
Isis::PipelineParameter::PipelineParameter
PipelineParameter(int branch, QString paramName)
Construct the parameter with only a parameter name; affects only the specified branch and is not a sp...
Definition: PipelineApplication.h:360
Isis::IsSpecial
bool IsSpecial(const double d)
Returns if the input pixel is special.
Definition: SpecialPixel.h:197
Isis::PipelineParameter::PipelineParameter
PipelineParameter(QString paramName, PipelineApplication::CustomParameterValue special)
Construct the parameter with a parameter name and special value; affects all branches.
Definition: PipelineApplication.h:390
Isis::PipelineApplication::SetOutputParameter
void SetOutputParameter(const QString &outputParamName, const QString &outNameModifier, const QString &outFileExtension="cub")
Set the output parameter for this application and it's naming convention.
Definition: PipelineApplication.cpp:137
Isis::PipelineApplication::BuildParamString
void BuildParamString()
This method calculates the inputs, outputs and necessary calls to this program for the pipeline.
Definition: PipelineApplication.cpp:308
Isis::PipelineParameter
This class represents a parameter of some type for the PipelineApplication.
Definition: PipelineApplication.h:323
Isis::PipelineApplication::SetPrevious
void SetPrevious(PipelineApplication *prev)
Link to the previous application in the pipeline.
Definition: PipelineApplication.h:163
Isis::PipelineParameter::IsSpecial
bool IsSpecial()
True if the parameter value is special.
Definition: PipelineApplication.h:432
Isis::PipelineApplication::PipelineApplication
PipelineApplication(QString appName, Pipeline *pipe)
Constructs the first pipeline application.
Definition: PipelineApplication.cpp:25
Isis::FileName::baseName
QString baseName() const
Returns the name of the file without the path and without extensions.
Definition: FileName.cpp:145
Isis::Application::GetUserInterface
static UserInterface & GetUserInterface()
Returns the UserInterface object.
Definition: Application.cpp:463
Isis::Pipeline::OriginalBranches
std::vector< QString > OriginalBranches()
Returns the names of the original branches of the pipeline (input files * branches if any)
Definition: Pipeline.h:233
Isis::PipelineApplication::AddBranch
void AddBranch(const QString &modString, NameModifierType type)
This method adds branch to this program.
Definition: PipelineApplication.cpp:163
Isis::PipelineApplication::BranchEnabled
bool BranchEnabled(int branch)
Check whether a branch is enabled given branch index.
Definition: PipelineApplication.h:218
Isis::PipelineApplication::Name
const QString & Name() const
Get the name of this pipeline application.
Definition: PipelineApplication.h:78
_FILEINFO_
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:24
Isis::PipelineApplication::OutputBranches
const std::vector< QString > & OutputBranches() const
Get the branches this program has as output.
Definition: PipelineApplication.h:90
Application.h
Isis::PipelineApplication::InputBranches
const std::vector< QString > & InputBranches() const
Get the branches this program expects as input.
Definition: PipelineApplication.h:86
Isis::PipelineApplication::SupportsVirtualBands
bool SupportsVirtualBands()
Returns true if virtual bands are supported.
Definition: PipelineApplication.cpp:844
Isis::PipelineApplication::~PipelineApplication
~PipelineApplication()
This is the destructor.
Definition: PipelineApplication.h:52
Isis::PipelineApplication::Next
PipelineApplication * Next() const
This returns the next enabled pipeline application or null.
Definition: PipelineApplication.h:170
Isis::PipelineParameter::PipelineParameter
PipelineParameter(int branch, QString paramName, PipelineApplication::CustomParameterValue special)
Construct the parameter with a parameter name and special value; affects only the specified branch.
Definition: PipelineApplication.h:405
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::PipelineApplication::OutputNameModifier
QString OutputNameModifier()
This returns this application's output name modifier.
Definition: PipelineApplication.h:136
Isis::PipelineApplication::Disable
void Disable()
This method disables this program, causing it to be ignored.
Definition: PipelineApplication.h:108
Isis::PipelineApplication::Enabled
const bool & Enabled() const
Returns true if this program will be run.
Definition: PipelineApplication.h:113
Isis::PipelineApplication::SetVirtualBands
void SetVirtualBands(std::vector< QString > bands)
Set the virtual bands that this application is to apply.
Definition: PipelineApplication.cpp:856
Isis::PipelineParameter::PipelineParameter
PipelineParameter(QString paramName)
Construct the parameter with only a parameter name; affects all branches and is not a special value.
Definition: PipelineApplication.h:331
Isis::PipelineApplication::AddParameter
void AddParameter(const QString &inputParamName, const QString &appParamName)
This method adds knowledge of a parameter to the application.
Definition: PipelineApplication.cpp:210
Isis::Pipeline
This class helps to call other Isis Applications in a Pipeline.
Definition: Pipeline.h:151
IsisAml::WasEntered
bool WasEntered(const QString &paramName) const
Returns a true if the parameter has a value, and false if it does not.
Definition: IsisAml.cpp:1836
IException.h
Isis::IException::Programmer
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:146
std
Namespace for the standard library.
Isis::PipelineParameter::PipelineParameter
PipelineParameter(QString paramName, QString value)
Construct the parameter with a parameter name and value; affects all branches and is not special.
Definition: PipelineApplication.h:345
Isis::UserInterface
Command Line and Xml loader, validation, and access.
Definition: UserInterface.h:140
Isis::PipelineApplication::EnableBranch
void EnableBranch(QString branch, bool flag)
Enable/Disable Branch given the branch name.
Definition: PipelineApplication.h:202
Isis::PipelineApplication::ParamString
const std::vector< QString > & ParamString() const
Get the parameters for running this program; one element in the vector per run.
Definition: PipelineApplication.h:82
Isis::PipelineParameter::Special
PipelineApplication::CustomParameterValue Special()
Special value of the parameter.
Definition: PipelineApplication.h:436
Isis::PipelineParameter::PipelineParameter
PipelineParameter(int branch, QString paramName, QString paramValue)
Construct the parameter with a parameter name and value; affects only the specified branch and is not...
Definition: PipelineApplication.h:375
Isis::PipelineApplication::SetInputParameter
void SetInputParameter(const QString &inputParamName, bool supportsVirtualBands)
Set the input parameter for this application and whether or not this application supports the virtual...
Definition: PipelineApplication.cpp:79
Isis::PipelineApplication::LastOutput
@ LastOutput
The very last output file. Do not use this for input parameters if it's not necessary,...
Definition: PipelineApplication.h:68
Isis::PipelineApplication::NameModifierType
NameModifierType
This is used for branches.
Definition: PipelineApplication.h:58
Isis::PipelineApplication::GetOutputs
std::vector< QString > & GetOutputs()
This returns this application's output files. Only valid after BuildParamString is called.
Definition: PipelineApplication.cpp:861
Isis::FileName::path
QString path() const
Returns the path of the file name.
Definition: FileName.cpp:103
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::PipelineApplication::Enable
void Enable()
This method enables this program to be run.
Definition: PipelineApplication.h:103