Skip to content

Commit c36be58

Browse files
committed
Define skippCurrentProcessLabel in one place
1 parent 2a40448 commit c36be58

File tree

6 files changed

+23
-11
lines changed

6 files changed

+23
-11
lines changed

DataFormats/Provenance/interface/ProductResolverIndexHelper.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,10 @@ namespace edm {
258258
// For debugging only
259259
void print(std::ostream& os) const;
260260

261+
//ProcessName label used to denote the current process should be skipped
262+
//used by all methods of this class that accept the process name
263+
static constexpr char const* const skipCurrentProcessLabel() { return "#"; }
264+
261265
private:
262266
// Next available value for a ProductResolverIndex. This just
263267
// increments by one each time a new value is assigned.
@@ -330,7 +334,7 @@ namespace edm {
330334
ProductResolverIndex index() const { return index_; }
331335

332336
void clearProcess() { process_.clear(); }
333-
void setSkipCurrentProcess() { process_ = "#"; }
337+
void setSkipCurrentProcess() { process_ = ProductResolverIndexHelper::skipCurrentProcessLabel(); }
334338
void setIndex(ProductResolverIndex v) { index_ = v; }
335339

336340
bool operator<(Item const& right) const;

DataFormats/Provenance/src/ProductResolverIndexHelper.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ namespace edm {
413413

414414
//sanity check
415415
for (auto const& p : *processItems_) {
416-
if (p.empty() or p == "#")
416+
if (p.empty() or p == skipCurrentProcessLabel())
417417
continue;
418418
if (orderedProcessNames.end() == std::find(orderedProcessNames.begin(), orderedProcessNames.end(), p)) {
419419
throw Exception(errors::LogicError)

DataFormats/Provenance/test/productResolverIndexHelper_t.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
#include <iomanip>
1515

1616
using namespace edm;
17+
namespace {
18+
constexpr auto skipCurrentProcessLabel = edm::ProductResolverIndexHelper::skipCurrentProcessLabel();
19+
}
1720

1821
TEST_CASE("ProductResolverIndexHelper", "[ProductResolverIndexHelper]") {
1922
TypeID typeID_ProductID(typeid(ProductID));
@@ -79,7 +82,8 @@ TEST_CASE("ProductResolverIndexHelper", "[ProductResolverIndexHelper]") {
7982
REQUIRE(helper.index(PRODUCT_TYPE, typeID_ProductID, "labelA", "instanceA") == indexWithProcess);
8083
REQUIRE(helper.index(PRODUCT_TYPE, typeID_ProductID, "labelA", "instanceA", "") == indexWithProcess);
8184
REQUIRE(helper.index(PRODUCT_TYPE, typeID_ProductID, "labelA", "instanceA", 0) == indexWithProcess);
82-
REQUIRE(helper.index(PRODUCT_TYPE, typeID_ProductID, "labelA", "instanceA", "#") == indexSkipCurrentProcess);
85+
REQUIRE(helper.index(PRODUCT_TYPE, typeID_ProductID, "labelA", "instanceA", skipCurrentProcessLabel) ==
86+
indexSkipCurrentProcess);
8387
REQUIRE(helper.index(PRODUCT_TYPE, typeID_ProductID, "labelA", "instanceA", "processA") == indexWithProcess);
8488

8589
REQUIRE(helper.index(PRODUCT_TYPE, typeID_ProductID, "labelA", "instance", "processA") ==
@@ -154,7 +158,8 @@ TEST_CASE("ProductResolverIndexHelper", "[ProductResolverIndexHelper]") {
154158
REQUIRE(helper.index(PRODUCT_TYPE, typeID_ProductID, "labelA", "instanceA") == indexWithProcess);
155159
REQUIRE(helper.index(PRODUCT_TYPE, typeID_ProductID, "labelA", "instanceA", "") == indexWithProcess);
156160
REQUIRE(helper.index(PRODUCT_TYPE, typeID_ProductID, "labelA", "instanceA", 0) == indexWithProcess);
157-
REQUIRE(helper.index(PRODUCT_TYPE, typeID_ProductID, "labelA", "instanceA", "#") == indexSkipCurrentProcess);
161+
REQUIRE(helper.index(PRODUCT_TYPE, typeID_ProductID, "labelA", "instanceA", skipCurrentProcessLabel) ==
162+
indexSkipCurrentProcess);
158163
REQUIRE(helper.index(PRODUCT_TYPE, typeID_ProductID, "labelA", "instanceA", "processA") == indexWithProcess);
159164

160165
REQUIRE(helper.index(PRODUCT_TYPE, typeID_ProductID, "labelA", "instance", "processA") ==
@@ -216,7 +221,8 @@ TEST_CASE("ProductResolverIndexHelper", "[ProductResolverIndexHelper]") {
216221
REQUIRE(helper.index(PRODUCT_TYPE, typeID_ProductID, "labelA", "instanceA") == indexWithProcessB);
217222
REQUIRE(helper.index(PRODUCT_TYPE, typeID_ProductID, "labelA", "instanceA", "") == indexWithProcessB);
218223
REQUIRE(helper.index(PRODUCT_TYPE, typeID_ProductID, "labelA", "instanceA", 0) == indexWithProcessB);
219-
REQUIRE(helper.index(PRODUCT_TYPE, typeID_ProductID, "labelA", "instanceA", "#") == indexSkipCurrentProcess);
224+
REQUIRE(helper.index(PRODUCT_TYPE, typeID_ProductID, "labelA", "instanceA", skipCurrentProcessLabel) ==
225+
indexSkipCurrentProcess);
220226
REQUIRE(helper.index(PRODUCT_TYPE, typeID_ProductID, "labelA", "instanceA", "processA") == indexWithProcessA);
221227
REQUIRE(helper.index(PRODUCT_TYPE, typeID_ProductID, "labelA", "instanceA", "processB") == indexWithProcessB);
222228
}

FWCore/Framework/src/EDConsumerBase.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ void EDConsumerBase::updateLookup(BranchType iBranchType,
129129
const char* moduleLabel = &(m_tokenLabels[labelStart]);
130130
const char* processName = moduleLabel + itLabels->m_deltaToProcessName;
131131
if (itInfo->m_index.skipCurrentProcess()) {
132-
processName = "#";
132+
processName = iHelper.skipCurrentProcessLabel();
133133
}
134134
itInfo->m_index = ProductResolverIndexAndSkipBit(
135135
iHelper.index(

FWCore/Framework/src/Principal.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ namespace edm {
457457
if (inputTag.process() == InputTag::kCurrentProcess) {
458458
processName = &processConfiguration_->processName();
459459
}
460-
std::string const kSkipCurrentProcess = "#";
460+
std::string const kSkipCurrentProcess = ProductResolverIndexHelper::skipCurrentProcessLabel();
461461
if (skipCurrentProcess) {
462462
processName = &kSkipCurrentProcess;
463463
}
@@ -481,7 +481,7 @@ namespace edm {
481481
if (index == ProductResolverIndexInitializing) {
482482
char const* processName = inputTag.process().c_str();
483483
if (skipCurrentProcess) {
484-
processName = "#";
484+
processName = ProductResolverIndexHelper::skipCurrentProcessLabel();
485485
} else if (inputTag.process() == InputTag::kCurrentProcess) {
486486
processName = processConfiguration_->processName().c_str();
487487
}

FWCore/Framework/test/edconsumerbase_t.cppunit.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ namespace {
114114
std::vector<edm::EDGetTokenT<std::vector<int>>> m_tokens;
115115
};
116116

117+
constexpr const auto skipCurrentProcessLabel = edm::ProductResolverIndexHelper::skipCurrentProcessLabel();
117118
} // namespace
118119

119120
void TestEDConsumerBase::testRegularType() {
@@ -150,7 +151,8 @@ void TestEDConsumerBase::testRegularType() {
150151

151152
edm::TypeID typeID_vint(typeid(std::vector<int>));
152153
const auto vint_c = helper.index(edm::PRODUCT_TYPE, typeID_vint, "labelC", "instanceC", "processC");
153-
const auto vint_c_skipCurrent = helper.index(edm::PRODUCT_TYPE, typeID_vint, "labelC", "instanceC", "#");
154+
const auto vint_c_skipCurrent =
155+
helper.index(edm::PRODUCT_TYPE, typeID_vint, "labelC", "instanceC", skipCurrentProcessLabel);
154156
CPPUNIT_ASSERT(edm::ProductResolverIndexInvalid == vint_c_skipCurrent);
155157
const auto vint_c_no_proc = helper.index(edm::PRODUCT_TYPE, typeID_vint, "labelC", "instanceC", 0);
156158
CPPUNIT_ASSERT(vint_c == vint_c_no_proc);
@@ -364,7 +366,7 @@ void TestEDConsumerBase::testViewType() {
364366
const auto v_int_no_proc = helper.index(edm::ELEMENT_TYPE, typeID_int, "label", "instance");
365367
const auto v_simple_no_proc = helper.index(edm::ELEMENT_TYPE, typeID_Simple, "labelC", "instanceC");
366368
CPPUNIT_ASSERT(v_simple_no_proc == v_simple);
367-
const auto v_simple_skip = helper.index(edm::ELEMENT_TYPE, typeID_Simple, "labelC", "#");
369+
const auto v_simple_skip = helper.index(edm::ELEMENT_TYPE, typeID_Simple, "labelC", skipCurrentProcessLabel);
368370

369371
{
370372
std::vector<std::pair<edm::TypeToGet, edm::InputTag>> vT = {
@@ -477,7 +479,7 @@ void TestEDConsumerBase::testMay() {
477479
const auto vint_c = helper.index(edm::PRODUCT_TYPE, typeID_vint, "labelC", "instanceC", "processC");
478480
const auto vint_c_no_proc = helper.index(edm::PRODUCT_TYPE, typeID_vint, "labelC", "instanceC", 0);
479481
CPPUNIT_ASSERT(vint_c_no_proc == vint_c);
480-
const auto vint_c_skip = helper.index(edm::PRODUCT_TYPE, typeID_vint, "labelC", "instanceC", "#");
482+
const auto vint_c_skip = helper.index(edm::PRODUCT_TYPE, typeID_vint, "labelC", "instanceC", skipCurrentProcessLabel);
481483
const auto vint_blank = helper.index(edm::PRODUCT_TYPE, typeID_vint, "label", "instance", "process");
482484
const auto vint_blank_no_proc = helper.index(edm::PRODUCT_TYPE, typeID_vint, "label", "instance", 0);
483485
{

0 commit comments

Comments
 (0)