CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/FWCore/PluginManager/interface/PluginManager.h

Go to the documentation of this file.
00001 #ifndef FWCore_PluginManager_PluginManager_h
00002 #define FWCore_PluginManager_PluginManager_h
00003 // -*- C++ -*-
00004 //
00005 // Package:     PluginManager
00006 // Class  :     PluginManager
00007 // 
00016 //
00017 // Original Author:  Chris Jones
00018 //         Created:  Wed Apr  4 14:28:48 EDT 2007
00019 //
00020 
00021 // system include files
00022 #include <vector>
00023 #include <map>
00024 #include <string>
00025 #include <boost/filesystem/path.hpp>
00026 #include "boost/shared_ptr.hpp"
00027 #include "sigc++/signal.h"
00028 
00029 // user include files
00030 #include "FWCore/PluginManager/interface/SharedLibrary.h"
00031 #include "FWCore/PluginManager/interface/PluginInfo.h"
00032 
00033 // forward declarations
00034 namespace edmplugin {
00035   class DummyFriend;
00036   class PluginFactoryBase;
00037 class PluginManager
00038 {
00039    friend class DummyFriend;
00040   public:
00041      typedef std::vector<std::string> SearchPath;
00042      typedef std::vector<PluginInfo> Infos;
00043      typedef std::map<std::string, Infos > CategoryToInfos;
00044 
00045      class Config {
00046       public:
00047        Config() { }
00048        Config& searchPath(const SearchPath& iPath) {
00049          m_path = iPath;
00050          return *this;
00051        }
00052        const SearchPath& searchPath() const {
00053          return m_path;
00054        }
00055        private:
00056        SearchPath m_path;
00057      };
00058 
00059       ~PluginManager();
00060 
00061       // ---------- const member functions ---------------------
00062       const SharedLibrary& load(const std::string& iCategory,
00063                                 const std::string& iPlugin);
00064 
00065       const boost::filesystem::path& loadableFor(const std::string& iCategory,
00066                                                  const std::string& iPlugin);
00067       
00071       const CategoryToInfos& categoryToInfos() const {
00072         return categoryToInfos_;
00073       }
00074       
00075       //If can not find iPlugin in category iCategory return null pointer, any other failure will cause a throw
00076       const SharedLibrary* tryToLoad(const std::string& iCategory,
00077                                      const std::string& iPlugin);
00078       
00079       // ---------- static member functions --------------------
00081       static const std::string& loadingFile() { 
00082         return loadingLibraryNamed_();}
00083 
00085       static const std::string& staticallyLinkedLoadingFileName();
00086 
00087       
00088       static PluginManager* get();
00089       static PluginManager& configure(const Config& );
00090       
00091       static bool isAvailable();
00092       
00093       // ---------- member functions ---------------------------
00094       sigc::signal<void,const boost::filesystem::path&> goingToLoad_;
00095       sigc::signal<void,const SharedLibrary&> justLoaded_;
00096       sigc::signal<void,const std::string&,const std::string&> askedToLoadCategoryWithPlugin_;
00097    private:
00098       PluginManager(const Config&);
00099       PluginManager(const PluginManager&); // stop default
00100 
00101       const PluginManager& operator=(const PluginManager&); // stop default
00102 
00103       void newFactory(const PluginFactoryBase* );
00104       static std::string& loadingLibraryNamed_();
00105       static PluginManager*& singleton();
00106       
00107       const boost::filesystem::path& loadableFor_(const std::string& iCategory,
00108                                                   const std::string& iPlugin,
00109                                                   bool& ioThrowIfFailElseSucceedStatus);
00110       // ---------- member data --------------------------------
00111       SearchPath searchPath_;
00112       std::map<boost::filesystem::path, boost::shared_ptr<SharedLibrary> > loadables_;
00113       
00114       CategoryToInfos categoryToInfos_;
00115 };
00116 
00117 }
00118 #endif