CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PluginFactoryBase.h
Go to the documentation of this file.
1 #ifndef FWCore_PluginManager_PluginFactoryBase_h
2 #define FWCore_PluginManager_PluginFactoryBase_h
3 // -*- C++ -*-
4 //
5 // Package: PluginManager
6 // Class : PluginFactoryBase
7 //
17 //
18 // Original Author: Chris Jones
19 // Created: Wed Apr 4 12:24:44 EDT 2007
20 // $Id: PluginFactoryBase.h,v 1.7 2009/10/26 14:06:45 eulisse Exp $
21 //
22 
23 // system include files
24 #include <string>
25 #include <vector>
26 #include <map>
27 #include "sigc++/signal.h"
28 // user include files
30 
31 // forward declarations
32 namespace edmplugin {
34 {
35 
36  public:
38  virtual ~PluginFactoryBase();
39 
40  typedef std::vector<std::pair<void*, std::string> > PMakers;
41  typedef std::map<std::string, PMakers > Plugins;
42 
43  // ---------- const member functions ---------------------
44 
46  virtual std::vector<PluginInfo> available() const;
47 
49  virtual const std::string& category() const = 0;
50 
52  mutable sigc::signal<void,const std::string&, const PluginInfo&> newPluginAdded_;
53 
54  // ---------- static member functions --------------------
55 
56  // ---------- member functions ---------------------------
57 
58  protected:
63  void finishedConstruction();
64 
65  void newPlugin(const std::string& iName);
66 
67  //since each inheriting class has its own Container type to hold their PMakers
68  // this function allows them to share the same code when doing the lookup
69  // this routine will throw an exception if iName is unknown therefore the return value is always valid
70  Plugins::const_iterator findPMaker(const std::string& iName) const;
71 
72  //similar to findPMaker but will return 'end()' if iName is known
73  Plugins::const_iterator tryToFindPMaker(const std::string& iName) const;
74 
75  void fillInfo(const PMakers &makers,
76  PluginInfo& iInfo,
77  std::vector<PluginInfo>& iReturn ) const;
78 
79  void fillAvailable(std::vector<PluginInfo>& iReturn) const;
80 
81  void registerPMaker(void* iPMaker, const std::string& iName);
82 
84 
85  private:
86  PluginFactoryBase(const PluginFactoryBase&); // stop default
87 
88  const PluginFactoryBase& operator=(const PluginFactoryBase&); // stop default
89 
90  void checkProperLoadable(const std::string& iName, const std::string& iLoadedFrom) const;
91  // ---------- member data --------------------------------
92 
93 };
94 
95 }
96 #endif
void registerPMaker(void *iPMaker, const std::string &iName)
std::vector< std::pair< void *, std::string > > PMakers
const PluginFactoryBase & operator=(const PluginFactoryBase &)
void fillAvailable(std::vector< PluginInfo > &iReturn) const
void checkProperLoadable(const std::string &iName, const std::string &iLoadedFrom) const
sigc::signal< void, const std::string &, const PluginInfo & > newPluginAdded_
signal containing plugin category, and plugin info for newly added plugin
void fillInfo(const PMakers &makers, PluginInfo &iInfo, std::vector< PluginInfo > &iReturn) const
std::map< std::string, PMakers > Plugins
virtual const std::string & category() const =0
returns the name of the category to which this plugin factory belongs
Plugins::const_iterator tryToFindPMaker(const std::string &iName) const
virtual std::vector< PluginInfo > available() const
return info about all plugins which are already available in the program
Plugins::const_iterator findPMaker(const std::string &iName) const
void newPlugin(const std::string &iName)