CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/FWCore/PluginManager/interface/PluginFactoryBase.h

Go to the documentation of this file.
00001 #ifndef FWCore_PluginManager_PluginFactoryBase_h
00002 #define FWCore_PluginManager_PluginFactoryBase_h
00003 // -*- C++ -*-
00004 //
00005 // Package:     PluginManager
00006 // Class  :     PluginFactoryBase
00007 // 
00017 //
00018 // Original Author:  Chris Jones
00019 //         Created:  Wed Apr  4 12:24:44 EDT 2007
00020 // $Id: PluginFactoryBase.h,v 1.7 2009/10/26 14:06:45 eulisse Exp $
00021 //
00022 
00023 // system include files
00024 #include <string>
00025 #include <vector>
00026 #include <map>
00027 #include "sigc++/signal.h"
00028 // user include files
00029 #include "FWCore/PluginManager/interface/PluginInfo.h"
00030 
00031 // forward declarations
00032 namespace edmplugin {
00033 class PluginFactoryBase
00034 {
00035 
00036    public:
00037       PluginFactoryBase() {}
00038       virtual ~PluginFactoryBase();
00039 
00040       typedef std::vector<std::pair<void*, std::string> > PMakers;
00041       typedef std::map<std::string, PMakers > Plugins;
00042 
00043       // ---------- const member functions ---------------------
00044 
00046       virtual std::vector<PluginInfo> available() const;
00047 
00049       virtual const std::string& category() const = 0;
00050       
00052       mutable sigc::signal<void,const std::string&, const PluginInfo&> newPluginAdded_;
00053 
00054       // ---------- static member functions --------------------
00055 
00056       // ---------- member functions ---------------------------
00057 
00058    protected:
00063       void finishedConstruction();
00064       
00065       void newPlugin(const std::string& iName);
00066 
00067       //since each inheriting class has its own Container type to hold their PMakers
00068       // this function allows them to share the same code when doing the lookup
00069       // this routine will throw an exception if iName is unknown therefore the return value is always valid
00070       Plugins::const_iterator findPMaker(const std::string& iName) const;
00071 
00072       //similar to findPMaker but will return 'end()' if iName is known
00073       Plugins::const_iterator tryToFindPMaker(const std::string& iName) const;
00074       
00075       void fillInfo(const PMakers &makers,
00076                     PluginInfo& iInfo,
00077                     std::vector<PluginInfo>& iReturn ) const;
00078 
00079       void fillAvailable(std::vector<PluginInfo>& iReturn) const;
00080 
00081       void registerPMaker(void* iPMaker, const std::string& iName);
00082       
00083       Plugins m_plugins;
00084       
00085    private:
00086       PluginFactoryBase(const PluginFactoryBase&); // stop default
00087 
00088       const PluginFactoryBase& operator=(const PluginFactoryBase&); // stop default
00089 
00090       void checkProperLoadable(const std::string& iName, const std::string& iLoadedFrom) const;
00091       // ---------- member data --------------------------------
00092 
00093 };
00094 
00095 }
00096 #endif