ATLAS Offline Software
Loading...
Searching...
No Matches
SGGetterImpl.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
10
11
14#include "SGTools/DataProxy.h"
17
18namespace D3PD {
19
20
26SGGetterImpl::SGGetterImpl (const std::string& name,
28 : m_clidsvc ("ClassIDSvc", name),
29 m_resolver (name, sg, m_sgkey),
30 m_clid (CLID_NULL),
31 m_sg (sg)
32{
33}
34
35
39const std::type_info& SGGetterImpl::typeinfo() const
40{
41 const std::type_info* ti = 0;
42 if (clidToTypeinfo (m_clid, m_typename, ti, this->name()).isSuccess())
43 return *ti;
44
45 REPORT_MESSAGE (MSG::ERROR) << "Can't find typeinfo for CLID "
46 << m_clid << " (type " << m_typename << ").";
47 return typeid (void);
48}
49
50
55{
56 return m_clid;
57}
58
59
68const void* SGGetterImpl::getUntyped (bool allowMissing /*= false*/)
69{
70 std::string key = m_resolver.key();
71 SG::DataProxy* proxy = m_sg->proxy (m_clid, key);
72 if (!proxy) {
73 if (!allowMissing) {
74 REPORT_MESSAGE (MSG::FATAL) << "Can't find object in event store for "
75 << m_typename << "(" << m_clid << ")/"
76 << key;
77 REPORT_MESSAGE (MSG::INFO) << m_sg->dump();
78 }
79 return 0;
80 }
81
82 void* ptr = SG::DataProxy_cast (proxy, m_clid);
83 if (!ptr) {
84 if (!allowMissing) {
85 REPORT_MESSAGE (MSG::FATAL)
86 << "Null object retrieved for " << m_typename << "(" << m_clid << ")/"
87 << key;
88 REPORT_MESSAGE (MSG::INFO) << m_sg->dump();
89 }
90 return 0;
91 }
92
93 // Try to retrieve a corresponding aux store as well.
94 m_sg->tryConstRetrieve<SG::IConstAuxStore> (key + "Aux.");
95
96 return ptr;
97}
98
99
106{
107 CHECK( m_clidsvc.retrieve() );
108
110
111 CHECK( m_resolver.initialize (m_clid, m_typename) );
112
113 return StatusCode::SUCCESS;
114}
115
116
117} // namespace D3PD
Helpers for checking error return status codes and reporting errors.
#define REPORT_MESSAGE(LVL)
Report a message.
#define CHECK(...)
Evaluate an expression and check for errors.
uint32_t CLID
The Class ID type.
Interface for const operations on an auxiliary store.
Common object getter code for retrieving from StoreGate.
Utility functions for converting between type names, type_info, and CLIDs.
std::string m_typename
Property: Name of the type of the object being retrieved.
SGKeyResolver m_resolver
Helper: Resolve the SG key to use.
SGGetterImpl(const std::string &name, ServiceHandle< StoreGateSvc > &sg)
Constructor.
StatusCode initializeImpl()
Initialize this mixin class.
CLID m_clid
CLID for the object being retrieved.
virtual const void * getUntyped(bool allowMissing=false)
Return the target object.
ServiceHandle< StoreGateSvc > & m_sg
The event storage service.
ServiceHandle< IClassIDSvc > m_clidsvc
Property: Instance of the ClassIDSvc to use.
CLID clid() const
Return the class ID being read by this tool.
virtual const std::type_info & typeinfo() const
Return the type of object retrieved by this tool.
std::string m_sgkey
Property: StoreGate key of the object being retrieved.
Block filler tool for noisy FEB information.
StatusCode clidToTypeinfo(CLID clid, const std::string &nmae, std::type_info const *&ti, const std::string &context)
Convert from a CLID to a type_info; we also already know the name.
StatusCode nameToCLID(const std::string &name, CLID &clid, const std::string &context, ServiceHandle< IClassIDSvc > clidsvc=ServiceHandle< IClassIDSvc >("ClassIDSvc", "TypeNameConversions"))
Convert from a class name to a CLID.
DATA * DataProxy_cast(DataProxy *proxy)
cast the proxy into the concrete data object it proxies
void * ptr(T *p)
Definition SGImplSvc.cxx:74