CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
edm::eventsetup::ComponentFactory< T > Class Template Reference

#include <ComponentFactory.h>

Public Types

typedef T::base_type base_type
 
typedef ComponentMakerBase< TMaker
 
typedef std::map< std::string, std::shared_ptr< Maker > > MakerMap
 

Public Member Functions

std::shared_ptr< base_typeaddTo (EventSetupsController &esController, EventSetupProvider &iProvider, edm::ParameterSet const &iConfiguration, bool replaceExisting=false) const
 
 ComponentFactory ()
 

Static Public Member Functions

static ComponentFactory< T > const * get ()
 

Private Member Functions

 ComponentFactory (const ComponentFactory &)
 
const ComponentFactoryoperator= (const ComponentFactory &)
 

Private Attributes

MakerMap makers_
 

Detailed Description

template<typename T>
class edm::eventsetup::ComponentFactory< T >

Definition at line 42 of file ComponentFactory.h.

Member Typedef Documentation

template<typename T >
typedef T::base_type edm::eventsetup::ComponentFactory< T >::base_type

Definition at line 49 of file ComponentFactory.h.

template<typename T >
typedef ComponentMakerBase<T> edm::eventsetup::ComponentFactory< T >::Maker

Definition at line 47 of file ComponentFactory.h.

template<typename T >
typedef std::map<std::string, std::shared_ptr<Maker> > edm::eventsetup::ComponentFactory< T >::MakerMap

Definition at line 48 of file ComponentFactory.h.

Constructor & Destructor Documentation

template<typename T >
edm::eventsetup::ComponentFactory< T >::ComponentFactory ( )
inline
template<typename T >
edm::eventsetup::ComponentFactory< T >::ComponentFactory ( const ComponentFactory< T > &  )
private

Member Function Documentation

template<typename T >
std::shared_ptr<base_type> edm::eventsetup::ComponentFactory< T >::addTo ( EventSetupsController esController,
EventSetupProvider iProvider,
edm::ParameterSet const &  iConfiguration,
bool  replaceExisting = false 
) const
inline

Definition at line 51 of file ComponentFactory.h.

References cms::Exception::addContext(), edm::eventsetup::ComponentFactory< T >::ComponentFactory(), edm::errors::Configuration, beamerCreator::create(), label, edm::eventsetup::ComponentFactory< T >::makers_, dataset::name, edm::eventsetup::ComponentFactory< T >::operator=(), AlCaHLTBitMon_QueryRunRegistry::string, edm::Exception::throwThis(), and edm::convertException::wrap().

54  {
55  std::string modtype = iConfiguration.template getParameter<std::string>("@module_type");
56  //cerr << "Factory: module_type = " << modtype << endl;
57  typename MakerMap::iterator it = makers_.find(modtype);
58 
59  if (it == makers_.end()) {
60  std::shared_ptr<Maker> wm(edmplugin::PluginFactory<ComponentMakerBase<T>*()>::get()->create(modtype));
61 
62  if (wm.get() == nullptr) {
64  "UnknownModule",
65  T::name().c_str(),
66  " of type ",
67  modtype.c_str(),
68  " has not been registered.\n"
69  "Perhaps your module type is misspelled or is not a "
70  "framework plugin.\n"
71  "Try running EdmPluginDump to obtain a list of "
72  "available Plugins.");
73  }
74 
75  //cerr << "Factory: created the worker" << endl;
76 
77  std::pair<typename MakerMap::iterator, bool> ret =
78  makers_.insert(std::pair<std::string, std::shared_ptr<Maker> >(modtype, wm));
79 
80  if (ret.second == false) {
81  Exception::throwThis(errors::Configuration, "Maker Factory map insert failed");
82  }
83 
84  it = ret.first;
85  }
86 
87  try {
88  return convertException::wrap([&]() -> std::shared_ptr<base_type> {
89  return it->second->addTo(esController, iProvider, iConfiguration, replaceExisting);
90  });
91  } catch (cms::Exception& iException) {
92  std::string edmtype = iConfiguration.template getParameter<std::string>("@module_edm_type");
93  std::string label = iConfiguration.template getParameter<std::string>("@module_label");
94  std::ostringstream ost;
95  ost << "Constructing " << edmtype << ": class=" << modtype << " label='" << label << "'";
96  iException.addContext(ost.str());
97  throw;
98  }
99  return std::shared_ptr<base_type>();
100  }
def create(alignables, pedeDump, additionalData, outputFile, config)
static void throwThis(Code category, char const *message0="", char const *message1="", char const *message2="", char const *message3="", char const *message4="")
Definition: EDMException.cc:83
char const * label
void addContext(std::string const &context)
Definition: Exception.cc:165
auto wrap(F iFunc) -> decltype(iFunc())
template<typename T >
static ComponentFactory<T> const* edm::eventsetup::ComponentFactory< T >::get ( )
static
template<typename T >
const ComponentFactory& edm::eventsetup::ComponentFactory< T >::operator= ( const ComponentFactory< T > &  )
private

Member Data Documentation

template<typename T >
MakerMap edm::eventsetup::ComponentFactory< T >::makers_
mutableprivate

Definition at line 113 of file ComponentFactory.h.

Referenced by edm::eventsetup::ComponentFactory< T >::addTo().