CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ProcessDesc.cc
Go to the documentation of this file.
1 
5 
6 namespace edm {
7 
8  ProcessDesc::ProcessDesc(std::shared_ptr<ParameterSet> pset) :
9  pset_(pset), services_(pset_->popVParameterSet(std::string("services")).release()) {
10  }
11 
13  pset_(new ParameterSet),
14  services_(new std::vector<ParameterSet>()) {
15  throw Exception(errors::Configuration,"Old config strings no longer accepted");
16  }
17 
19  }
20 
22  // The standard services should be initialized first.
23  services_->insert(services_->begin(), pset);
24  }
25 
26  void ProcessDesc::addService(std::string const& service) {
27  ParameterSet newpset;
28  newpset.addParameter<std::string>("@service_type", service);
29  addService(newpset);
30  }
31 
33  typedef std::vector<ParameterSet>::iterator Iter;
34  for(Iter it = services_->begin(), itEnd = services_->end(); it != itEnd; ++it) {
35  std::string name = it->getParameter<std::string>("@service_type");
36  if (name == service) {
37  // Use the configured service. Don't add a default.
38  // However, the service needs to be moved to the front because it is a standard service.
39  ParameterSet pset = *it;
40  services_->erase(it);
41  addService(pset);
42  return;
43  }
44  }
45  addService(service);
46  }
47 
49  typedef std::vector<ParameterSet>::iterator Iter;
50  for(Iter it = services_->begin(), itEnd = services_->end(); it != itEnd; ++it) {
51  std::string name = it->getParameter<std::string>("@service_type");
52  if (name == service) {
53  // Remove the configured service before adding the default.
54  services_->erase(it);
55  break;
56  }
57  }
58  addService(service);
59  }
60 
61  void ProcessDesc::addServices(std::vector<std::string> const& defaultServices,
62  std::vector<std::string> const& forcedServices) {
63  // Add the default services to services_.
64  for(std::vector<std::string>::const_iterator i = defaultServices.begin(), iEnd = defaultServices.end();
65  i != iEnd; ++i) {
67  }
68  // Add the forced services to services_.
69  for(std::vector<std::string>::const_iterator i = forcedServices.begin(), iEnd = forcedServices.end();
70  i != iEnd; ++i) {
72  }
73  }
74 
76  std::string out = pset_->dump();
77  for (std::vector<ParameterSet>::const_iterator it = services_->begin(), itEnd = services_->end(); it != itEnd; ++it) {
78  out += it->dump();
79  }
80  return out;
81  }
82 } // namespace edm
int i
Definition: DBlmapReader.cc:9
void addDefaultService(std::string const &service)
add a service if it&#39;s not already there
Definition: ProcessDesc.cc:32
edm::propagate_const< std::shared_ptr< ParameterSet > > pset_
Definition: ProcessDesc.h:45
void addServices(std::vector< std::string > const &defaultServices, std::vector< std::string > const &forcedServices=std::vector< std::string >())
add some default services and forced services
Definition: ProcessDesc.cc:61
void addService(ParameterSet &pset)
Definition: ProcessDesc.cc:21
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:144
void addForcedService(std::string const &service)
add a service and replace it if it&#39;s already there
Definition: ProcessDesc.cc:48
edm::propagate_const< std::shared_ptr< std::vector< ParameterSet > > > services_
Definition: ProcessDesc.h:46
std::string dump() const
Definition: ProcessDesc.cc:75
ProcessDesc(std::shared_ptr< ParameterSet > pset)
Definition: ProcessDesc.cc:8