Skip to content

Commit

Permalink
Added removeSchedulingTokensFromModuleLabel function
Browse files Browse the repository at this point in the history
Function removes tokens added by the framework to denote how to
schedule a module.
  • Loading branch information
Dr15Jones committed Jan 3, 2023
1 parent 9eb6ddb commit 06fbef4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions FWCore/Utilities/interface/path_configuration.h
Expand Up @@ -35,6 +35,9 @@ namespace edm::path_configuration {
//Takes the Parameter associated to a given Path and converts it to the list of modules
// in the same order as the Path's position bits
std::vector<std::string> configurationToModuleBitPosition(std::vector<std::string>);

//removes any scheduling tokens from the module's label
std::string removeSchedulingTokensFromModuleLabel(std::string iLabel);
} // namespace edm::path_configuration

#endif
13 changes: 13 additions & 0 deletions FWCore/Utilities/src/path_configuration.cc
Expand Up @@ -35,4 +35,17 @@ namespace edm::path_configuration {
return iConfig;
}

std::string removeSchedulingTokensFromModuleLabel(std::string iLabel) {
constexpr std::array<char, 4> s_tokens = {{'!', '-', '+', '|'}};
if (not iLabel.empty()) {
for (auto t : s_tokens) {
if (t == iLabel[0]) {
iLabel.erase(0, 1);
break;
}
}
}
return iLabel;
}

} // namespace edm::path_configuration
13 changes: 13 additions & 0 deletions FWCore/Utilities/test/test_catch2_path_configuration.cc
@@ -0,0 +1,13 @@
#include "FWCore/Utilities/interface/path_configuration.h"
#include "catch.hpp"

using namespace edm::path_configuration;
TEST_CASE("Test path_configuration", "[path_configuration]") {
SECTION("removeSchedulingTokensFromModuleLabel") {
SECTION("no tokens") { REQUIRE("foo" == removeSchedulingTokensFromModuleLabel("foo")); }
SECTION("+") { REQUIRE("foo" == removeSchedulingTokensFromModuleLabel("+foo")); }
SECTION("-") { REQUIRE("foo" == removeSchedulingTokensFromModuleLabel("-foo")); }
SECTION("|") { REQUIRE("foo" == removeSchedulingTokensFromModuleLabel("|foo")); }
SECTION("!") { REQUIRE("foo" == removeSchedulingTokensFromModuleLabel("!foo")); }
}
}

0 comments on commit 06fbef4

Please sign in to comment.