CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PluginManager.h
Go to the documentation of this file.
1 #ifndef FWCore_PluginManager_PluginManager_h
2 #define FWCore_PluginManager_PluginManager_h
3 // -*- C++ -*-
4 //
5 // Package: PluginManager
6 // Class : PluginManager
7 //
16 //
17 // Original Author: Chris Jones
18 // Created: Wed Apr 4 14:28:48 EDT 2007
19 //
20 
21 // system include files
22 #include <vector>
23 #include <map>
24 #include <string>
25 #include <boost/filesystem/path.hpp>
26 #include "boost/shared_ptr.hpp"
28 
29 // user include files
32 
33 // forward declarations
34 namespace edmplugin {
35  class DummyFriend;
36  class PluginFactoryBase;
38 {
39  friend class DummyFriend;
40  public:
41  typedef std::vector<std::string> SearchPath;
42  typedef std::vector<PluginInfo> Infos;
43  typedef std::map<std::string, Infos > CategoryToInfos;
44 
45  class Config {
46  public:
47  Config() { }
48  Config& searchPath(const SearchPath& iPath) {
49  m_path = iPath;
50  return *this;
51  }
52  const SearchPath& searchPath() const {
53  return m_path;
54  }
55  private:
57  };
58 
60 
61  // ---------- const member functions ---------------------
62  const SharedLibrary& load(const std::string& iCategory,
63  const std::string& iPlugin);
64 
65  const boost::filesystem::path& loadableFor(const std::string& iCategory,
66  const std::string& iPlugin);
67 
72  return categoryToInfos_;
73  }
74 
75  //If can not find iPlugin in category iCategory return null pointer, any other failure will cause a throw
76  const SharedLibrary* tryToLoad(const std::string& iCategory,
77  const std::string& iPlugin);
78 
79  // ---------- static member functions --------------------
81  static const std::string& loadingFile() {
82  return loadingLibraryNamed_();}
83 
86 
87 
88  static PluginManager* get();
89  static PluginManager& configure(const Config& );
90 
91  static bool isAvailable();
92 
93  // ---------- member functions ---------------------------
97  private:
98  PluginManager(const Config&);
99  PluginManager(const PluginManager&); // stop default
100 
101  const PluginManager& operator=(const PluginManager&); // stop default
102 
103  void newFactory(const PluginFactoryBase* );
105  static PluginManager*& singleton();
106 
107  const boost::filesystem::path& loadableFor_(const std::string& iCategory,
108  const std::string& iPlugin,
109  bool& ioThrowIfFailElseSucceedStatus);
110  // ---------- member data --------------------------------
112  std::map<boost::filesystem::path, boost::shared_ptr<SharedLibrary> > loadables_;
113 
115 };
116 
117 }
118 #endif
CategoryToInfos categoryToInfos_
const CategoryToInfos & categoryToInfos() const
Definition: PluginManager.h:71
std::map< boost::filesystem::path, boost::shared_ptr< SharedLibrary > > loadables_
const boost::filesystem::path & loadableFor(const std::string &iCategory, const std::string &iPlugin)
const SharedLibrary * tryToLoad(const std::string &iCategory, const std::string &iPlugin)
static PluginManager & configure(const Config &)
static PluginManager *& singleton()
const boost::filesystem::path & loadableFor_(const std::string &iCategory, const std::string &iPlugin, bool &ioThrowIfFailElseSucceedStatus)
static const std::string & staticallyLinkedLoadingFileName()
if the value returned from loadingFile matches this string then the file is statically linked ...
const SearchPath & searchPath() const
Definition: PluginManager.h:52
const PluginManager & operator=(const PluginManager &)
static const std::string & loadingFile()
file name of the shared object being loaded
Definition: PluginManager.h:81
std::map< std::string, Infos > CategoryToInfos
Definition: PluginManager.h:43
std::vector< std::string > SearchPath
Definition: PluginManager.h:41
edm::signalslot::Signal< void(const SharedLibrary &)> justLoaded_
Definition: PluginManager.h:95
edm::signalslot::Signal< void(const std::string &, const std::string &)> askedToLoadCategoryWithPlugin_
Definition: PluginManager.h:96
edm::signalslot::Signal< void(const boost::filesystem::path &)> goingToLoad_
Definition: PluginManager.h:94
Config & searchPath(const SearchPath &iPath)
Definition: PluginManager.h:48
static std::string & loadingLibraryNamed_()
std::vector< PluginInfo > Infos
Definition: PluginManager.h:42
void newFactory(const PluginFactoryBase *)
const SharedLibrary & load(const std::string &iCategory, const std::string &iPlugin)
PluginManager(const Config &)