36 std::vector<char> makeEmptyTokenLabels() {
return std::vector<char>{
'\0'}; }
40 : m_tokenLabels{makeEmptyTokenLabels()}, frozen_(
false), containsCurrentProcessAlias_(
false) {}
55 if (iTag.
label().empty()) {
73 const size_t labelSize = iTag.
label().size();
74 const size_t productInstanceSize = iTag.
instance().size();
76 unsigned short delta1 = labelSize + 1;
77 unsigned short delta2 = labelSize + 2 + productInstanceSize;
83 const size_t additionalSize = skipCurrentProcess ? labelSize + productInstanceSize + 3
84 : labelSize + productInstanceSize + iTag.
process().size() + 3;
102 if (!skipCurrentProcess) {
114 bool iPrefetchMayGet) {
121 ++itInfo, ++itKind, ++itLabels) {
122 if (itInfo->m_branchType == iBranchType) {
123 const unsigned int labelStart = itLabels->m_startOfModuleLabel;
130 itInfo->m_index.skipCurrentProcess());
150 for (
unsigned int j = 0;
j !=
matches.numberOfMatches(); ++
j) {
166 if (iPrefetchMayGet) {
177 unsigned int index = 0;
179 auto indexInRecord = iPI.
indexInRecord(it->m_record, it->m_key);
181 const char* componentName = &(
m_tokenLabels[it->m_startOfComponentName]);
182 if (*componentName) {
183 auto component = iPI.
component(it->m_record, it->m_key);
184 if (component->label_.empty()) {
185 if (component->type_ != componentName) {
188 }
else if (component->label_ != componentName) {
195 int negIndex = -1 * (
index + 1);
197 for (
auto& itemIndex :
items) {
198 if (itemIndex.value() == negIndex) {
199 itemIndex = indexInRecord;
223 unsigned int startOfComponentName = 0;
224 if (not iTag.
module().empty()) {
245 return ESTokenIndex{static_cast<ESTokenIndex::Value_t>(indexForToken)};
253 TypeID const& iType)
const {
276 unsigned int count = 0;
280 ++it, ++itAlwaysGet) {
281 if (iBranch == it->m_branchType) {
290 oIndices.reserve(oIndices.size() +
count);
294 ++it, ++itAlwaysGet) {
295 if (iBranch == it->m_branchType) {
298 oIndices.push_back(it->m_index);
308 unsigned int count = 0;
312 ++it, ++itAlwaysGet) {
313 if (iBranch == it->m_branchType) {
315 if (not *itAlwaysGet) {
322 oIndices.reserve(oIndices.size() +
count);
326 ++it, ++itAlwaysGet) {
327 if (iBranch == it->m_branchType) {
329 if (not *itAlwaysGet) {
330 oIndices.push_back(it->m_index);
348 bool skipCurrentProcess,
351 if (it->m_index.productResolverIndex() == iIndex and it->m_index.skipCurrentProcess() == skipCurrentProcess and
352 it->m_branchType == iBranch) {
363 it->m_branchType == iBranch) {
372 <<
"' but the consumes call was for type '"
374 <<
"'.\n Please modify either the consumes or get call so the types match.";
378 <<
"A get using a EDGetToken was done in " <<
BranchTypeToString(iBranch) <<
" but the consumes call was for "
380 <<
".\n Please modify the consumes call to use the correct branch type.";
386 <<
"' was made using an uninitialized token.\n Please check that the variable is "
387 "being initialized from a 'consumes' call.";
390 <<
"A get using a EDGetToken with the C++ type '" << iType.
className() <<
"' was made using a token with a value "
392 <<
" which is beyond the range used by this module.\n Please check that the variable is being initialized from a "
393 "'consumes' call from this module.\n You can not share EDGetToken values between modules.";
397 throw cms::Exception(
"LogicError") <<
"A module declared it consumes a product after its constructor.\n"
398 <<
"This must be done in the contructor\n"
399 <<
"The product type was: " << typeToGet.
type() <<
"\n"
406 throw cms::Exception(
"LogicError") <<
"A module declared it consumes an EventSetup product after its constructor.\n"
407 <<
"This must be done in the contructor\n"
408 <<
"The product type was: " << iDataType.
name() <<
" in record "
410 <<
"and ESInputTag was " << iTag <<
"\n";
415 <<
"A module declared it consumes an EventSetup product during a ProcessBlock transition.\n"
416 <<
"EventSetup products can only be consumed in Event, Lumi, or Run transitions.\n";
420 struct CharStarComp {
421 bool operator()(
const char* iLHS,
const char* iRHS)
const {
return strcmp(iLHS, iRHS) < 0; }
428 const char* consumedModuleLabel,
429 const char* consumedProductInstance,
430 std::vector<ModuleDescription const*>&
modules,
431 std::set<std::string>& alreadyFound,
432 std::map<std::string, ModuleDescription const*>
const& labelsToDesc,
436 if (
auto it = labelsToDesc.find(consumedModuleLabel); it != labelsToDesc.end()) {
437 if (alreadyFound.insert(consumedModuleLabel).second) {
443 if (
auto aliasToModuleLabels =
444 preg.
aliasToModules(consumedTypeKind, consumedType, consumedModuleLabel, consumedProductInstance);
445 not aliasToModuleLabels.empty()) {
446 bool foundInLabelsToDesc =
false;
447 for (
auto const&
label : aliasToModuleLabels) {
448 if (
auto it = labelsToDesc.find(
label); it != labelsToDesc.end()) {
449 if (alreadyFound.insert(
label).second) {
452 foundInLabelsToDesc =
true;
455 if (foundInLabelsToDesc) {
462 if (std::string_view(consumedModuleLabel) !=
"source") {
464 <<
"Couldn't find ModuleDescription for the consumed product type: '" << consumedType.
className()
465 <<
"' module label: '" << consumedModuleLabel <<
"' product instance name: '" << consumedProductInstance
473 std::vector<ModuleProcessName>& modulesInPreviousProcesses,
475 std::map<std::string, ModuleDescription const*>
const& labelsToDesc,
477 std::set<std::string> alreadyFound;
479 auto modulesInPreviousProcessesEmplace = [&modulesInPreviousProcesses](std::string_view module,
483 modulesInPreviousProcesses.emplace(it, module,
process);
489 ++itInfo, ++itKind, ++itLabels) {
491 std::vector<ModuleDescription const*>&
modules = *modulesAll[itInfo->m_branchType];
493 const unsigned int labelStart = itLabels->m_startOfModuleLabel;
494 const char*
const consumedModuleLabel = &(
m_tokenLabels[labelStart]);
495 const char*
const consumedProductInstance = consumedModuleLabel + itLabels->m_deltaToProductInstance;
496 const char*
const consumedProcessName = consumedModuleLabel + itLabels->m_deltaToProcessName;
498 if (not itInfo->m_index.skipCurrentProcess()) {
499 if (*consumedModuleLabel !=
'\0') {
500 if (*consumedProcessName !=
'\0') {
502 *itKind, itInfo->m_type, consumedModuleLabel, consumedProductInstance, consumedProcessName) !=
505 insertFoundModuleLabel(*itKind,
508 consumedProductInstance,
515 modulesInPreviousProcessesEmplace(consumedModuleLabel, consumedProcessName);
519 auto matches =
helper.relatedIndexes(*itKind, itInfo->m_type, consumedModuleLabel, consumedProductInstance);
520 for (
unsigned int j = 0;
j <
matches.numberOfMatches(); ++
j) {
522 insertFoundModuleLabel(*itKind,
525 consumedProductInstance,
533 modulesInPreviousProcessesEmplace(consumedModuleLabel,
matches.processName(
j));
539 auto matches =
helper.relatedIndexes(*itKind, itInfo->m_type);
540 for (
unsigned int j = 0;
j <
matches.numberOfMatches(); ++
j) {
542 insertFoundModuleLabel(*itKind,
551 modulesInPreviousProcessesEmplace(
matches.moduleLabel(
j),
matches.processName(
j));
560 auto matches =
helper.relatedIndexes(*itKind, itInfo->m_type, consumedModuleLabel, consumedProductInstance);
561 for (
unsigned int j = 0;
j <
matches.numberOfMatches(); ++
j) {
563 modulesInPreviousProcessesEmplace(
matches.moduleLabel(
j),
matches.processName(
j));
576 auto newTokenLabels = makeEmptyTokenLabels();
582 newProcessName = &
m_tokenLabels[iter->m_startOfModuleLabel + iter->m_deltaToProcessName];
586 newSize += (iter->m_deltaToProcessName + newProcessName.size() + 1);
588 newTokenLabels.reserve(newSize);
590 unsigned int newStartOfModuleLabel = newTokenLabels.size();
592 unsigned int startOfModuleLabel = iter->m_startOfModuleLabel;
593 unsigned short deltaToProcessName = iter->m_deltaToProcessName;
595 iter->m_startOfModuleLabel = newStartOfModuleLabel;
597 newProcessName = &
m_tokenLabels[startOfModuleLabel + deltaToProcessName];
602 newStartOfModuleLabel += (deltaToProcessName + newProcessName.size() + 1);
605 newTokenLabels.insert(newTokenLabels.end(),
607 m_tokenLabels.begin() + (startOfModuleLabel + deltaToProcessName));
609 newTokenLabels.insert(newTokenLabels.end(), newProcessName.begin(), newProcessName.end());
610 newTokenLabels.push_back(
'\0');
621 std::set<edm::TypeID> alreadySeenTypes;
623 std::vector<ConsumesInfo>
result;
628 ++itInfo, ++itKind, ++itLabels, ++itAlways) {
629 const unsigned int labelStart = itLabels->m_startOfModuleLabel;
630 const char* consumedModuleLabel = &(
m_tokenLabels[labelStart]);
631 const char* consumedInstance = consumedModuleLabel + itLabels->m_deltaToProductInstance;
632 const char* consumedProcessName = consumedModuleLabel + itLabels->m_deltaToProcessName;
635 if (*consumedModuleLabel ==
'\0') {
636 if (!alreadySeenTypes.insert(itInfo->m_type).second) {
642 result.emplace_back(itInfo->m_type,
646 itInfo->m_branchType,
649 itInfo->m_index.skipCurrentProcess());