Isis 3 Programmer Reference
PipelineApplication.h
Go to the documentation of this file.
1 #ifndef PipelineApplication_h
2 #define PipelineApplication_h
3 
26 #include <vector>
27 
28 #include <QString>
29 
30 #include "IException.h"
31 
32 namespace Isis {
33  class Pipeline;
34  class PipelineParameter;
35 
63  public:
64  PipelineApplication(QString appName, Pipeline *pipe);
65  PipelineApplication(QString appName, PipelineApplication *previous);
66 
69 
77  };
78 
86  // Implies branches will be merged if this is set as an input parameter.
89  // Implies branches will NOT be merged if this is set as an input parameter.
91  };
92 
94  const QString &Name() const {
95  return p_name;
96  }
98  const std::vector<QString> &ParamString() const {
99  return p_paramString;
100  }
102  const std::vector<QString> &InputBranches() const {
103  return p_inBranches;
104  }
106  const std::vector<QString> &OutputBranches() const {
107  if(!Enabled() && Previous()) {
108  return Previous()->OutputBranches();
109  }
110  else if(Enabled()) {
111  return p_outBranches;
112  }
113  else {
114  return p_inBranches;
115  }
116  }
117 
119  void Enable() {
120  p_enabled = true;
121  };
122 
124  void Disable() {
125  p_enabled = false;
126  };
127 
129  const bool &Enabled() const {
130  return p_enabled;
131  }
132 
133  void SetInputParameter(const QString &inputParamName, bool supportsVirtualBands);
134  void SetInputParameter(const QString &inputParamName, CustomParameterValue value, bool supportsVirtualBands);
135 
136  void SetOutputParameter(const QString &outputParamName, const QString &outNameModifier, const QString &outFileExtension = "cub");
137  void SetOutputParameter(const QString &branch, const QString &outputParamName,
138  const QString &outNameModifier, const QString &outFileExtension);
139 
140  void AddBranch(const QString &modString, NameModifierType type);
141 
142  void AddParameter(const QString &inputParamName, const QString &appParamName);
143  void AddParameter(const QString &branch, const QString &inputParamName, const QString &appParamName);
144 
145  void AddConstParameter(const QString &appParamName, const QString &appParamValue);
146  void AddConstParameter(const QString &branch, const QString &appParamName, const QString &appParamValue);
147 
148  void AddParameter(const QString &appParamName, CustomParameterValue value);
149  void AddParameter(const QString &branch, const QString &appParamName, CustomParameterValue value);
150 
152  QString OutputNameModifier() {
153  return (!p_outputMod.isEmpty() || !Previous()) ? p_outputMod : Previous()->OutputNameModifier();
154  }
156  QString OutputExtension() {
157  return (!p_outputExtension.isEmpty() || !Previous()) ? p_outputExtension : Previous()->OutputExtension();
158  }
160  std::vector<QString> &GetOutputs();
161 
162  std::vector<QString> TemporaryFiles();
163 
170  p_next = next;
171  }
172 
173 
180  p_previous = prev;
181  }
182 
183  void BuildParamString();
184 
187  if(p_next == NULL) return p_next;
188  if(!p_next->Enabled()) return p_next->Next();
189  return p_next;
190  }
191 
194  if(p_previous == NULL) return p_previous;
195  if(!p_previous->Enabled()) return p_previous->Previous();
196  return p_previous;
197  }
198 
201  if(p_previous == NULL) return p_previous;
202  if(!p_previous->Enabled()) return p_previous->Previous();
203  if(p_previous->p_output.empty()) return p_previous->Previous();
204  return p_previous;
205  }
206 
207  bool SupportsVirtualBands();
208  void SetVirtualBands(std::vector<QString> bands);
209 
218  void EnableBranch(QString branch, bool flag) {
219  for(int i=0; i<(int)p_inBranches.size(); i++) {
220  if (p_inBranches[i].contains(branch))
221  p_enableBranch[i] = flag;
222  }
223  }
224 
234  bool BranchEnabled(int branch){
235  if (branch >= 0 && branch >= (int)p_enableBranch.size())
236  return false;
237  return p_enableBranch[branch] ;
238  }
239 
247  void SetContinue(bool pbFlag){
248  p_continue = pbFlag;
249  };
250 
258  bool Continue(void) {
259  return p_continue;
260  };
261 
262  private:
267  return p_pipeline;
268  }
269 
271  bool Branches() {
272  if(p_inBranches.size() >= p_outBranches.size()) return false;
273  return true;
274  }
275 
277  bool Merges() {
278  if(p_inBranches.size() == 1) return false;
279  if(p_outBranches.size() == 1) return true;
280  return false;
281  }
282 
289  bool StringStartsWith(QString from, QString compare) {
290  if(compare.size() > from.size()) return false;
291 
292  for(int index = 0; index < compare.size(); index++)
293  if(from[index] != compare[index]) return false;
294 
295  return true;
296  }
297 
298  QString CalculateInputFile(int branch);
299  QString CalculateOutputFile(int branch);
300  QString GetRealLastOutput(bool skipOne = false);
302 
303  int FindBranch(QString name, bool input = true);
304 
306  bool p_enabled;
308  QString p_name;
309  std::vector<QString> p_outputs;
310  std::vector<QString> p_tempFiles;
311  std::vector<QString> p_paramString;
312  std::vector<QString> p_inBranches;
313  std::vector<QString> p_outBranches;
314  std::vector<bool> p_enableBranch;
315 
316  std::vector<PipelineParameter> p_output;
317  QString p_outputMod;
319  std::vector<QString> p_virtualBands;
320 
321  std::vector<PipelineParameter> p_input;
322  std::vector<PipelineParameter> p_params;
323 
327  };
328 
340  public:
347  PipelineParameter(QString paramName) {
348  p_paramName = paramName;
350  p_branch = -1;
351  }
352 
353 
361  PipelineParameter(QString paramName, QString value) {
362  p_paramName = paramName;
363  p_paramValue = value;
365  p_branch = -1;
366  }
367 
368 
376  PipelineParameter(int branch, QString paramName) {
377  p_branch = branch;
378  p_paramName = paramName;
380  }
381 
382 
391  PipelineParameter(int branch, QString paramName, QString paramValue) {
392  p_branch = branch;
393  p_paramValue = paramValue;
394  p_paramName = paramName;
396  }
397 
398 
407  p_paramName = paramName;
408  p_special = special;
409  p_branch = -1;
410  }
411 
412 
421  PipelineParameter(int branch, QString paramName, PipelineApplication::CustomParameterValue special) {
422  p_paramName = paramName;
423  p_special = special;
424  p_branch = branch;
425  }
426 
427 
435  bool AppliesToBranch(int branch) {
436  return (p_branch == -1 || p_branch == branch);
437  }
438 
440  QString Name() {
441  return p_paramName;
442  }
444  QString Value() {
445  return p_paramValue;
446  }
448  bool IsSpecial() {
450  };
453  return p_special;
454  }
457  return p_branch == -1;
458  }
459 
460  private:
461  int p_branch;
462  QString p_paramName;
463  QString p_paramValue;
465  };
466 };
467 #endif
std::vector< bool > p_enableBranch
Branch enabled/disabled.
void SetPrevious(PipelineApplication *prev)
Link to the previous application in the pipeline.
bool BranchEnabled(int branch)
Check whether a branch is enabled given branch index.
PipelineParameter(QString paramName)
Construct the parameter with only a parameter name; affects all branches and is not a special value...
PipelineParameter(int branch, QString paramName)
Construct the parameter with only a parameter name; affects only the specified branch and is not a sp...
bool Merges()
Returns true if this application does merge branches (multiple input branches, one output) ...
const QString & Name() const
Get the name of this pipeline application.
const std::vector< QString > & InputBranches() const
Get the branches this program expects as input.
std::vector< QString > & GetOutputs()
This returns this application&#39;s output files. Only valid after BuildParamString is called...
std::vector< PipelineParameter > p_params
Regular parameters.
PipelineApplication::CustomParameterValue Special()
Special value of the parameter.
~PipelineApplication()
This is the destructor.
QString OutputNameModifier()
This returns this application&#39;s output name modifier.
bool LastApplicationWithOutput()
Returns true if this is the last application with output.
void BuildParamString()
This method calculates the inputs, outputs and necessary calls to this program for the pipeline...
QString p_paramValue
Parameter non-special value.
PipelineApplication * PreviousOutputer() const
This returns the previous enabled pipeline application that makes output or null. ...
bool FutureOutputFileCreated()
Returns true if a future application creates output.
void Disable()
This method disables this program, causing it to be ignored.
The very last output file. Do not use this for input parameters if it&#39;s not necessary, that is done automatically.
This class helps to call other Isis Applications in a Pipeline.
Definition: Pipeline.h:162
PipelineParameter(int branch, QString paramName, QString paramValue)
Construct the parameter with a parameter name and value; affects only the specified branch and is not...
PipelineApplication * Next() const
This returns the next enabled pipeline application or null.
PipelineParameter(int branch, QString paramName, PipelineApplication::CustomParameterValue special)
Construct the parameter with a parameter name and special value; affects only the specified branch...
PipelineApplication::CustomParameterValue p_special
Parameter special value.
bool p_enabled
This application enabled?
bool StringStartsWith(QString from, QString compare)
String comparison helper, returns true if from starts with compare bool.
std::vector< QString > p_inBranches
Input branches.
bool p_supportsVirtualBands
This application supports virtual bands?
const std::vector< QString > & ParamString() const
Get the parameters for running this program; one element in the vector per run.
std::vector< QString > p_virtualBands
Virtual bands string to add (empty if none)
QString p_outputExtension
Output file name extension.
QString CalculateOutputFile(int branch)
This method calculates the output file for the specified branch.
const bool & Enabled() const
Returns true if this program will be run.
QString p_paramName
Parameter name.
int p_branch
Branch this affects.
std::vector< QString > p_tempFiles
Actial temporary files.
void SetContinue(bool pbFlag)
Set the continue flag status.
Pipeline * GetPipeline()
Returns the pipeline.
void AddBranch(const QString &modString, NameModifierType type)
This method adds branch to this program.
std::vector< PipelineParameter > p_output
Output parameters.
PipelineParameter(QString paramName, QString value)
Construct the parameter with a parameter name and value; affects all branches and is not special...
NameModifierType
This is used for branches.
PipelineApplication * Previous() const
This returns the last enabled pipeline application or null.
QString p_outputMod
Output file name modifier.
This class represents one application in the pipeline.
QString p_name
Name of this application.
bool Branches()
Return true is this application does branch (one input branch, multiple output)
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...
void SetNext(PipelineApplication *next)
Link to the next application in the pipeline.
bool SupportsVirtualBands()
Returns true if virtual bands are supported.
int FindBranch(QString name, bool input=true)
The method, given a string, finds the index of a branch.
std::vector< QString > p_outBranches
Output branches.
QString Name()
Name of the parameter.
This class represents a parameter of some type for the PipelineApplication.
PipelineApplication(QString appName, Pipeline *pipe)
Constructs the first pipeline application.
void SetVirtualBands(std::vector< QString > bands)
Set the virtual bands that this application is to apply.
bool IsSpecial()
True if the parameter value is special.
Pipeline * p_pipeline
The pipeline.
QString Value()
Non-special value of the parameter.
CustomParameterValue
This is used to set custom values that must be calculated on the fly.
bool Continue(void)
Get the continue flag status.
void AddParameter(const QString &inputParamName, const QString &appParamName)
This method adds knowledge of a parameter to the application.
const std::vector< QString > & OutputBranches() const
Get the branches this program has as output.
void EnableBranch(QString branch, bool flag)
Enable/Disable Branch given the branch name.
std::vector< QString > p_outputs
Actual output files.
bool AffectsAllBranches()
True if branch-independant.
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
PipelineApplication * p_next
Next pipeline application.
PipelineParameter & GetInputParameter(int branch)
This gets the input parameter for the specified branch.
void SetInputParameter(const QString &inputParamName, bool supportsVirtualBands)
Set the input parameter for this application and whether or not this application supports the virtual...
A list of files from the last run application&#39;s output.
QString OutputExtension()
This returns this application&#39;s output file name&#39;s extension.
bool p_continue
Continue the pipeline execution even if an error is encountered by this app.
std::vector< QString > p_paramString
Built parameter strings.
void SetOutputParameter(const QString &outputParamName, const QString &outNameModifier, const QString &outFileExtension="cub")
Set the output parameter for this application and it&#39;s naming convention.
void Enable()
This method enables this program to be run.
A list of files from the last run application&#39;s output.
PipelineParameter(QString paramName, PipelineApplication::CustomParameterValue special)
Construct the parameter with a parameter name and special value; affects all branches.
QString GetRealLastOutput(bool skipOne=false)
This method is used to calculate the value for CustomParameterValue::LastOutput.
std::vector< PipelineParameter > p_input
Input parameters.
bool AppliesToBranch(int branch)
Returns whether or not the specified branch is affected.
std::vector< QString > TemporaryFiles()
This method returns a list of the temporary files generated by this program.
PipelineApplication * p_previous
Previous pipeline application.
QString CalculateInputFile(int branch)
This method calculates the input file for the specified branch.