27 if(p_pipeline->OriginalBranches().size() == 1) {
28 p_inBranches.push_back(
"");
29 p_outBranches.push_back(
"");
30 p_enableBranch.push_back(
true);
34 p_outBranches = p_pipeline->OriginalBranches();
35 for(
int i=0; i<(int)p_outBranches.size(); i++) {
36 p_enableBranch.push_back(
true);
52 p_previous = previous;
56 p_inBranches = p_previous->OutputBranches();
57 p_outBranches = p_previous->OutputBranches();
58 for(
int i=0; i<(int)p_outBranches.size(); i++) {
59 p_enableBranch.push_back(
true);
61 p_previous->SetNext(
this);
76 p_supportsVirtualBands = supportsVirtualBands;
91 if(value == LastAppOutputList) {
93 p_outBranches.clear();
94 p_outBranches.push_back(
"");
96 else if(value == LastAppOutputListNoMerge) {
98 value = LastAppOutputList;
102 p_supportsVirtualBands = supportsVirtualBands;
117 const QString &outNameModifier,
const QString &outFileExtension) {
118 p_output.push_back(
PipelineParameter(FindBranch(branch,
false), outputParamName));
119 p_outputMod = outNameModifier;
120 p_outputExtension = outFileExtension;
134 p_outputMod = outNameModifier;
135 p_outputExtension = outFileExtension;
158 if(modString ==
"") {
159 string msg =
"Can not add empty branch to pipeline";
168 if(p_outBranches[0] ==
"") {
169 p_outBranches.clear();
170 p_enableBranch.clear();
173 if(p_inBranches.size() == 1) {
174 p_outBranches.push_back(modString);
175 p_enableBranch.push_back(
true);
177 else if(p_inBranches.size() == p_outBranches.size()) {
178 for(
int outBranch = p_outBranches.size() - 1; outBranch >= 0; outBranch --) {
179 if(p_inBranches[outBranch] == p_outBranches[outBranch]) {
180 p_outBranches[outBranch] = p_inBranches[outBranch] +
"." + modString;
183 p_outBranches.push_back(p_inBranches[outBranch] +
"." + modString);
184 p_enableBranch.push_back(
true);
189 for(
unsigned int inBranch = 0; inBranch < p_inBranches.size(); inBranch ++) {
190 p_outBranches.push_back(p_inBranches[inBranch] +
"." + modString);
191 p_enableBranch.push_back(
true);
241 for(
unsigned int i = 0; !added && i < p_params.size(); i++) {
242 if(p_params[i].Name() == appParamName) {
265 p_params.push_back(
PipelineParameter(FindBranch(branch,
false), appParamName, appParamValue));
290 p_params.push_back(
PipelineParameter(FindBranch(branch,
false), appParamName, value));
303 p_paramString.clear();
307 if(!Enabled())
return;
311 bool needList =
false;
314 bool runOnce = Merges() && !Branches();
327 if(!runOnce && p_input.size() == 1) {
332 for(
int param = 0; param < (int)p_params.size() && runOnce; param++) {
333 runOnce = (p_params[param].IsSpecial() && p_params[param].Special() == LastAppOutputList) ||
334 (!p_params[param].
IsSpecial() && p_params[param].AffectsAllBranches());
340 for(
int branch = 0; branch < (int)p_inBranches.size(); branch ++) {
341 if(runOnce && branch > 0) {
345 if(!BranchEnabled(branch)) {
346 QString tmpBranch(branch);
347 p_outputs.push_back(p_name +
"." +tmpBranch +
".blank");
353 QString inputFile = CalculateInputFile(branch);
355 QString outputFile = CalculateOutputFile(branch);
364 needList = (inputParam.
IsSpecial() && inputParam.
Special() == LastAppOutputList);
366 for(
int param = 0; param < (int)p_params.size() && !needList; param++) {
367 needList = (p_params[param].IsSpecial() && p_params[param].Special() == LastAppOutputList);
373 QString listName = outputFile;
375 if(listName.isEmpty()) {
382 QString input = p_pipeline->TemporaryFolder() +
"/" +
FileName(listName).baseName() +
".lis";
383 params =
">>LIST " + input +
" ";
387 while(prev != NULL && infile < (
int)p_inBranches.size()) {
397 p_tempFiles.push_back(input);
398 p_paramString.push_back(params);
406 params = GetInputParameter(branch).
Name() +
"=\"" + listFile +
"\"";
411 params = GetInputParameter(branch).Name() +
"=\"" + inputFile;
412 if(p_virtualBands.size() == 1) {
413 params +=
"+" + p_virtualBands[0];
415 else if(p_virtualBands.size() == p_inBranches.size() && !p_virtualBands[branch].isEmpty()) {
416 params +=
"+" + p_virtualBands[branch];
423 if(p_output.size() != 0) {
424 if(Branches() && p_output.size() != 1) {
426 for(
unsigned int outBranch = 0; outBranch < p_outBranches.size(); outBranch ++) {
428 bool outputSet =
false;
431 if(p_inBranches.size() > 1) {
432 if(!StringStartsWith(p_outBranches[outBranch], p_inBranches[branch])) {
438 for(
unsigned int outParam = 0; outParam < p_output.size(); outParam++) {
439 if(p_output[outParam].AppliesToBranch(outBranch)) {
440 params +=
" " + p_output[outParam].Name() +
"=\"" + p_outputs[outBranch] +
"\"";
443 QString message =
"Application [" + Name() +
"] in the pipeline branches with an ";
444 message +=
"output parameter for each branch, but branch [" + p_outBranches[outBranch];
445 message +=
"] has multiple output files specified.";
454 QString message =
"Application [" + Name() +
"] in the pipeline branches with an ";
455 message +=
"output parameter for each branch, but branch [" + p_outBranches[outBranch];
456 message +=
"] has no output files specified.";
462 bool foundBranch =
false;
465 for(
unsigned int outputParam = 0; outputParam < p_output.size(); outputParam++) {
466 if(p_output[outputParam].AppliesToBranch(branch)) {
467 params +=
" " + p_output[0].Name() +
"=\"" + outputFile +
"\"";
472 if(!foundBranch)
continue;
477 for(
int i = 0; i < (int)p_params.size() && i < (int)p_params.size(); i++) {
478 if(p_params[i].AppliesToBranch(branch)) {
480 params +=
" " + p_params[i].Name() +
"=\"" + p_params[i].Value() +
"\"";
482 else if(p_params[i].Special() == LastOutput) {
483 params +=
" " + p_params[i].Name() +
"=\"" + GetRealLastOutput(
true) +
"\"";
485 else if(p_params[i].Special() == LastAppOutputList) {
486 params +=
" " + p_params[i].Name() +
"=\"" + listFile +
"\"";
491 if(inputFile.isEmpty()) {
492 QString message =
"There was a problem with calculating the inputs for program [" + Name();
493 message +=
"]. Please verify your program is not setting outputs for branches that ";
494 message +=
"don't have input.";
499 p_paramString.push_back(params);
524 while (prev != NULL && file==
"") {
527 string msg =
"Application branches but branch is disabled";
557 file = p_pipeline->OriginalInput(branch);
558 if (file.isEmpty()) {
559 int index = branch / (p_pipeline->OriginalBranchesSize() / p_pipeline->OriginalInputSize());
560 file = p_pipeline->OriginalInput(index);
565 for(
int i = 0; i < (int)p_input.size(); i++) {
566 if(p_input[i].AppliesToBranch(branch) && p_input[i].IsSpecial()) {
567 if(p_input[i].Special() == LastOutput) {
568 file = GetRealLastOutput();
586 QString outFolder = p_pipeline->TemporaryFolder();
590 bool usedBranch =
false;
591 unsigned int usedBranchIndex = 0;
592 unsigned int numUsedBranches = 0;
594 for(
unsigned int outputBranch = 0; outputBranch < p_outBranches.size(); outputBranch++) {
595 bool outBranchUsed =
false;
597 for(
unsigned int outputParam = 0; outputParam < p_output.size(); outputParam ++) {
598 if(p_output[outputParam].AppliesToBranch(outputBranch)) {
599 outBranchUsed =
true;
604 if(outputBranch < (
unsigned int)branch) {
608 if((
unsigned int)branch == outputBranch) {
616 if(!usedBranch)
return "";
618 if(!LastApplicationWithOutput()) {
619 QString lastOutput = p_pipeline->FinalOutput(branch,
false);
620 outputFile = outFolder +
"/" +
621 FileName(lastOutput).baseName() +
"." + p_outputMod +
"." + p_outputExtension;
623 if(p_outputMod.isEmpty()) {
624 outputFile = outFolder +
"/" +
625 FileName(lastOutput).baseName() +
"." + p_outputExtension;
629 outputFile = p_pipeline->FinalOutput(branch, numUsedBranches > 1);
633 if(!LastApplicationWithOutput() && numUsedBranches != 1 && !p_outputMod.isEmpty()) {
636 QString realOut(outFolder +
"/" + outfile.baseName() +
"." + p_outBranches[branch] +
"." + p_outputExtension);
641 if(p_outputs.size() == usedBranchIndex) {
642 p_outputs.push_back(realOut);
648 if(branch == 0 && Branches()) {
649 for(
unsigned int i = 1; i < OutputBranches().size(); i++) {
650 CalculateOutputFile(i);
659 outputFile = realOut;
663 else if(!p_outputMod.isEmpty()) {
664 if(p_outputs.size() == usedBranchIndex) {
665 p_outputs.push_back(outputFile);
671 if(branch == 0 && Branches()) {
672 for(
unsigned int i = 1; i < OutputBranches().size(); i++) {
673 CalculateOutputFile(i);
689 if(!Next() && !p_output.empty()) {
692 if(!Next() && p_output.empty()) {
697 return !Next()->FutureOutputFileCreated();
708 if(!p_output.empty()) {
712 if(!Next() && p_output.empty()) {
716 return Next()->FutureOutputFileCreated();
728 for(
int i = 0; i < (int)p_input.size(); i++) {
729 if(p_input[i].AppliesToBranch(branch)) {
734 if(p_inBranches[0] !=
"") {
735 QString msg =
"Application [" + Name() +
"] in the pipeline does not have an input for branch [" + p_inBranches[branch] +
"]";
739 QString msg =
"Application [" + Name() +
"] in the pipeline does not have an input";
758 while(!found && branchIndex < (
int)p_inBranches.size()) {
759 if(p_inBranches[branchIndex] == name) {
768 while(!found && branchIndex < (
int)p_outBranches.size()) {
769 if(p_outBranches[branchIndex] == name) {
779 QString msg =
"Branch [" + name +
"] does not exist in the pipeline application [" + Name() +
"]";
796 if(!LastApplicationWithOutput()) {
797 for(
int i = 0; i < (int)p_outputs.size(); i++) {
798 tmp.push_back(p_outputs[i]);
802 for(
int i = 0; i < (int)p_tempFiles.size(); i++) {
803 tmp.push_back(p_tempFiles[i]);
821 return GetOutputs()[GetOutputs().size()-1];
824 if(p_outputs.size() > 1) {
825 return GetOutputs()[GetOutputs().size()-2];
828 return Previous()->GetOutputs()[Previous()->GetOutputs().size()-1];
839 if(!Enabled())
return false;
840 return p_supportsVirtualBands;
851 p_virtualBands = bands;
856 if(Enabled() && p_outputs.size() != 0) {
859 else if(Previous()) {
860 return Previous()->GetOutputs();