CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/FWCore/Services/src/PrintLoadingPlugins.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Services
00004 // Class  :     PrintLoadingPlugins
00005 // 
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  
00010 //         Created:  Thu Dec 13 15:00:49 EST 2007
00011 // $Id: PrintLoadingPlugins.cc,v 1.5 2011/08/24 11:41:25 eulisse Exp $
00012 //
00013 
00014 // system include files
00015 
00016 // user include files
00017 #include "FWCore/Services/interface/PrintLoadingPlugins.h"
00018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00019 #include "FWCore/PluginManager/interface/PluginManager.h"
00020 #include "FWCore/PluginManager/interface/PluginInfo.h"
00021 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
00022 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
00023 
00024 #include "boost/bind.hpp"
00025 #include "boost/mem_fn.hpp"
00026 #include "sigc++/signal.h"
00027 
00028 #include <algorithm>
00029 #include <iostream>
00030 #include <string>
00031 #include <map>
00032 
00033 //
00034 // constants, enums and typedefs
00035 //
00036 
00037 //
00038 // static data member definitions
00039 //
00040 
00041 //
00042 // constructors and destructor
00043 //
00044 using namespace edmplugin;
00045 
00046 PrintLoadingPlugins::PrintLoadingPlugins()
00047 {   
00048    PluginManager *pm = PluginManager::get();
00049 
00050    pm->askedToLoadCategoryWithPlugin_.connect(boost::bind(boost::mem_fn(&PrintLoadingPlugins::askedToLoad),this, _1,_2));
00051    
00052    pm->goingToLoad_.connect(boost::bind(boost::mem_fn(&PrintLoadingPlugins::goingToLoad),this, _1));
00053 
00054    
00055   
00056 }
00057 
00058 // PrintLoadingPlugins::PrintLoadingPlugins(const PrintLoadingPlugins& rhs)
00059 // {
00060 //    // do actual copying here;
00061 // }
00062 
00063 PrintLoadingPlugins::~PrintLoadingPlugins()
00064 {
00065 }
00066 
00067 void PrintLoadingPlugins::fillDescriptions(edm::ConfigurationDescriptions & descriptions) {
00068   edm::ParameterSetDescription desc;
00069   descriptions.add("PrintLoadingPlugins", desc);
00070   descriptions.setComment("This service logs each request to load a plugin.");
00071 }
00072 
00073 //
00074 // assignment operators
00075 //
00076 // const PrintLoadingPlugins& PrintLoadingPlugins::operator=(const PrintLoadingPlugins& rhs)
00077 // {
00078 //   //An exception safe implementation is
00079 //   PrintLoadingPlugins temp(rhs);
00080 //   swap(rhs);
00081 //
00082 //   return *this;
00083 // }
00084 
00085 //
00086 // member functions
00087 //
00088 
00089  namespace{
00090     struct PICompare {
00091           bool operator()(const PluginInfo& iLHS,
00092                           const PluginInfo& iRHS) const {
00093              return iLHS.name_ < iRHS.name_;
00094           }
00095     };
00096  }
00097 
00098 void PrintLoadingPlugins::askedToLoad(const std::string& iCategory,
00099                                       const std::string& iPlugin)
00100 { 
00101    PluginManager *pm = PluginManager::get();
00102 
00103    const PluginManager::CategoryToInfos& category = pm->categoryToInfos();
00104 
00105    PluginManager::CategoryToInfos::const_iterator itFound = category.find(iCategory);
00106 
00107    std::string libname("Not found");
00108    
00109    if(itFound != category.end()) {
00110       
00111       PluginInfo i;
00112       
00113       i.name_ = iPlugin;
00114       
00115       typedef std::vector<PluginInfo>::const_iterator PIItr;
00116       
00117       std::pair<PIItr,PIItr> range = std::equal_range(itFound->second.begin(),itFound->second.end(),i,PICompare());
00118       
00119       if(range.second - range.first > 1){
00120          
00121          const boost::filesystem::path& loadable = range.first->loadable_;
00122          
00123          libname = loadable.string();
00124          
00125       }
00126       
00127       edm::LogAbsolute("GetPlugin")<<"Getting> '"<<iCategory<< "' "<<iPlugin 
00128                                    <<"\n         from "<<libname <<std::endl;
00129    }
00130    
00131 }
00132 
00133 void PrintLoadingPlugins::goingToLoad(const boost::filesystem::path& Loadable_)
00134 
00135 {
00136   edm::LogAbsolute("LoadLib")<<"Loading> "<<Loadable_.string()<< std::endl;
00137 }
00138 
00139 
00140 //
00141 // const member functions
00142 //
00143 
00144 //
00145 // static member functions
00146 //