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";
422 struct CharStarComp {
423 bool operator()(
const char* iLHS,
const char* iRHS)
const {
return strcmp(iLHS, iRHS) < 0; }
430 const char* consumedModuleLabel,
431 const char* consumedProductInstance,
432 std::vector<ModuleDescription const*>&
modules,
433 std::set<std::string>& alreadyFound,
434 std::map<std::string, ModuleDescription const*>
const& labelsToDesc,
438 if (
auto it = labelsToDesc.find(consumedModuleLabel); it != labelsToDesc.end()) {
439 if (alreadyFound.insert(consumedModuleLabel).second) {
445 if (
auto aliasToModuleLabels =
446 preg.
aliasToModules(consumedTypeKind, consumedType, consumedModuleLabel, consumedProductInstance);
447 not aliasToModuleLabels.empty()) {
448 bool foundInLabelsToDesc =
false;
449 for (
auto const&
label : aliasToModuleLabels) {
450 if (
auto it = labelsToDesc.find(
label); it != labelsToDesc.end()) {
451 if (alreadyFound.insert(
label).second) {
454 foundInLabelsToDesc =
true;
456 if (
label ==
"source") {
457 foundInLabelsToDesc =
true;
461 if (foundInLabelsToDesc) {
468 if (std::string_view(consumedModuleLabel) !=
"source") {
470 <<
"Couldn't find ModuleDescription for the consumed product type: '" << consumedType.
className()
471 <<
"' module label: '" << consumedModuleLabel <<
"' product instance name: '" << consumedProductInstance
479 std::vector<ModuleProcessName>& modulesInPreviousProcesses,
481 std::map<std::string, ModuleDescription const*>
const& labelsToDesc,
483 std::set<std::string> alreadyFound;
485 auto modulesInPreviousProcessesEmplace = [&modulesInPreviousProcesses](std::string_view
module,
495 ++itInfo, ++itKind, ++itLabels) {
497 std::vector<ModuleDescription const*>&
modules = *modulesAll[itInfo->m_branchType];
499 const unsigned int labelStart = itLabels->m_startOfModuleLabel;
500 const char*
const consumedModuleLabel = &(
m_tokenLabels[labelStart]);
501 const char*
const consumedProductInstance = consumedModuleLabel + itLabels->m_deltaToProductInstance;
502 const char*
const consumedProcessName = consumedModuleLabel + itLabels->m_deltaToProcessName;
504 if (not itInfo->m_index.skipCurrentProcess()) {
505 if (*consumedModuleLabel !=
'\0') {
506 if (*consumedProcessName !=
'\0') {
508 *itKind, itInfo->m_type, consumedModuleLabel, consumedProductInstance, consumedProcessName) !=
511 insertFoundModuleLabel(*itKind,
514 consumedProductInstance,
521 modulesInPreviousProcessesEmplace(consumedModuleLabel, consumedProcessName);
525 auto matches =
helper.relatedIndexes(*itKind, itInfo->m_type, consumedModuleLabel, consumedProductInstance);
526 for (
unsigned int j = 0;
j <
matches.numberOfMatches(); ++
j) {
528 insertFoundModuleLabel(*itKind,
531 consumedProductInstance,
539 modulesInPreviousProcessesEmplace(consumedModuleLabel,
matches.processName(
j));
545 auto matches =
helper.relatedIndexes(*itKind, itInfo->m_type);
546 for (
unsigned int j = 0;
j <
matches.numberOfMatches(); ++
j) {
548 insertFoundModuleLabel(*itKind,
557 modulesInPreviousProcessesEmplace(
matches.moduleLabel(
j),
matches.processName(
j));
566 auto matches =
helper.relatedIndexes(*itKind, itInfo->m_type, consumedModuleLabel, consumedProductInstance);
567 for (
unsigned int j = 0;
j <
matches.numberOfMatches(); ++
j) {
569 modulesInPreviousProcessesEmplace(
matches.moduleLabel(
j),
matches.processName(
j));
582 auto newTokenLabels = makeEmptyTokenLabels();
588 newProcessName = &
m_tokenLabels[iter->m_startOfModuleLabel + iter->m_deltaToProcessName];
592 newSize += (iter->m_deltaToProcessName + newProcessName.size() + 1);
594 newTokenLabels.reserve(newSize);
596 unsigned int newStartOfModuleLabel = newTokenLabels.size();
598 unsigned int startOfModuleLabel = iter->m_startOfModuleLabel;
599 unsigned short deltaToProcessName = iter->m_deltaToProcessName;
601 iter->m_startOfModuleLabel = newStartOfModuleLabel;
603 newProcessName = &
m_tokenLabels[startOfModuleLabel + deltaToProcessName];
608 newStartOfModuleLabel += (deltaToProcessName + newProcessName.size() + 1);
611 newTokenLabels.insert(newTokenLabels.end(),
613 m_tokenLabels.begin() + (startOfModuleLabel + deltaToProcessName));
615 newTokenLabels.insert(newTokenLabels.end(), newProcessName.begin(), newProcessName.end());
616 newTokenLabels.push_back(
'\0');
627 std::set<edm::TypeID> alreadySeenTypes;
629 std::vector<ConsumesInfo>
result;
634 ++itInfo, ++itKind, ++itLabels, ++itAlways) {
635 const unsigned int labelStart = itLabels->m_startOfModuleLabel;
636 const char* consumedModuleLabel = &(
m_tokenLabels[labelStart]);
637 const char* consumedInstance = consumedModuleLabel + itLabels->m_deltaToProductInstance;
638 const char* consumedProcessName = consumedModuleLabel + itLabels->m_deltaToProcessName;
641 if (*consumedModuleLabel ==
'\0') {
642 if (!alreadySeenTypes.insert(itInfo->m_type).second) {
648 result.emplace_back(itInfo->m_type,
652 itInfo->m_branchType,
655 itInfo->m_index.skipCurrentProcess());