CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/FWCore/ParameterSet/src/ProcessDesc.cc

Go to the documentation of this file.
00001 
00002 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00003 #include "FWCore/ParameterSet/interface/ProcessDesc.h"
00004 #include "FWCore/Utilities/interface/EDMException.h"
00005 
00006 namespace edm {
00007 
00008   ProcessDesc::ProcessDesc(boost::shared_ptr<ParameterSet> pset) :
00009       pset_(pset), services_(pset_->popVParameterSet(std::string("services")).release()) {
00010   }
00011 
00012   ProcessDesc::ProcessDesc(std::string const&) :
00013       pset_(new ParameterSet),
00014       services_(new std::vector<ParameterSet>()) {
00015     throw Exception(errors::Configuration,"Old config strings no longer accepted");
00016   }
00017 
00018   ProcessDesc::~ProcessDesc() {
00019   }
00020 
00021   boost::shared_ptr<ParameterSet>
00022   ProcessDesc::getProcessPSet() const {
00023     return pset_;
00024   }
00025 
00026   boost::shared_ptr<std::vector<ParameterSet> >
00027   ProcessDesc::getServicesPSets() const {
00028     return services_;
00029   }
00030 
00031   void ProcessDesc::addService(ParameterSet& pset) {
00032     // The standard services should be initialized first.
00033     services_->insert(services_->begin(), pset);
00034   }
00035 
00036   void ProcessDesc::addService(std::string const& service) {
00037     ParameterSet newpset;
00038     newpset.addParameter<std::string>("@service_type", service);
00039     addService(newpset);
00040   }
00041 
00042   void ProcessDesc::addDefaultService(std::string const& service) {
00043     typedef std::vector<ParameterSet>::iterator Iter;
00044     for(Iter it = services_->begin(), itEnd = services_->end(); it != itEnd; ++it) {
00045       std::string name = it->getParameter<std::string>("@service_type");
00046       if (name == service) {
00047         // Use the configured service.  Don't add a default.
00048         // However, the service needs to be moved to the front because it is a standard service.
00049         ParameterSet pset = *it;
00050         services_->erase(it);
00051         addService(pset);
00052         return;
00053       }
00054     }
00055     addService(service);
00056   }
00057 
00058   void ProcessDesc::addForcedService(std::string const& service) {
00059     typedef std::vector<ParameterSet>::iterator Iter;
00060     for(Iter it = services_->begin(), itEnd = services_->end(); it != itEnd; ++it) {
00061       std::string name = it->getParameter<std::string>("@service_type");
00062       if (name == service) {
00063         // Remove the configured service before adding the default.
00064         services_->erase(it);
00065         break;
00066       }
00067     }
00068     addService(service);
00069   }
00070 
00071   void ProcessDesc::addServices(std::vector<std::string> const& defaultServices,
00072                                 std::vector<std::string> const& forcedServices) {
00073     // Add the default services to services_.
00074     for(std::vector<std::string>::const_iterator i = defaultServices.begin(), iEnd = defaultServices.end();
00075          i != iEnd; ++i) {
00076       addDefaultService(*i);
00077     }
00078     // Add the forced services to services_.
00079     for(std::vector<std::string>::const_iterator i = forcedServices.begin(), iEnd = forcedServices.end();
00080          i != iEnd; ++i) {
00081       addForcedService(*i);
00082     }
00083   }
00084 
00085   std::string ProcessDesc::dump() const {
00086     std::string out = pset_->dump();
00087     for (std::vector<ParameterSet>::const_iterator it = services_->begin(), itEnd = services_->end(); it != itEnd; ++it) {
00088       out += it->dump();
00089     }
00090     return out;
00091   }
00092 } // namespace edm