| 73 | } |
| 74 | |
| 75 | void TOPPASMergerVertex::run() |
| 76 | { |
| 77 | //check if everything ready |
| 78 | if (!isUpstreamFinished()) |
| 79 | { |
| 80 | return; |
| 81 | } |
| 82 | RoundPackages pkg; |
| 83 | String error_msg(""); |
| 84 | bool success = buildRoundPackages(pkg, error_msg); |
| 85 | if (!success) |
| 86 | { |
| 87 | std::cerr << "Could not retrieve input files from upstream nodes...\n"; |
| 88 | emit mergeFailed((String("Merger #") + this->getTopoNr() + " failed. " + error_msg).toQString()); |
| 89 | return; |
| 90 | } |
| 91 | |
| 92 | /// update round status |
| 93 | Size input_rounds = pkg.size(); |
| 94 | round_total_ = (round_based_mode_ ? (int) input_rounds : 1); // for round based: take number of rounds from previous tool(s) - should all be equal |
| 95 | round_counter_ = 0; // once round_counter_ reaches round_total_, we are done |
| 96 | |
| 97 | // clear output file list |
| 98 | output_files_.clear(); |
| 99 | output_files_.resize(round_total_); // #rounds |
| 100 | |
| 101 | // Do the virtual merging (nothing more than reorganizing filenames) |
| 102 | for (Size round = 0; round < input_rounds; ++round) |
| 103 | { |
| 104 | QStringList files; |
| 105 | // warning: ite->first (i.e. target-in param could be -1,-2,... etc to cover all incoming edges (they all have -1 theoretically - see buildRoundPackages()) |
| 106 | for (RoundPackageConstIt ite = pkg[round].begin(); |
| 107 | ite != pkg[round].end(); ++ite) |
| 108 | { |
| 109 | files.append(ite->second.filenames.get()); // concat filenames from all incoming edges |
| 110 | } |
| 111 | Size round_index = (round_based_mode_ ? round : 0); |
| 112 | output_files_[round_index][-1].filenames.append(files); // concat over all rounds (if required) |
| 113 | } |
| 114 | |
| 115 | round_counter_ = round_total_; |
| 116 | finished_ = true; |
| 117 | |
| 118 | // call all children, proceed in pipeline |
| 119 | for (ConstEdgeIterator it = outEdgesBegin(); it != outEdgesEnd(); ++it) |
| 120 | { |
| 121 | TOPPASVertex* tv = (*it)->getTargetVertex(); |
| 122 | debugOut_(String("Starting child ") + tv->getTopoNr()); |
| 123 | tv->run(); |
| 124 | } |
| 125 | |
| 126 | } |
| 127 | |
| 128 | } |