35 std::vector<char> makeEmptyTokenLabels() {
return std::vector<char>{
'\0'}; }
39 : m_tokenLabels{makeEmptyTokenLabels()}, frozen_(
false), containsCurrentProcessAlias_(
false) {}
54 if (iTag.
label().empty()) {
72 const size_t labelSize = iTag.
label().size();
73 const size_t productInstanceSize = iTag.
instance().size();
75 unsigned short delta1 = labelSize + 1;
76 unsigned short delta2 = labelSize + 2 + productInstanceSize;
82 const size_t additionalSize = skipCurrentProcess ? labelSize + productInstanceSize + 3
83 : labelSize + productInstanceSize + iTag.
process().size() + 3;
101 if (!skipCurrentProcess) {
113 bool iPrefetchMayGet) {
120 ++itInfo, ++itKind, ++itLabels) {
121 if (itInfo->m_branchType == iBranchType) {
122 const unsigned int labelStart = itLabels->m_startOfModuleLabel;
129 itInfo->m_index.skipCurrentProcess());
149 for (
unsigned int j = 0;
j !=
matches.numberOfMatches(); ++
j) {
165 if (iPrefetchMayGet) {
176 unsigned int index = 0;
178 auto indexInRecord = iPI.
indexInRecord(it->m_record, it->m_key);
180 const char* componentName = &(
m_tokenLabels[it->m_startOfComponentName]);
181 if (*componentName) {
182 auto component = iPI.
component(it->m_record, it->m_key);
183 if (component->label_.empty()) {
184 if (component->type_ != componentName) {
187 }
else if (component->label_ != componentName) {
194 int negIndex = -1 * (
index + 1);
196 for (
auto& itemIndex :
items) {
197 if (itemIndex.value() == negIndex) {
198 itemIndex = indexInRecord;
222 unsigned int startOfComponentName = 0;
223 if (not iTag.
module().empty()) {
244 return ESTokenIndex{static_cast<ESTokenIndex::Value_t>(indexForToken)};
252 TypeID const& iType)
const {
275 unsigned int count = 0;
279 ++it, ++itAlwaysGet) {
280 if (iBranch == it->m_branchType) {
289 oIndices.reserve(oIndices.size() +
count);
293 ++it, ++itAlwaysGet) {
294 if (iBranch == it->m_branchType) {
297 oIndices.push_back(it->m_index);
307 unsigned int count = 0;
311 ++it, ++itAlwaysGet) {
312 if (iBranch == it->m_branchType) {
314 if (not *itAlwaysGet) {
321 oIndices.reserve(oIndices.size() +
count);
325 ++it, ++itAlwaysGet) {
326 if (iBranch == it->m_branchType) {
328 if (not *itAlwaysGet) {
329 oIndices.push_back(it->m_index);
347 bool skipCurrentProcess,
350 if (it->m_index.productResolverIndex() == iIndex and it->m_index.skipCurrentProcess() == skipCurrentProcess and
351 it->m_branchType == iBranch) {
362 it->m_branchType == iBranch) {
371 <<
"' but the consumes call was for type '"
373 <<
"'.\n Please modify either the consumes or get call so the types match.";
377 <<
"A get using a EDGetToken was done in " <<
BranchTypeToString(iBranch) <<
" but the consumes call was for "
379 <<
".\n Please modify the consumes call to use the correct branch type.";
385 <<
"' was made using an uninitialized token.\n Please check that the variable is "
386 "being initialized from a 'consumes' call.";
389 <<
"A get using a EDGetToken with the C++ type '" << iType.
className() <<
"' was made using a token with a value "
391 <<
" which is beyond the range used by this module.\n Please check that the variable is being initialized from a "
392 "'consumes' call from this module.\n You can not share EDGetToken values between modules.";
396 throw cms::Exception(
"LogicError") <<
"A module declared it consumes a product after its constructor.\n"
397 <<
"This must be done in the contructor\n"
398 <<
"The product type was: " << typeToGet.
type() <<
"\n"
405 throw cms::Exception(
"LogicError") <<
"A module declared it consumes an EventSetup product after its constructor.\n"
406 <<
"This must be done in the contructor\n"
407 <<
"The product type was: " << iDataType.
name() <<
" in record "
409 <<
"and ESInputTag was " << iTag <<
"\n";
414 <<
"A module declared it consumes an EventSetup product during a ProcessBlock transition.\n"
415 <<
"EventSetup products can only be consumed in Event, Lumi, or Run transitions.\n";
419 struct CharStarComp {
420 bool operator()(
const char* iLHS,
const char* iRHS)
const {
return strcmp(iLHS, iRHS) < 0; }
427 const char* consumedModuleLabel,
428 const char* consumedProductInstance,
429 std::vector<ModuleDescription const*>&
modules,
430 std::set<std::string>& alreadyFound,
431 std::map<std::string, ModuleDescription const*>
const& labelsToDesc,
435 if (
auto it = labelsToDesc.find(consumedModuleLabel); it != labelsToDesc.end()) {
436 if (alreadyFound.insert(consumedModuleLabel).second) {
442 if (
auto aliasToModuleLabels =
443 preg.
aliasToModules(consumedTypeKind, consumedType, consumedModuleLabel, consumedProductInstance);
444 not aliasToModuleLabels.empty()) {
445 bool foundInLabelsToDesc =
false;
446 for (
auto const&
label : aliasToModuleLabels) {
447 if (
auto it = labelsToDesc.find(
label); it != labelsToDesc.end()) {
448 if (alreadyFound.insert(
label).second) {
451 foundInLabelsToDesc =
true;
454 if (foundInLabelsToDesc) {
461 if (std::string_view(consumedModuleLabel) !=
"source") {
463 <<
"Couldn't find ModuleDescription for the consumed product type: '" << consumedType.
className()
464 <<
"' module label: '" << consumedModuleLabel <<
"' product instance name: '" << consumedProductInstance
472 std::map<std::string, ModuleDescription const*>
const& labelsToDesc,
476 std::set<std::string> alreadyFound;
481 ++itInfo, ++itKind, ++itLabels) {
482 if (itInfo->m_branchType ==
InEvent and (not itInfo->m_index.skipCurrentProcess())) {
483 const unsigned int labelStart = itLabels->m_startOfModuleLabel;
484 const char*
const consumedModuleLabel = &(
m_tokenLabels[labelStart]);
485 const char*
const consumedProductInstance = consumedModuleLabel + itLabels->m_deltaToProductInstance;
486 const char*
const consumedProcessName = consumedModuleLabel + itLabels->m_deltaToProcessName;
488 if (*consumedModuleLabel !=
'\0') {
489 if (*consumedProcessName !=
'\0') {
492 *itKind, itInfo->m_type, consumedModuleLabel, consumedProductInstance, consumedProcessName) !=
494 insertFoundModuleLabel(*itKind,
497 consumedProductInstance,
504 auto matches = iHelper.
relatedIndexes(*itKind, itInfo->m_type, consumedModuleLabel, consumedProductInstance);
505 for (
unsigned int j = 0;
j <
matches.numberOfMatches(); ++
j) {
507 insertFoundModuleLabel(*itKind,
510 consumedProductInstance,
521 for (
unsigned int j = 0;
j <
matches.numberOfMatches(); ++
j) {
523 insertFoundModuleLabel(*itKind,
544 auto newTokenLabels = makeEmptyTokenLabels();
550 newProcessName = &
m_tokenLabels[iter->m_startOfModuleLabel + iter->m_deltaToProcessName];
554 newSize += (iter->m_deltaToProcessName + newProcessName.size() + 1);
556 newTokenLabels.reserve(newSize);
558 unsigned int newStartOfModuleLabel = newTokenLabels.size();
560 unsigned int startOfModuleLabel = iter->m_startOfModuleLabel;
561 unsigned short deltaToProcessName = iter->m_deltaToProcessName;
563 iter->m_startOfModuleLabel = newStartOfModuleLabel;
565 newProcessName = &
m_tokenLabels[startOfModuleLabel + deltaToProcessName];
570 newStartOfModuleLabel += (deltaToProcessName + newProcessName.size() + 1);
573 newTokenLabels.insert(newTokenLabels.end(),
575 m_tokenLabels.begin() + (startOfModuleLabel + deltaToProcessName));
577 newTokenLabels.insert(newTokenLabels.end(), newProcessName.begin(), newProcessName.end());
578 newTokenLabels.push_back(
'\0');
589 std::set<edm::TypeID> alreadySeenTypes;
591 std::vector<ConsumesInfo>
result;
596 ++itInfo, ++itKind, ++itLabels, ++itAlways) {
597 const unsigned int labelStart = itLabels->m_startOfModuleLabel;
598 const char* consumedModuleLabel = &(
m_tokenLabels[labelStart]);
599 const char* consumedInstance = consumedModuleLabel + itLabels->m_deltaToProductInstance;
600 const char* consumedProcessName = consumedModuleLabel + itLabels->m_deltaToProcessName;
603 if (*consumedModuleLabel ==
'\0') {
604 if (!alreadySeenTypes.insert(itInfo->m_type).second) {
610 result.emplace_back(itInfo->m_type,
614 itInfo->m_branchType,
617 itInfo->m_index.skipCurrentProcess());