CMS 3D CMS Logo

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.2 2008/01/18 20:10:31 wmtan 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 
00022 #include "boost/bind.hpp"
00023 #include "boost/mem_fn.hpp"
00024 #include "sigc++/signal.h"
00025 
00026 #include <algorithm>
00027 #include <iostream>
00028 #include <string>
00029 #include <map>
00030 
00031 //
00032 // constants, enums and typedefs
00033 //
00034 
00035 //
00036 // static data member definitions
00037 //
00038 
00039 //
00040 // constructors and destructor
00041 //
00042 using namespace edmplugin;
00043 
00044 PrintLoadingPlugins::PrintLoadingPlugins()
00045 {   
00046    PluginManager *pm = PluginManager::get();
00047 
00048    pm->askedToLoadCategoryWithPlugin_.connect(boost::bind(boost::mem_fn(&PrintLoadingPlugins::askedToLoad),this, _1,_2));
00049    
00050    pm->goingToLoad_.connect(boost::bind(boost::mem_fn(&PrintLoadingPlugins::goingToLoad),this, _1));
00051 
00052    
00053   
00054 }
00055 
00056 // PrintLoadingPlugins::PrintLoadingPlugins(const PrintLoadingPlugins& rhs)
00057 // {
00058 //    // do actual copying here;
00059 // }
00060 
00061 PrintLoadingPlugins::~PrintLoadingPlugins()
00062 {
00063 }
00064 
00065 //
00066 // assignment operators
00067 //
00068 // const PrintLoadingPlugins& PrintLoadingPlugins::operator=(const PrintLoadingPlugins& rhs)
00069 // {
00070 //   //An exception safe implementation is
00071 //   PrintLoadingPlugins temp(rhs);
00072 //   swap(rhs);
00073 //
00074 //   return *this;
00075 // }
00076 
00077 //
00078 // member functions
00079 //
00080 
00081  namespace{
00082     struct PICompare {
00083           bool operator()(const PluginInfo& iLHS,
00084                           const PluginInfo& iRHS) const {
00085              return iLHS.name_ < iRHS.name_;
00086           }
00087     };
00088  }
00089 
00090 void PrintLoadingPlugins::askedToLoad(const std::string& iCategory,
00091                                       const std::string& iPlugin)
00092 { 
00093    PluginManager *pm = PluginManager::get();
00094 
00095    const PluginManager::CategoryToInfos& category = pm->categoryToInfos();
00096 
00097    PluginManager::CategoryToInfos::const_iterator itFound = category.find(iCategory);
00098 
00099    std::string libname("Not found");
00100    
00101    if(itFound != category.end()) {
00102       
00103       PluginInfo i;
00104       
00105       i.name_ = iPlugin;
00106       
00107       typedef std::vector<PluginInfo>::const_iterator PIItr;
00108       
00109       std::pair<PIItr,PIItr> range = std::equal_range(itFound->second.begin(),itFound->second.end(),i,PICompare());
00110       
00111       if(range.second - range.first > 1){
00112          
00113          const boost::filesystem::path& loadable = range.first->loadable_;
00114          
00115          libname = loadable.native_file_string();
00116          
00117       }
00118       
00119       edm::LogAbsolute("GetPlugin")<<"Getting> '"<<iCategory<< "' "<<iPlugin 
00120                                    <<"\n         from "<<libname <<std::endl;
00121    }
00122    
00123 }
00124 
00125 void PrintLoadingPlugins::goingToLoad(const boost::filesystem::path& Loadable_)
00126 
00127 {
00128   edm::LogAbsolute("LoadLib")<<"Loading> "<<Loadable_.native_file_string()<< std::endl;
00129 }
00130 
00131 
00132 //
00133 // const member functions
00134 //
00135 
00136 //
00137 // static member functions
00138 //

Generated on Tue Jun 9 17:36:39 2009 for CMSSW by  doxygen 1.5.4