Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
cet::PluginFactory Class Reference

#include <PluginFactory.h>

Inheritance diagram for cet::PluginFactory:
cet::BasicPluginFactory

Public Member Functions

 PluginFactory (cet::search_path const &search_path, std::string const &suffix="plugin")
 
void setDiagReleaseVersion (std::string const &rv)
 
void setDiagReleaseVersion (std::function< std::string()> rvf)
 
template<typename RESULT_TYPE , typename... ARGS>
RESULT_TYPE call (std::string const &libspec, std::string const &funcname, ARGS &&...args) const
 
template<typename RESULT_TYPE , typename... ARGS>
auto find (std::string const &funcname, std::string const &libspec) const -> RESULT_TYPE(*)(ARGS...)
 
template<typename RESULT_TYPE , typename... ARGS>
auto find (std::string const &funcname, std::string const &libspec, LibraryManager::nothrow_t) const -> RESULT_TYPE(*)(ARGS...)
 
template<typename FUNCTION_TYPE >
std::enable_if_t< std::is_function_v< FUNCTION_TYPE >, FUNCTION_TYPE * > find (std::string const &funcname, std::string const &libspec) const
 
virtual ~PluginFactory ()=default
 
 PluginFactory (PluginFactory const &)=delete
 
PluginFactoryoperator= (PluginFactory const &)=delete
 

Static Public Attributes

static LibraryManager::nothrow_t nothrow
 

Private Member Functions

template<typename T >
void resolveSymbolOrThrow_ (std::string const &libspec, std::string const &funcname, T &symbol) const
 
std::string releaseVersion_ () const
 

Private Attributes

LibraryManager lm_
 
std::string releaseVersionString_ {}
 
std::function< std::string()> releaseVersionFunc_ {}
 

Detailed Description

Definition at line 35 of file PluginFactory.h.

Constructor & Destructor Documentation

cet::PluginFactory::PluginFactory ( cet::search_path const &  search_path,
std::string const &  suffix = "plugin" 
)
explicit

Definition at line 5 of file PluginFactory.cc.

7  : lm_{search_path, suffix}
8 {}
LibraryManager lm_
Definition: PluginFactory.h:88
virtual cet::PluginFactory::~PluginFactory ( )
virtualdefault
cet::PluginFactory::PluginFactory ( PluginFactory const &  )
delete

Member Function Documentation

template<typename RESULT_TYPE , typename... ARGS>
RESULT_TYPE cet::PluginFactory::call ( std::string const &  libspec,
std::string const &  funcname,
ARGS &&...  args 
) const
inline

Definition at line 107 of file PluginFactory.h.

110 {
111  return (*find<RESULT_TYPE, ARGS...>(libspec, funcname))(
112  std::forward<ARGS>(args)...);
113 }
static QCString args
Definition: declinfo.cpp:674
template<typename RESULT_TYPE , typename... ARGS>
auto cet::PluginFactory::find ( std::string const &  funcname,
std::string const &  libspec 
) const -> RESULT_TYPE (*)(ARGS...)
inline

Definition at line 127 of file PluginFactory.h.

130 {
131  RESULT_TYPE (*symbol)(ARGS...) = nullptr;
132  resolveSymbolOrThrow_(libspec, funcname, symbol);
133  return symbol;
134 }
void resolveSymbolOrThrow_(std::string const &libspec, std::string const &funcname, T &symbol) const
template<typename RESULT_TYPE , typename... ARGS>
auto cet::PluginFactory::find ( std::string const &  funcname,
std::string const &  libspec,
LibraryManager::nothrow_t  nothrow 
) const -> RESULT_TYPE (*)(ARGS...)
inline

Definition at line 138 of file PluginFactory.h.

142 {
143  return lm_.getSymbolByLibspec<RESULT_TYPE (*)(ARGS...)>(
144  libspec, funcname, nothrow);
145 }
static LibraryManager::nothrow_t nothrow
Definition: PluginFactory.h:54
LibraryManager lm_
Definition: PluginFactory.h:88
T getSymbolByLibspec(std::string const &libspec, std::string const &sym_name) const
template<typename FUNCTION_TYPE >
std::enable_if_t< std::is_function_v< FUNCTION_TYPE >, FUNCTION_TYPE * > cet::PluginFactory::find ( std::string const &  funcname,
std::string const &  libspec 
) const
inline

Definition at line 117 of file PluginFactory.h.

119 {
120  FUNCTION_TYPE** symbol{nullptr};
121  resolveSymbolOrThrow_(libspec, funcname, symbol);
122  return *symbol;
123 }
void resolveSymbolOrThrow_(std::string const &libspec, std::string const &funcname, T &symbol) const
PluginFactory& cet::PluginFactory::operator= ( PluginFactory const &  )
delete
std::string cet::PluginFactory::releaseVersion_ ( ) const
private

Definition at line 11 of file PluginFactory.cc.

12 {
14  if (releaseVersionFunc_) {
15  result = releaseVersionFunc_();
16  } else {
17  result = releaseVersionString_.empty() ? "Unknown" : releaseVersionString_;
18  }
19  return result;
20 }
static QCString result
std::string string
Definition: nybbler.cc:12
std::function< std::string()> releaseVersionFunc_
Definition: PluginFactory.h:90
std::string releaseVersionString_
Definition: PluginFactory.h:89
template<typename T >
void cet::PluginFactory::resolveSymbolOrThrow_ ( std::string const &  libspec,
std::string const &  funcname,
T &  symbol 
) const
private

Definition at line 149 of file PluginFactory.h.

152 {
153  try {
154  lm_.getSymbolByLibspec(libspec, funcname, symbol);
155  }
156  catch (exception const& e) {
158  e, "Plugin", libspec, releaseVersion_());
159  }
160  if (symbol == nullptr) {
161  throw exception("Configuration", "BadPluginLibrary")
162  << "Plugin " << libspec << " with version " << releaseVersion_()
163  << " has internal symbol definition problems: consult an expert.";
164  }
165 }
std::string releaseVersion_() const
LibraryManager lm_
Definition: PluginFactory.h:88
T getSymbolByLibspec(std::string const &libspec, std::string const &sym_name) const
const double e
void wrapLibraryManagerException(cet::exception const &e, std::string const &item_type, std::string const &libspec, std::string const &release)
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void cet::PluginFactory::setDiagReleaseVersion ( std::string const &  rv)
inline

Definition at line 100 of file PluginFactory.h.

101 {
103 }
std::string releaseVersionString_
Definition: PluginFactory.h:89
void cet::PluginFactory::setDiagReleaseVersion ( std::function< std::string()>  rvf)
inline

Definition at line 94 of file PluginFactory.h.

95 {
96  releaseVersionFunc_ = rvf;
97 }
std::function< std::string()> releaseVersionFunc_
Definition: PluginFactory.h:90

Member Data Documentation

LibraryManager cet::PluginFactory::lm_
private

Definition at line 88 of file PluginFactory.h.

LibraryManager::nothrow_t cet::PluginFactory::nothrow
static

Definition at line 54 of file PluginFactory.h.

std::function<std::string()> cet::PluginFactory::releaseVersionFunc_ {}
private

Definition at line 90 of file PluginFactory.h.

std::string cet::PluginFactory::releaseVersionString_ {}
private

Definition at line 89 of file PluginFactory.h.


The documentation for this class was generated from the following files: