CMS 3D CMS Logo

Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes

edm::eventsetup::EventSetupProvider Class Reference

#include <EventSetupProvider.h>

List of all members.

Public Types

typedef std::pair< DataType,
DataLabel
DataKeyInfo
typedef std::string DataLabel
typedef std::string DataType
typedef std::map
< ComponentDescription,
RecordToDataMap
PreferredProviderInfo
typedef std::string RecordName
typedef std::multimap
< RecordName, DataKeyInfo
RecordToDataMap

Public Member Functions

void add (boost::shared_ptr< DataProxyProvider >)
void add (boost::shared_ptr< EventSetupRecordIntervalFinder >)
void addRecordToEventSetup (EventSetupRecord &iRecord)
EventSetup const & eventSetup () const
EventSetup const & eventSetupForInstance (IOVSyncValue const &)
 EventSetupProvider (PreferredProviderInfo const *iInfo=0)
void finishConfiguration ()
void forceCacheClear ()
 Used when testing that all code properly updates on IOV changes of all Records.
std::set< ComponentDescriptionproxyProviderDescriptions () const
void resetRecordPlusDependentRecords (EventSetupRecordKey const &)
 Used when we need to force a Record to reset all its proxies.
virtual ~EventSetupProvider ()

Protected Member Functions

template<typename T >
void insert (std::auto_ptr< T > iRecordProvider)

Private Types

typedef std::map
< EventSetupRecordKey,
boost::shared_ptr
< EventSetupRecordProvider > > 
Providers

Private Member Functions

 EventSetupProvider (EventSetupProvider const &)
void insert (EventSetupRecordKey const &, std::auto_ptr< EventSetupRecordProvider >)
EventSetupProvider const & operator= (EventSetupProvider const &)

Private Attributes

std::auto_ptr< std::vector
< boost::shared_ptr
< DataProxyProvider > > > 
dataProviders_
EventSetup eventSetup_
std::auto_ptr< std::vector
< boost::shared_ptr
< EventSetupRecordIntervalFinder > > > 
finders_
bool mustFinishConfiguration_
std::auto_ptr
< PreferredProviderInfo
preferredProviderInfo_
Providers providers_

Detailed Description

Definition at line 45 of file EventSetupProvider.h.


Member Typedef Documentation

Definition at line 51 of file EventSetupProvider.h.

Definition at line 50 of file EventSetupProvider.h.

Definition at line 49 of file EventSetupProvider.h.

Definition at line 53 of file EventSetupProvider.h.

Definition at line 101 of file EventSetupProvider.h.

Definition at line 48 of file EventSetupProvider.h.

Definition at line 52 of file EventSetupProvider.h.


Constructor & Destructor Documentation

EventSetupProvider::EventSetupProvider ( PreferredProviderInfo const *  iInfo = 0)

Definition at line 42 of file EventSetupProvider.cc.

                                                                         :
eventSetup_(),
providers_(),
mustFinishConfiguration_(true),
preferredProviderInfo_((0!=iInfo) ? (new PreferredProviderInfo(*iInfo)): 0),
finders_(new std::vector<boost::shared_ptr<EventSetupRecordIntervalFinder> >() ),
dataProviders_(new std::vector<boost::shared_ptr<DataProxyProvider> >() )
{
}
EventSetupProvider::~EventSetupProvider ( ) [virtual]

Definition at line 57 of file EventSetupProvider.cc.

{
}
edm::eventsetup::EventSetupProvider::EventSetupProvider ( EventSetupProvider const &  ) [private]

Member Function Documentation

void EventSetupProvider::add ( boost::shared_ptr< DataProxyProvider iProvider)
void EventSetupProvider::add ( boost::shared_ptr< EventSetupRecordIntervalFinder iFinder)

Definition at line 94 of file EventSetupProvider.cc.

References finders_, and mustFinishConfiguration_.

{
   mustFinishConfiguration_ = true;
   assert(&(*iFinder) != 0);
   finders_->push_back(iFinder);
}
void EventSetupProvider::addRecordToEventSetup ( EventSetupRecord iRecord)
EventSetup const& edm::eventsetup::EventSetupProvider::eventSetup ( ) const [inline]

Definition at line 65 of file EventSetupProvider.h.

References eventSetup_.

{return eventSetup_;}
EventSetup const & EventSetupProvider::eventSetupForInstance ( IOVSyncValue const &  iValue)

Definition at line 412 of file EventSetupProvider.cc.

References edm::EventSetup::clear(), eventSetup_, finishConfiguration(), mustFinishConfiguration_, providers_, and edm::EventSetup::setIOVSyncValue().

{
   eventSetup_.setIOVSyncValue(iValue);

   eventSetup_.clear();
   if(mustFinishConfiguration_) {
      const_cast<EventSetupProvider*>(this)->finishConfiguration();
   }

   for(Providers::iterator itProvider = providers_.begin(), itProviderEnd = providers_.end();
        itProvider != itProviderEnd;
        ++itProvider) {
      itProvider->second->addRecordToIfValid(*this, iValue);
   }
   
   return eventSetup_;

   
}
void EventSetupProvider::finishConfiguration ( )

Definition at line 243 of file EventSetupProvider.cc.

References dataProviders_, edm::eventsetup::determinePreferred(), finders_, insert(), edm::eventsetup::EventSetupRecordProviderFactoryManager::instance(), mustFinishConfiguration_, preferredProviderInfo_, and providers_.

Referenced by eventSetupForInstance().

{   
   //we delayed adding finders to the system till here so that everything would be loaded first
   for(std::vector<boost::shared_ptr<EventSetupRecordIntervalFinder> >::iterator itFinder=finders_->begin(),
       itEnd = finders_->end();
       itFinder != itEnd;
       ++itFinder) {
      typedef std::set<EventSetupRecordKey> Keys;
      const Keys recordsUsing = (*itFinder)->findingForRecords();
      
      for(Keys::const_iterator itKey = recordsUsing.begin(), itKeyEnd = recordsUsing.end();
          itKey != itKeyEnd;
          ++itKey) {
         Providers::iterator itFound = providers_.find(*itKey);
         if(providers_.end() == itFound) {
            //create a provider for this record
            insert(*itKey, EventSetupRecordProviderFactoryManager::instance().makeRecordProvider(*itKey));
            itFound = providers_.find(*itKey);
         }
         itFound->second->addFinder(*itFinder);
      }      
   }
   //we've transfered our ownership so this is no longer needed
   finders_.reset();
   
   //Now handle providers since sources can also be finders and the sources can delay registering
   // their Records and therefore could delay setting up their Proxies
   typedef std::set<EventSetupRecordKey> Keys;
   for(std::vector<boost::shared_ptr<DataProxyProvider> >::iterator itProvider=dataProviders_->begin(),
       itEnd = dataProviders_->end();
       itProvider != itEnd;
       ++itProvider) {
      
      const Keys recordsUsing = (*itProvider)->usingRecords();
      
      for(Keys::const_iterator itKey = recordsUsing.begin(), itKeyEnd = recordsUsing.end();
          itKey != itKeyEnd;
          ++itKey) {
         Providers::iterator itFound = providers_.find(*itKey);
         if(providers_.end() == itFound) {
            //create a provider for this record
            insert(*itKey, EventSetupRecordProviderFactoryManager::instance().makeRecordProvider(*itKey));
            itFound = providers_.find(*itKey);
         }
         itFound->second->add(*itProvider);
      }
   }
   dataProviders_.reset();
   
   //used for the case where no preferred Providers have been specified for the Record
   static const EventSetupRecordProvider::DataToPreferredProviderMap kEmptyMap;
   
   RecordToPreferred recordToPreferred = determinePreferred(preferredProviderInfo_.get(),providers_);
   //For each Provider, find all the Providers it depends on.  If a dependent Provider
   // can not be found pass in an empty list
   //CHANGE: now allow for missing Providers
   for(Providers::iterator itProvider = providers_.begin(), itProviderEnd = providers_.end();
        itProvider != itProviderEnd;
        ++itProvider) {
      const EventSetupRecordProvider::DataToPreferredProviderMap* preferredInfo = &kEmptyMap;
      RecordToPreferred::const_iterator itRecordFound = recordToPreferred.find(itProvider->first);
      if(itRecordFound != recordToPreferred.end()) {
         preferredInfo = &(itRecordFound->second);
      }
      //Give it our list of preferred 
      itProvider->second->usePreferred(*preferredInfo);
      
      std::set<EventSetupRecordKey> records = itProvider->second->dependentRecords();
      if(records.size() != 0) {
         std::string missingRecords;
         std::vector<boost::shared_ptr<EventSetupRecordProvider> > depProviders;
         depProviders.reserve(records.size());
         bool foundAllProviders = true;
         for(std::set<EventSetupRecordKey>::iterator itRecord = records.begin(),
              itRecordEnd = records.end();
              itRecord != itRecordEnd;
              ++itRecord) {
            Providers::iterator itFound = providers_.find(*itRecord);
            if(itFound == providers_.end()) {
               foundAllProviders = false;
               if(missingRecords.size() == 0) {
                 missingRecords = itRecord->name();
               } else {
                 missingRecords += ", ";
                 missingRecords += itRecord->name();
               }
               //break;
            } else {
               depProviders.push_back(itFound->second);
            }
         }
         
         if(!foundAllProviders) {
            edm::LogInfo("EventSetupDependency")<<"The EventSetup record "<<itProvider->second->key().name()
            <<" depends on at least one Record \n ("<<missingRecords<<") which is not present in the job."
           "\n This may lead to an exception begin thrown during event processing.\n If no exception occurs during the job than it is usually safe to ignore this message.";

            //depProviders.clear();
           //NOTE: should provide a warning
         }
          
         itProvider->second->setDependentProviders(depProviders);
      }
   }
   mustFinishConfiguration_ = false;
   
}
void EventSetupProvider::forceCacheClear ( )

Used when testing that all code properly updates on IOV changes of all Records.

Definition at line 392 of file EventSetupProvider.cc.

References providers_.

{
   for(Providers::iterator it=providers_.begin(), itEnd = providers_.end();
       it != itEnd;
       ++it) {
      it->second->resetProxies();
   }
}
template<typename T >
void edm::eventsetup::EventSetupProvider::insert ( std::auto_ptr< T iRecordProvider) [inline, protected]

Definition at line 84 of file EventSetupProvider.h.

References edm::eventsetup::heterocontainer::makeKey(), and groupFilesInBlocks::temp.

Referenced by finishConfiguration().

                                                     {
            std::auto_ptr<EventSetupRecordProvider> temp(iRecordProvider.release());
            insert(eventsetup::heterocontainer::makeKey<
                    typename T::RecordType,
                       eventsetup::EventSetupRecordKey>(),
                    temp);
         }
void EventSetupProvider::insert ( EventSetupRecordKey const &  iKey,
std::auto_ptr< EventSetupRecordProvider iProvider 
) [private]

Definition at line 77 of file EventSetupProvider.cc.

References providers_, and groupFilesInBlocks::temp.

{
   boost::shared_ptr<EventSetupRecordProvider> temp(iProvider.release());
   providers_[iKey] = temp;
   //temp->addRecordTo(*this);
}
EventSetupProvider const& edm::eventsetup::EventSetupProvider::operator= ( EventSetupProvider const &  ) [private]
std::set< ComponentDescription > EventSetupProvider::proxyProviderDescriptions ( ) const

Definition at line 443 of file EventSetupProvider.cc.

References dataProviders_, edm::for_all(), providers_, edm::eventsetup::EventSetupRecordProvider::proxyProviderDescriptions(), and edm::second().

{
   using boost::bind;
   typedef std::set<ComponentDescription> Set;
   Set descriptions;

   for_all(providers_,
                 bind(InsertAll(descriptions),
                      bind(&EventSetupRecordProvider::proxyProviderDescriptions,
                           bind(&Providers::value_type::second,_1))));
   if(dataProviders_.get()) {
      for(std::vector<boost::shared_ptr<DataProxyProvider> >::const_iterator it = dataProviders_->begin(),
          itEnd = dataProviders_->end();
          it != itEnd;
          ++it) {
         descriptions.insert((*it)->description());
      }
         
   }
                       
   return descriptions;
}
void EventSetupProvider::resetRecordPlusDependentRecords ( EventSetupRecordKey const &  iKey)

Used when we need to force a Record to reset all its proxies.

Definition at line 372 of file EventSetupProvider.cc.

References edm::eventsetup::findDependents(), edm::for_all(), providers_, and edm::eventsetup::EventSetupRecordProvider::resetProxies().

Referenced by edm::EDLooperBase::prepareForNextLoop().

{
  Providers::iterator itFind = providers_.find(iKey);
  if(itFind == providers_.end()) {
    return;
  }

  
  std::vector<boost::shared_ptr<EventSetupRecordProvider> > dependents;
  findDependents(iKey, providers_.begin(), providers_.end(), dependents);

  dependents.erase(std::unique(dependents.begin(),dependents.end()), dependents.end());
  
  itFind->second->resetProxies();
  for_all(dependents,
                boost::bind(&EventSetupRecordProvider::resetProxies,
                            _1));
}

Member Data Documentation

std::auto_ptr<std::vector<boost::shared_ptr<DataProxyProvider> > > edm::eventsetup::EventSetupProvider::dataProviders_ [private]

Definition at line 107 of file EventSetupProvider.h.

Referenced by add(), finishConfiguration(), and proxyProviderDescriptions().

Definition at line 100 of file EventSetupProvider.h.

Referenced by addRecordToEventSetup(), eventSetup(), and eventSetupForInstance().

std::auto_ptr<std::vector<boost::shared_ptr<EventSetupRecordIntervalFinder> > > edm::eventsetup::EventSetupProvider::finders_ [private]

Definition at line 106 of file EventSetupProvider.h.

Referenced by add(), and finishConfiguration().

Definition at line 103 of file EventSetupProvider.h.

Referenced by add(), eventSetupForInstance(), and finishConfiguration().

Definition at line 105 of file EventSetupProvider.h.

Referenced by finishConfiguration().