CMS 3D CMS Logo

KeyList.cc
Go to the documentation of this file.
3 
4 namespace cond {
5 
6  namespace persistency {
7 
8  void KeyList::init( IOVProxy iovProxy ){
9  m_proxy = iovProxy;
10  m_data.clear();
11  m_objects.clear();
12  }
13 
14  void KeyList::load( const std::vector<unsigned long long>& keys ){
15  std::shared_ptr<SessionImpl> simpl = m_proxy.session();
16  if( !simpl.get() ) cond::throwException("The KeyList has not been initialized.","KeyList::load");
17  Session s( simpl );
18  s.transaction().start( true );
19  m_data.clear();
20  m_objects.resize(keys.size());
21  for (size_t i=0; i<keys.size(); ++i) {
22  m_objects[i].reset();
23  if (keys[i]!=0) {
24  auto p = m_proxy.find(keys[i]);
25  if ( p!= m_proxy.end()) {
26  auto item = m_data.insert( std::make_pair( i, std::make_pair("",std::make_pair(cond::Binary(),cond::Binary()) ) ) );
27  if( ! s.fetchPayloadData( (*p).payloadId, item.first->second.first,
28  item.first->second.second.first, item.first->second.second.second ) )
29  cond::throwException("The Iov contains a broken payload reference.","KeyList::load");
30  }
31  }
32  }
33  s.transaction().commit();
34  }
35  }
36 }
37 
38 
void start(bool readOnly=true)
Definition: Session.cc:22
std::vector< std::shared_ptr< void > > m_objects
Definition: KeyList.h:63
Transaction & transaction()
Definition: Session.cc:66
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:21
std::map< size_t, std::pair< std::string, std::pair< cond::Binary, cond::Binary > > > m_data
Definition: KeyList.h:62
Iterator find(cond::Time_t time)
Definition: IOVProxy.cc:320
bool fetchPayloadData(const cond::Hash &payloadHash, std::string &payloadType, cond::Binary &payloadData, cond::Binary &streamerInfoData)
Definition: Session.cc:202
Definition: plugin.cc:24
void init(IOVProxy iovProxy)
Definition: KeyList.cc:8
void load(const std::vector< unsigned long long > &keys)
Definition: KeyList.cc:14
Iterator end() const
Definition: IOVProxy.cc:297
const std::shared_ptr< SessionImpl > & session() const
Definition: IOVProxy.cc:386