CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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,
boost::shared_ptr< Maker > > 
MakerMap
 

Public Member Functions

boost::shared_ptr< base_typeaddTo (EventSetupsController &esController, EventSetupProvider &iProvider, edm::ParameterSet const &iConfiguration) const
 
 ComponentFactory ()
 

Static Public Member Functions

static ComponentFactory< T > * 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 51 of file ComponentFactory.h.

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

Definition at line 49 of file ComponentFactory.h.

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

Definition at line 50 of file ComponentFactory.h.

Constructor & Destructor Documentation

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

Definition at line 46 of file ComponentFactory.h.

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

Member Function Documentation

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

Definition at line 53 of file ComponentFactory.h.

References cms::Exception::addContext(), edm::convertException::badAllocToEDM(), trackerHits::c, edm::convertException::charPtrToEDM(), edm::errors::Configuration, SurfaceDeformationFactory::create(), alignCSCRings::e, cppFunctionSkipper::exception, diffTwoXMLs::label, edm::eventsetup::ComponentFactory< T >::makers_, mergeVDriftHistosByStation::name, run_regression::ret, alignCSCRings::s, edm::convertException::stdToEDM(), edm::convertException::stringToEDM(), edm::Exception::throwThis(), and edm::convertException::unknownToEDM().

56  {
57  std::string modtype = iConfiguration.template getParameter<std::string>("@module_type");
58  //cerr << "Factory: module_type = " << modtype << endl;
59  typename MakerMap::iterator it = makers_.find(modtype);
60 
61  if(it == makers_.end())
62  {
63  boost::shared_ptr<Maker> wm(edmplugin::PluginFactory<ComponentMakerBase<T>* ()>::get()->create(modtype));
64 
65  if(wm.get() == 0) {
67  "UnknownModule",
68  T::name().c_str(),
69  " of type ",
70  modtype.c_str(),
71  " has not been registered.\n"
72  "Perhaps your module type is misspelled or is not a "
73  "framework plugin.\n"
74  "Try running EdmPluginDump to obtain a list of "
75  "available Plugins.");
76  }
77 
78  //cerr << "Factory: created the worker" << endl;
79 
80  std::pair<typename MakerMap::iterator,bool> ret =
81  makers_.insert(std::pair<std::string,boost::shared_ptr<Maker> >(modtype,wm));
82 
83  if(ret.second == false) {
84  Exception::throwThis(errors::Configuration,"Maker Factory map insert failed");
85  }
86 
87  it = ret.first;
88  }
89 
90  try {
91  try {
92  return it->second->addTo(esController, iProvider, iConfiguration);
93  }
94  catch (cms::Exception& e) { throw; }
95  catch(std::bad_alloc& bda) { convertException::badAllocToEDM(); }
97  catch(std::string& s) { convertException::stringToEDM(s); }
98  catch(char const* c) { convertException::charPtrToEDM(c); }
99  catch (...) { convertException::unknownToEDM(); }
100  }
101  catch(cms::Exception & iException) {
102  std::string edmtype = iConfiguration.template getParameter<std::string>("@module_edm_type");
103  std::string label = iConfiguration.template getParameter<std::string>("@module_label");
104  std::ostringstream ost;
105  ost << "Constructing " << edmtype << ": class=" << modtype << " label='" << label << "'";
106  iException.addContext(ost.str());
107  throw;
108  }
109  return boost::shared_ptr<base_type>();
110  }
static void throwThis(Code category, char const *message0="", char const *message1="", char const *message2="", char const *message3="", char const *message4="")
void stdToEDM(std::exception const &e)
void charPtrToEDM(char const *c)
void stringToEDM(std::string &s)
void addContext(std::string const &context)
Definition: Exception.cc:227
SurfaceDeformation * create(int type, const std::vector< double > &params)
template<typename T >
static ComponentFactory<T>* 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 124 of file ComponentFactory.h.

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