ATLAS Offline Software
Loading...
Searching...
No Matches
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
13ForceLoadCondObj::ForceLoadCondObj(const std::string& name,
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
uint32_t CLID
The Class ID type.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
StatusCode initialize()
ForceLoadCondObj(const std::string &name, ISvcLocator *pSvcLocator)
ServiceHandle< IClassIDSvc > p_clidsvc
std::vector< std::string > m_objectList