CMS 3D CMS Logo

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 // $Id: PluginManager.h,v 1.5 2007/07/03 19:16:33 chrjones Exp $
00020 //
00021 
00022 // system include files
00023 #include <vector>
00024 #include <map>
00025 #include <string>
00026 #include <boost/filesystem/path.hpp>
00027 #include <boost/shared_ptr.hpp>
00028 #include "sigc++/signal.h"
00029 
00030 // user include files
00031 #include "FWCore/PluginManager/interface/SharedLibrary.h"
00032 #include "FWCore/PluginManager/interface/PluginInfo.h"
00033 
00034 // forward declarations
00035 namespace edmplugin {
00036   class DummyFriend;
00037   class PluginFactoryBase;
00038 class PluginManager
00039 {
00040    friend class DummyFriend;
00041   public:
00042      typedef std::vector<std::string> SearchPath;
00043      typedef std::vector<PluginInfo> Infos;
00044      typedef std::map<std::string, Infos > CategoryToInfos;
00045 
00046      class Config {
00047       public:
00048        Config() { }
00049        Config& searchPath(const SearchPath& iPath) {
00050          m_path = iPath;
00051          return *this;
00052        }
00053        const SearchPath& searchPath() const {
00054          return m_path;
00055        }
00056        private:
00057        SearchPath m_path;
00058      };
00059 
00060       ~PluginManager();
00061 
00062       // ---------- const member functions ---------------------
00063       const SharedLibrary& load(const std::string& iCategory,
00064                                 const std::string& iPlugin);
00065 
00066       const boost::filesystem::path& loadableFor(const std::string& iCategory,
00067                                                  const std::string& iPlugin);
00068       
00072       const CategoryToInfos& categoryToInfos() const {
00073         return categoryToInfos_;
00074       }
00075       
00076       //If can not find iPlugin in category iCategory return null pointer, any other failure will cause a throw
00077       const SharedLibrary* tryToLoad(const std::string& iCategory,
00078                                      const std::string& iPlugin);
00079       
00080       // ---------- static member functions --------------------
00082       static const std::string& loadingFile() { 
00083         return loadingLibraryNamed_();}
00084 
00086       static const std::string& staticallyLinkedLoadingFileName();
00087 
00088       
00089       static PluginManager* get();
00090       static PluginManager& configure(const Config& );
00091       
00092       static bool isAvailable();
00093       
00094       // ---------- member functions ---------------------------
00095       sigc::signal<void,const boost::filesystem::path&> goingToLoad_;
00096       sigc::signal<void,const SharedLibrary&> justLoaded_;
00097       sigc::signal<void,const std::string&,const std::string&> askedToLoadCategoryWithPlugin_;
00098    private:
00099       PluginManager(const Config&);
00100       PluginManager(const PluginManager&); // stop default
00101 
00102       const PluginManager& operator=(const PluginManager&); // stop default
00103 
00104       void newFactory(const PluginFactoryBase* );
00105       static std::string& loadingLibraryNamed_();
00106       static PluginManager*& singleton();
00107       
00108       const boost::filesystem::path& loadableFor_(const std::string& iCategory,
00109                                                   const std::string& iPlugin,
00110                                                   bool& ioThrowIfFailElseSucceedStatus);
00111       // ---------- member data --------------------------------
00112       SearchPath searchPath_;
00113       std::map<boost::filesystem::path, boost::shared_ptr<SharedLibrary> > loadables_;
00114       
00115       CategoryToInfos categoryToInfos_;
00116 };
00117 
00118 }
00119 #endif

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