|
11 | 11 |
|
12 | 12 | #include "Framework/AnalysisSupportHelpers.h" |
13 | 13 | #include "Framework/DataOutputDirector.h" |
14 | | -#include "Framework/OutputObjHeader.h" |
15 | | -#include "Framework/ControlService.h" |
16 | | -#include "Framework/EndOfStreamContext.h" |
17 | | -#include "Framework/DeviceSpec.h" |
| 14 | +#include "Framework/DataSpecViews.h" |
18 | 15 | #include "Framework/PluginManager.h" |
19 | 16 | #include "Framework/ConfigContext.h" |
20 | 17 | #include "WorkflowHelpers.h" |
@@ -129,109 +126,59 @@ void AnalysisSupportHelpers::addMissingOutputsToReader(std::vector<OutputSpec> c |
129 | 126 | std::vector<InputSpec> const& requestedInputs, |
130 | 127 | DataProcessorSpec& publisher) |
131 | 128 | { |
132 | | - auto matchingOutputFor = [](InputSpec const& requested) { |
133 | | - return [&requested](OutputSpec const& provided) { |
134 | | - return DataSpecUtils::match(requested, provided); |
135 | | - }; |
136 | | - }; |
137 | | - for (InputSpec const& requested : requestedInputs) { |
138 | | - auto provided = std::find_if(providedOutputs.begin(), |
139 | | - providedOutputs.end(), |
140 | | - matchingOutputFor(requested)); |
141 | | - |
142 | | - if (provided != providedOutputs.end()) { |
143 | | - continue; |
144 | | - } |
145 | | - |
146 | | - auto inList = std::find_if(publisher.outputs.begin(), |
147 | | - publisher.outputs.end(), |
148 | | - matchingOutputFor(requested)); |
149 | | - if (inList != publisher.outputs.end()) { |
150 | | - continue; |
151 | | - } |
152 | | - |
153 | | - auto concrete = DataSpecUtils::asConcreteDataMatcher(requested); |
154 | | - publisher.outputs.emplace_back(concrete.origin, concrete.description, concrete.subSpec, requested.lifetime, requested.metadata); |
155 | | - } |
| 129 | + requestedInputs | |
| 130 | + views::filter_not_matching(providedOutputs) | // filter the inputs that are already provided |
| 131 | + views::filter_not_matching(publisher.outputs) | // filter the inputs that are already covered |
| 132 | + views::input_to_output_specs() | |
| 133 | + sinks::append_to{publisher.outputs}; // append them to the publisher outputs |
156 | 134 | } |
157 | 135 |
|
158 | 136 | void AnalysisSupportHelpers::addMissingOutputsToSpawner(std::vector<OutputSpec> const& providedSpecials, |
159 | 137 | std::vector<InputSpec> const& requestedSpecials, |
160 | 138 | std::vector<InputSpec>& requestedAODs, |
161 | 139 | DataProcessorSpec& publisher) |
162 | 140 | { |
163 | | - for (auto& input : requestedSpecials) { |
164 | | - if (std::any_of(providedSpecials.begin(), providedSpecials.end(), [&input](auto const& x) { |
165 | | - return DataSpecUtils::match(input, x); |
166 | | - })) { |
167 | | - continue; |
168 | | - } |
169 | | - auto concrete = DataSpecUtils::asConcreteDataMatcher(input); |
170 | | - publisher.outputs.emplace_back(concrete.origin, concrete.description, concrete.subSpec); |
171 | | - for (auto& i : input.metadata) { |
172 | | - if ((i.type == VariantType::String) && (i.name.find("input:") != std::string::npos)) { |
173 | | - auto spec = DataSpecUtils::fromMetadataString(i.defaultValue.get<std::string>()); |
174 | | - auto j = std::find(publisher.inputs.begin(), publisher.inputs.end(), spec); |
175 | | - if (j == publisher.inputs.end()) { |
176 | | - publisher.inputs.push_back(spec); |
177 | | - } |
178 | | - DataSpecUtils::updateInputList(requestedAODs, std::move(spec)); |
179 | | - } |
180 | | - } |
| 141 | + requestedSpecials | |
| 142 | + views::filter_not_matching(providedSpecials) | // filter the inputs that are already provided |
| 143 | + views::input_to_output_specs() | |
| 144 | + sinks::append_to{publisher.outputs}; // append them to the publisher outputs |
| 145 | + |
| 146 | + std::vector<InputSpec> additionalInputs; |
| 147 | + for (auto& input : requestedSpecials | views::filter_not_matching(providedSpecials)) { |
| 148 | + input.metadata | |
| 149 | + views::filter_string_params_with("input:") | |
| 150 | + views::params_to_input_specs() | |
| 151 | + sinks::update_input_list{additionalInputs}; // store into a temporary |
181 | 152 | } |
| 153 | + additionalInputs | sinks::update_input_list{requestedAODs}; // update requestedAODs |
| 154 | + additionalInputs | sinks::update_input_list{publisher.inputs}; // update publisher inputs |
182 | 155 | } |
183 | 156 |
|
184 | 157 | void AnalysisSupportHelpers::addMissingOutputsToBuilder(std::vector<InputSpec> const& requestedSpecials, |
185 | 158 | std::vector<InputSpec>& requestedAODs, |
186 | 159 | std::vector<InputSpec>& requestedDYNs, |
187 | 160 | DataProcessorSpec& publisher) |
188 | 161 | { |
189 | | - for (auto& input : requestedSpecials) { |
190 | | - auto concrete = DataSpecUtils::asConcreteDataMatcher(input); |
191 | | - publisher.outputs.emplace_back(concrete.origin, concrete.description, concrete.subSpec); |
192 | | - for (auto& i : input.metadata) { |
193 | | - if ((i.type == VariantType::String) && (i.name.find("input:") != std::string::npos)) { |
194 | | - auto spec = DataSpecUtils::fromMetadataString(i.defaultValue.get<std::string>()); |
195 | | - auto j = std::find_if(publisher.inputs.begin(), publisher.inputs.end(), [&](auto x) { return x.binding == spec.binding; }); |
196 | | - if (j == publisher.inputs.end()) { |
197 | | - publisher.inputs.push_back(spec); |
198 | | - } |
199 | | - if (DataSpecUtils::partialMatch(spec, AODOrigins)) { |
200 | | - DataSpecUtils::updateInputList(requestedAODs, std::move(spec)); |
201 | | - } else if (DataSpecUtils::partialMatch(spec, header::DataOrigin{"DYN"})) { |
202 | | - DataSpecUtils::updateInputList(requestedDYNs, std::move(spec)); |
203 | | - } |
204 | | - } |
205 | | - } |
| 162 | + requestedSpecials | |
| 163 | + views::input_to_output_specs() | |
| 164 | + sinks::append_to{publisher.outputs}; // append them to the publisher outputs |
| 165 | + |
| 166 | + std::vector<InputSpec> additionalInputs; |
| 167 | + for (auto const& input : requestedSpecials) { |
| 168 | + input.metadata | |
| 169 | + views::filter_string_params_with("input:") | |
| 170 | + views::params_to_input_specs() | |
| 171 | + sinks::update_input_list{additionalInputs}; // store into a temporary |
206 | 172 | } |
207 | | -} |
208 | 173 |
|
209 | | -void AnalysisSupportHelpers::addMissingOutputsToAnalysisCCDBFetcher( |
210 | | - std::vector<OutputSpec> const& providedSpecials, |
211 | | - std::vector<InputSpec> const& requestedSpecials, |
212 | | - std::vector<InputSpec>& requestedAODs, |
213 | | - std::vector<InputSpec>& requestedDYNs, |
214 | | - DataProcessorSpec& publisher) |
215 | | -{ |
216 | | - for (auto& input : requestedSpecials) { |
217 | | - auto concrete = DataSpecUtils::asConcreteDataMatcher(input); |
218 | | - publisher.outputs.emplace_back(concrete.origin, concrete.description, concrete.subSpec); |
219 | | - // FIXME: good enough for now... |
220 | | - for (auto& i : input.metadata) { |
221 | | - if ((i.type == VariantType::String) && (i.name.find("input:") != std::string::npos)) { |
222 | | - auto spec = DataSpecUtils::fromMetadataString(i.defaultValue.get<std::string>()); |
223 | | - auto j = std::find_if(publisher.inputs.begin(), publisher.inputs.end(), [&](auto x) { return x.binding == spec.binding; }); |
224 | | - if (j == publisher.inputs.end()) { |
225 | | - publisher.inputs.push_back(spec); |
226 | | - } |
227 | | - if (DataSpecUtils::partialMatch(spec, AODOrigins)) { |
228 | | - DataSpecUtils::updateInputList(requestedAODs, std::move(spec)); |
229 | | - } else if (DataSpecUtils::partialMatch(spec, header::DataOrigin{"DYN"})) { |
230 | | - DataSpecUtils::updateInputList(requestedDYNs, std::move(spec)); |
231 | | - } |
232 | | - } |
233 | | - } |
234 | | - } |
| 174 | + additionalInputs | sinks::update_input_list{publisher.inputs}; // update publisher inputs |
| 175 | + // FIXME: until we have a single list of pairs |
| 176 | + additionalInputs | |
| 177 | + views::partial_match_filter(AODOrigins) | |
| 178 | + sinks::update_input_list{requestedAODs}; // update requestedAODs |
| 179 | + additionalInputs | |
| 180 | + views::partial_match_filter(header::DataOrigin{"DYN"}) | |
| 181 | + sinks::update_input_list{requestedDYNs}; // update requestedDYNs |
235 | 182 | } |
236 | 183 |
|
237 | 184 | // ============================================================================= |
|
0 commit comments