ATLAS Offline Software
ForceLoadCondObj.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // ForceLoadCondObj.cxx
6 
8 #include "GaudiKernel/IClassIDSvc.h"
9 #include "GaudiKernel/MsgStream.h"
11 
12 
14  ISvcLocator* pSvcLocator) :
15  AthAlgorithm(name, pSvcLocator),
16  p_clidsvc ( "ClassIDSvc", name )
17 {
18  declareProperty("ObjectList",m_objectList,"list of 'object#key'");
19 }
20 
22 = default;
23 
25  ATH_MSG_DEBUG ("in initialize()" );
26  ATH_CHECK( p_clidsvc.retrieve() );
27  return StatusCode::SUCCESS;
28 }
29 
31 
32  return StatusCode::SUCCESS;
33 }
34 
36  //Loop through objects
37  for (unsigned int iobj=0;iobj<m_objectList.size();++iobj) {
38  // if object name contains a '#', it represents a specific typename#key
39  std::string::size_type ihash=m_objectList[iobj].find_first_of('#');
40  if (ihash==std::string::npos) {
41  ATH_MSG_ERROR ( "Expected syntax 'object#key' for property ObjectList, got" << m_objectList[iobj] );
42  return StatusCode::FAILURE;
43  }
44  std::string::size_type ihash2=m_objectList[iobj].find_first_of('#',ihash+1);
45  if (ihash2 != std::string::npos) ihash2-=(1+ihash);
46  const std::string objName=m_objectList[iobj].substr(0,ihash);
47  const std::string objKey=m_objectList[iobj].substr(ihash+1,ihash2);
48 
49  ATH_MSG_INFO ( "Retrieving object " << objName << ", key " << objKey );
50 
51  CLID clid;
52  ATH_CHECK( p_clidsvc->getIDOfTypeName(objName,clid) );
53 
54  SG::DataProxy* proxy=detStore()->proxy(clid,objKey);
55 
56  if (!proxy) {
57  ATH_MSG_ERROR ( "Could not find proxy for object of type " << objName << " with key " << objKey );
58  return StatusCode::FAILURE;
59  }
60 
61  if (proxy->accessData()!=nullptr) { //This should trigger the conversion
62  ATH_MSG_INFO ( "Sucessfully retrieved object of type " << objName << " with key " << objKey );
63  }
64  }
65  return StatusCode::SUCCESS;
66 }
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
ForceLoadCondObj::finalize
StatusCode finalize()
Definition: ForceLoadCondObj.cxx:30
ForceLoadCondObj::execute
StatusCode execute()
Definition: ForceLoadCondObj.cxx:35
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
ForceLoadCondObj::ForceLoadCondObj
ForceLoadCondObj(const std::string &name, ISvcLocator *pSvcLocator)
Definition: ForceLoadCondObj.cxx:13
AthAlgorithm
Definition: AthAlgorithm.h:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
ForceLoadCondObj::~ForceLoadCondObj
~ForceLoadCondObj()
ForceLoadCondObj::initialize
StatusCode initialize()
Definition: ForceLoadCondObj.cxx:24
ForceLoadCondObj::p_clidsvc
ServiceHandle< IClassIDSvc > p_clidsvc
Definition: ForceLoadCondObj.h:31
ForceLoadCondObj.h
SG::DataProxy
Definition: DataProxy.h:44
StoreGateSvc.h
ForceLoadCondObj::m_objectList
std::vector< std::string > m_objectList
Definition: ForceLoadCondObj.h:33