Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-30 02:33:06

0001 // -*- C++ -*-
0002 //
0003 // Package:     Services
0004 // Class  :     LoadAllDictionaries
0005 //
0006 /**\class LoadAllDictionaries
0007  
0008  Description: Loads all Capability dictionaries
0009  
0010  Usage:
0011  <usage>
0012  
0013  */
0014 //
0015 // Original Author:  Chris Jones
0016 //         Created:  Thu Sep 15 09:47:48 EDT 2005
0017 //
0018 
0019 // system include files
0020 
0021 // user include files
0022 #include "FWCore/ServiceRegistry/interface/ServiceMaker.h"
0023 
0024 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0025 #include "FWCore/PluginManager/interface/PluginManager.h"
0026 #include "FWCore/PluginManager/interface/PluginCapabilities.h"
0027 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0028 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0029 
0030 namespace edm {
0031   namespace service {
0032     class LoadAllDictionaries {
0033     public:
0034       LoadAllDictionaries(const edm::ParameterSet&);
0035       LoadAllDictionaries(const LoadAllDictionaries&) = delete;                   // stop default
0036       const LoadAllDictionaries& operator=(const LoadAllDictionaries&) = delete;  // stop default
0037 
0038       //virtual ~LoadAllDictionaries();
0039 
0040       // ---------- const member functions ---------------------
0041 
0042       // ---------- static member functions --------------------
0043       static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0044 
0045       // ---------- member functions ---------------------------
0046 
0047     private:
0048       // ---------- member data --------------------------------
0049     };
0050   }  // namespace service
0051 }  // namespace edm
0052 
0053 //
0054 // constants, enums and typedefs
0055 //
0056 
0057 //
0058 // static data member definitions
0059 //
0060 
0061 //
0062 // constructors and destructor
0063 //
0064 edm::service::LoadAllDictionaries::LoadAllDictionaries(const edm::ParameterSet& iConfig) {
0065   bool doLoad(iConfig.getUntrackedParameter<bool>("doLoad"));
0066   if (doLoad) {
0067     edmplugin::PluginManager* db = edmplugin::PluginManager::get();
0068 
0069     typedef edmplugin::PluginManager::CategoryToInfos CatToInfos;
0070 
0071     CatToInfos::const_iterator itFound = db->categoryToInfos().find("Capability");
0072 
0073     if (itFound == db->categoryToInfos().end()) {
0074       return;
0075     }
0076     std::string lastClass;
0077     const std::string mystring("edm::Wrapper");
0078 
0079     for (edmplugin::PluginManager::Infos::const_iterator itInfo = itFound->second.begin(),
0080                                                          itInfoEnd = itFound->second.end();
0081          itInfo != itInfoEnd;
0082          ++itInfo) {
0083       if (lastClass == itInfo->name_) {
0084         continue;
0085       }
0086 
0087       lastClass = itInfo->name_;
0088       if (lastClass.find(mystring) != std::string::npos) {
0089         edmplugin::PluginCapabilities::get()->load(lastClass);
0090       }
0091       //NOTE: since we have the library already, we could be more efficient if we just load it ourselves
0092     }
0093   }
0094 }
0095 
0096 void edm::service::LoadAllDictionaries::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0097   edm::ParameterSetDescription desc;
0098   desc.addUntracked<bool>("doLoad", true)->setComment("Only if 'true' do we load all dictionaries");
0099   descriptions.add("LoadAllDictionaries", desc);
0100   descriptions.setComment(
0101       "This service allows you to force all known dictionaries to be loaded at the beginning of the job");
0102 }
0103 
0104 using edm::service::LoadAllDictionaries;
0105 DEFINE_FWK_SERVICE_MAKER(LoadAllDictionaries, edm::serviceregistry::ParameterSetMaker<LoadAllDictionaries>);