CMS 3D CMS Logo

Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends

edm::ServiceRegistry Class Reference

#include <ServiceRegistry.h>

List of all members.

Classes

class  Operate

Public Member Functions

template<typename T >
Tget () const
template<typename T >
bool isAvailable () const
ServiceToken presentToken () const
virtual ~ServiceRegistry ()

Static Public Member Functions

template<typename T >
static ServiceToken createContaining (std::auto_ptr< T > iService)
 create a service token that holds the service defined by iService
template<typename T >
static ServiceToken createContaining (boost::shared_ptr< serviceregistry::ServiceWrapper< T > > iWrapper, ServiceToken iToken, serviceregistry::ServiceLegacy iLegacy)
template<typename T >
static ServiceToken createContaining (boost::shared_ptr< serviceregistry::ServiceWrapper< T > > iWrapper)
 create a service token that holds the service held by iWrapper
template<typename T >
static ServiceToken createContaining (std::auto_ptr< T > iService, ServiceToken iToken, serviceregistry::ServiceLegacy iLegacy)
static ServiceToken createServicesFromConfig (std::string const &config)
static ServiceToken createSet (std::vector< ParameterSet > &, ServiceToken, serviceregistry::ServiceLegacy, bool associate=true)
static ServiceToken createSet (std::vector< ParameterSet > &)
static ServiceRegistryinstance ()

Private Member Functions

ServiceRegistry const & operator= (ServiceRegistry const &)
 ServiceRegistry (ServiceRegistry const &)
 ServiceRegistry ()
ServiceToken setContext (ServiceToken const &iNewToken)
void unsetContext (ServiceToken const &iOldToken)

Private Attributes

boost::shared_ptr
< serviceregistry::ServicesManager
manager_

Friends

class edm::FwkImpl
int main (int argc, char *argv[])
class Operate

Detailed Description

Definition at line 37 of file ServiceRegistry.h.


Constructor & Destructor Documentation

ServiceRegistry::~ServiceRegistry ( ) [virtual]

Definition at line 39 of file ServiceRegistry.cc.

                                     {
   }
ServiceRegistry::ServiceRegistry ( ) [private]

Definition at line 32 of file ServiceRegistry.cc.

                                    {
   }
edm::ServiceRegistry::ServiceRegistry ( ServiceRegistry const &  ) [private]

Member Function Documentation

template<typename T >
static ServiceToken edm::ServiceRegistry::createContaining ( std::auto_ptr< T iService) [inline, static]

create a service token that holds the service defined by iService

Definition at line 100 of file ServiceRegistry.h.

References HDQMDatabaseProducer::config, and wrapper.

Referenced by edm::ScheduleItems::addCPRandTNS(), spf::SherpackFetcher::FnFileGet(), and main().

                                                                   {
         std::vector<edm::ParameterSet> config;
         boost::shared_ptr<serviceregistry::ServicesManager> manager(new serviceregistry::ServicesManager(config));
         boost::shared_ptr<serviceregistry::ServiceWrapper<T> >
            wrapper(new serviceregistry::ServiceWrapper<T>(iService));
         manager->put(wrapper);
         return manager;
      }
template<typename T >
static ServiceToken edm::ServiceRegistry::createContaining ( std::auto_ptr< T iService,
ServiceToken  iToken,
serviceregistry::ServiceLegacy  iLegacy 
) [inline, static]

Definition at line 109 of file ServiceRegistry.h.

References HDQMDatabaseProducer::config, and wrapper.

                                                                                {
         std::vector<edm::ParameterSet> config;
         boost::shared_ptr<serviceregistry::ServicesManager> manager(new serviceregistry::ServicesManager(iToken,
                                                                                                          iLegacy,
                                                                                                          config));
         boost::shared_ptr<serviceregistry::ServiceWrapper<T> >
         wrapper(new serviceregistry::ServiceWrapper<T>(iService));
         manager->put(wrapper);
         return manager;
      }
template<typename T >
static ServiceToken edm::ServiceRegistry::createContaining ( boost::shared_ptr< serviceregistry::ServiceWrapper< T > >  iWrapper) [inline, static]

create a service token that holds the service held by iWrapper

Definition at line 123 of file ServiceRegistry.h.

References HDQMDatabaseProducer::config.

                                                                                                        {
         std::vector<edm::ParameterSet> config;
         boost::shared_ptr<serviceregistry::ServicesManager> manager(new serviceregistry::ServicesManager(config));
         manager->put(iWrapper);
         return manager;
      }
template<typename T >
static ServiceToken edm::ServiceRegistry::createContaining ( boost::shared_ptr< serviceregistry::ServiceWrapper< T > >  iWrapper,
ServiceToken  iToken,
serviceregistry::ServiceLegacy  iLegacy 
) [inline, static]

Definition at line 130 of file ServiceRegistry.h.

References HDQMDatabaseProducer::config.

                                                                                {
         std::vector<edm::ParameterSet> config;
         boost::shared_ptr<serviceregistry::ServicesManager> manager(new serviceregistry::ServicesManager(iToken,
                                                                                                          iLegacy,
                                                                                                          config));
         manager->put(iWrapper);
         return manager;
      }
ServiceToken ServiceRegistry::createServicesFromConfig ( std::string const &  config) [static]

Definition at line 81 of file ServiceRegistry.cc.

References createSet(), edm::makeParameterSets(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by HPDNoiseLibraryReader::initializeServices().

                                                                    {
      boost::shared_ptr<ParameterSet> params;
      makeParameterSets(config, params);

      std::auto_ptr<std::vector<ParameterSet> > serviceSets = params->popVParameterSet(std::string("services"));
      //create the services
      return ServiceToken(ServiceRegistry::createSet(*serviceSets));
   }
ServiceToken ServiceRegistry::createSet ( std::vector< ParameterSet > &  iPS) [static]

Definition at line 91 of file ServiceRegistry.cc.

Referenced by createServicesFromConfig(), cond::FWIncantation::FWIncantation(), evf::FWEPWrapper::init(), evf::iDie::initFramework(), cond::Utilities::initializePluginManager(), and edm::ScheduleItems::initServices().

                                                          {
      using namespace serviceregistry;
      boost::shared_ptr<ServicesManager> returnValue(new ServicesManager(iPS));
      return ServiceToken(returnValue);
   }
ServiceToken ServiceRegistry::createSet ( std::vector< ParameterSet > &  iPS,
ServiceToken  iToken,
serviceregistry::ServiceLegacy  iLegacy,
bool  associate = true 
) [static]

Definition at line 98 of file ServiceRegistry.cc.

                                                   {
      using namespace serviceregistry;
      boost::shared_ptr<ServicesManager> returnValue(new ServicesManager(iToken, iLegacy, iPS, associate));
      return ServiceToken(returnValue);
   }
template<typename T >
T& edm::ServiceRegistry::get ( void  ) const [inline]

Definition at line 63 of file ServiceRegistry.h.

References manager_, edm::errors::NotFound, and edm::Exception::throwThis().

                     {
         if(0 == manager_.get()) {
            Exception::throwThis(errors::NotFound,
              "Service"
              " no ServiceRegistry has been set for this thread");
         }
         return manager_-> template get<T>();
      }
ServiceRegistry & ServiceRegistry::instance ( ) [static]

Definition at line 108 of file ServiceRegistry.cc.

Referenced by edm::ScheduleItems::initSchedule(), and edm::ServiceRegistry::Operate::~Operate().

                             {
      static boost::thread_specific_ptr<ServiceRegistry> s_registry;
      if(0 == s_registry.get()){
         s_registry.reset(new ServiceRegistry);
      }
      return *s_registry;
   }
template<typename T >
bool edm::ServiceRegistry::isAvailable ( ) const [inline]

Definition at line 73 of file ServiceRegistry.h.

References manager_, edm::errors::NotFound, and edm::Exception::throwThis().

                               {
         if(0 == manager_.get()) {
            Exception::throwThis(errors::NotFound,
              "Service"
              " no ServiceRegistry has been set for this thread");
         }
         return manager_-> template isAvailable<T>();
      }
ServiceRegistry const& edm::ServiceRegistry::operator= ( ServiceRegistry const &  ) [private]
ServiceToken ServiceRegistry::presentToken ( ) const

The token can be passed to another thread in order to have the same services available in the other thread.

Definition at line 72 of file ServiceRegistry.cc.

References manager_.

                                       {
      return manager_;
   }
ServiceToken ServiceRegistry::setContext ( ServiceToken const &  iNewToken) [private]

Definition at line 57 of file ServiceRegistry.cc.

References edm::ServiceToken::manager_, and manager_.

                                                            {
      ServiceToken returnValue(manager_);
      manager_ = iNewToken.manager_;
      return returnValue;
   }
void ServiceRegistry::unsetContext ( ServiceToken const &  iOldToken) [private]

Definition at line 64 of file ServiceRegistry.cc.

References edm::ServiceToken::manager_, and manager_.

Referenced by edm::ServiceRegistry::Operate::~Operate().

                                                              {
      manager_ = iOldToken.manager_;
   }

Friends And Related Function Documentation

friend class edm::FwkImpl [friend]

Definition at line 55 of file ServiceRegistry.h.

int main ( int  argc,
char *  argv[] 
) [friend]

------------------ CALO JETS ------------------

------------------ PF JETS ------------------

Definition at line 93 of file HcalPedestalValidator.cc.

                                   {

// CORAL required variables to be set, even if not needed
  const char* foo1 = "CORAL_AUTH_USER=blaaah";
  const char* foo2 = "CORAL_AUTH_PASSWORD=blaaah";
  if (!::getenv("CORAL_AUTH_USER")) ::putenv(const_cast<char*>(foo1));
  if (!::getenv("CORAL_AUTH_PASSWORD")) ::putenv(const_cast<char*>(foo2)); 

  Args args;
  args.defineParameter ("-p", "raw pedestals");
  args.defineParameter ("-w", "raw widths");
  args.defineParameter ("-run", "current run number <0>");
  args.defineParameter ("-ptag", "raw pedestal tag <NULL>");
  args.defineParameter ("-wtag", "raw width tag <ptag>");
  args.defineParameter ("-pref", "reference pedestals");
  args.defineParameter ("-wref", "reference widths");
  args.defineParameter ("-ptagref", "reference pedestal tag <NULL>");
  args.defineParameter ("-wtagref", "reference width tag <ptagref>");
  args.defineParameter ("-pval", "validated pedestals");
  args.defineParameter ("-wval", "validated widths");
  args.defineOption ("-help", "this help");

  args.parse (argn, argv);
  std::vector<std::string> arguments = args.arguments ();
  if (args.optionIsSet ("-help")) {
    args.printOptionsHelp ();
    return -1;
  }

// read parameters from command line
  std::string RawPedSource = args.getParameter("-p");
  std::string RawPedWidSource = args.getParameter("-w");
  std::string RawPedTag = args.getParameter("-ptag").empty() ? "" : args.getParameter("-ptag");
  std::string RawPedWidTag = args.getParameter("-wtag").empty() ? RawPedTag : args.getParameter("-wtag");
  int RawPedRun = args.getParameter("-run").empty() ? 0 : (int)strtoll (args.getParameter("-run").c_str(),0,0);
  int RawPedWidRun = RawPedRun;
  std::string RefPedSource = args.getParameter("-pref");
  std::string RefPedWidSource = args.getParameter("-wref");
  std::string RefPedTag = args.getParameter("-ptagref").empty() ? "" : args.getParameter("-ptagref");
  std::string RefPedWidTag = args.getParameter("-wtagref").empty() ? RefPedTag : args.getParameter("-wtagref");
  int RefPedRun = RawPedRun;
  int RefPedWidRun = RefPedRun;
  std::string outputPedDest = args.getParameter("-pval");
  std::string outputPedWidDest = args.getParameter("-wval");
  std::string outputPedTag = "";
  std::string outputPedWidTag = "";
  int outputPedRun = RawPedRun;
  int outputPedWidRun = outputPedRun;

  // need to know how to make proper topology in the future.
  HcalTopology topo(HcalTopologyMode::LHC,2,4);

// get reference objects
  HcalPedestals* RefPeds = 0;
  RefPeds = new HcalPedestals (&topo);
  if (!getObject (RefPeds, RefPedSource, RefPedTag, RefPedRun)) {
    std::cerr << "HcalPedestalValidator-> Failed to get reference Pedestals" << std::endl;
    return 1;
  }
  HcalPedestalWidths* RefPedWids = 0;
  RefPedWids = new HcalPedestalWidths (&topo);
  if (!getObject (RefPedWids, RefPedWidSource, RefPedWidTag, RefPedWidRun)) {
    std::cerr << "HcalPedestalValidator-> Failed to get reference PedestalWidths" << std::endl;
    return 2;
  }

// get input raw objects
  HcalPedestals* RawPeds = 0;
  RawPeds = new HcalPedestals (&topo);
  if (!getObject (RawPeds, RawPedSource, RawPedTag, RawPedRun)) {
    std::cerr << "HcalPedestalValidator-> Failed to get raw Pedestals" << std::endl;
    return 3;
  }
  HcalPedestalWidths* RawPedWids = 0;
  RawPedWids = new HcalPedestalWidths (&topo);
  if (!getObject (RawPedWids, RawPedWidSource, RawPedWidTag, RawPedWidRun)) {
    std::cerr << "HcalPedestalValidator-> Failed to get raw PedestalWidths" << std::endl;
    return 4;
  }

// make output objects
  HcalPedestals* outputPeds = 0;
  outputPeds = new HcalPedestals (&topo);
  HcalPedestalWidths* outputPedWids = 0;
  outputPedWids = new HcalPedestalWidths (&topo);

// run algorithm
  int nstat[4]={2500,2500,2500,2500};
  int Flag=HcalPedestalAnalysis::HcalPedVal(nstat,RefPeds,RefPedWids,RawPeds,RawPedWids,outputPeds,outputPedWids);

  delete RefPeds;
  delete RefPedWids;
  delete RawPeds;
  delete RawPedWids;


// store new objects if necessary
  if (Flag%100000>0) {
    if (outputPeds) {
      if (!putObject (&outputPeds, outputPedDest, outputPedTag, outputPedRun)) {
          std::cerr << "HcalPedestalAnalyzer-> Failed to put output Pedestals" << std::endl;
          return 5;
        }
    }
    if (outputPedWids) {
        if (!putObject (&outputPedWids, outputPedWidDest, outputPedWidTag, outputPedWidRun)) {
        std::cerr << "HcalPedestalAnalyzer-> Failed to put output PedestalWidths" << std::endl;
        return 6;
      }
    }
  }
  delete outputPeds;
  delete outputPedWids;

return 0;
}
friend class Operate [friend]

Definition at line 57 of file ServiceRegistry.h.


Member Data Documentation

Definition at line 152 of file ServiceRegistry.h.

Referenced by get(), isAvailable(), presentToken(), setContext(), and unsetContext().