Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 'on demand' Service building #16290

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion FWCore/ServiceRegistry/interface/ServicesManager.h
Expand Up @@ -83,7 +83,7 @@ namespace edm {
typeid(T).name(),
"'.\n");
} else {
itFoundMaker->second.add(const_cast<ServicesManager&>(*this));
const_cast<ServicesManager&>(*this).createServiceFor(itFoundMaker->second);
itFound = type2Service_.find(TypeIDBase(typeid(T)));
//the 'add()' should have put the service into the list
assert(itFound != type2Service_.end());
Expand Down Expand Up @@ -150,6 +150,7 @@ namespace edm {

void fillListOfMakers(std::vector<ParameterSet>&);
void createServices();
void createServiceFor(MakerHolder const&);

// ---------- member data --------------------------------
//hold onto the Manager passed in from the ServiceToken so that
Expand Down
64 changes: 34 additions & 30 deletions FWCore/ServiceRegistry/src/ServicesManager.cc
Expand Up @@ -267,6 +267,39 @@ namespace edm {
};
}

void
ServicesManager::createServiceFor(MakerHolder const& iMaker) {
std::string serviceType = iMaker.pset_->getParameter<std::string>("@service_type");
std::unique_ptr<ParameterSetDescriptionFillerBase> filler(
ParameterSetDescriptionFillerPluginFactory::get()->create(serviceType));
ConfigurationDescriptions descriptions(filler->baseType());
filler->fill(descriptions);

try {
convertException::wrap([&]() {
descriptions.validate(*(iMaker.pset_), serviceType);
});
}
catch (cms::Exception & iException) {
std::ostringstream ost;
ost << "Validating configuration of service of type " << serviceType;
iException.addContext(ost.str());
throw;
}
try {
convertException::wrap([&]() {
// This creates the service
iMaker.add(*this);
});
}
catch (cms::Exception & iException) {
std::ostringstream ost;
ost << "Constructing service of type " << serviceType;
iException.addContext(ost.str());
throw;
}
}

void
ServicesManager::createServices() {

Expand All @@ -291,36 +324,7 @@ namespace edm {
// Check to make sure this maker is still there. They are deleted
// sometimes and that is OK.
if(itMaker != type2Maker_->end()) {

std::string serviceType = itMaker->second.pset_->getParameter<std::string>("@service_type");
std::unique_ptr<ParameterSetDescriptionFillerBase> filler(
ParameterSetDescriptionFillerPluginFactory::get()->create(serviceType));
ConfigurationDescriptions descriptions(filler->baseType());
filler->fill(descriptions);

try {
convertException::wrap([&]() {
descriptions.validate(*(itMaker->second.pset_), serviceType);
});
}
catch (cms::Exception & iException) {
std::ostringstream ost;
ost << "Validating configuration of service of type " << serviceType;
iException.addContext(ost.str());
throw;
}
try {
convertException::wrap([&]() {
// This creates the service
itMaker->second.add(*this);
});
}
catch (cms::Exception & iException) {
std::ostringstream ost;
ost << "Constructing service of type " << serviceType;
iException.addContext(ost.str());
throw;
}
createServiceFor(itMaker->second);
}
}
//No longer need the makers
Expand Down