ATLAS Offline Software
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
D3PD::SGGetterImpl Class Referenceabstract

Common object getter code for retrieving from StoreGate. More...

#include <SGGetterImpl.h>

Inherits D3PD::IObjGetterTool.

Inherited by D3PD::SGCollectionGetterTool< CONT >, D3PD::SGDataVectorGetterTool, D3PD::SGObjGetterTool, D3PD::SGCollectionGetterTool< CaloCalibrationHitContainer >, D3PD::SGCollectionGetterTool< INav4MomLinkContainer >, D3PD::SGCollectionGetterTool< IParticleLinks >, D3PD::SGCollectionGetterTool< LArHitContainer >, D3PD::SGCollectionGetterTool< LArRawChannelContainer >, D3PD::SGCollectionGetterTool< Obj4Container >, D3PD::SGCollectionGetterTool< TileDigitsContainer >, D3PD::SGCollectionGetterTool< TileHitVector >, D3PD::SGCollectionGetterTool< TileRawChannelContainer >, and D3PD::SGCollectionGetterTool< TrackRecordCollection >.

Collaboration diagram for D3PD::SGGetterImpl:

Public Member Functions

 SGGetterImpl (const std::string &name, ServiceHandle< StoreGateSvc > &sg)
 Constructor. More...
 
virtual const std::type_info & typeinfo () const
 Return the type of object retrieved by this tool. More...
 
CLID clid () const
 Return the class ID being read by this tool. More...
 
virtual const void * getUntyped (bool allowMissing=false)
 Return the target object. More...
 
 DeclareInterfaceID (IObjGetterTool, 1, 0)
 Gaudi interface definition. More...
 
template<class T >
const T * get (bool allowMissing=false)
 Type-safe wrapper for get. More...
 
virtual void releaseObjectUntyped (const void *p)
 Release an object retrieved from the getter. More...
 
template<class T >
void releaseObject (const T *p)
 Type-safe wrapper for releaseObjectUntyped. More...
 
template<class T >
StatusCode configureD3PD ()
 Test type compatibility. More...
 
virtual const void * getTypeinfo (const std::type_info &ti, bool allowMissing=false)=0
 Return the target object cast to a different pointer type. More...
 
void releaseObjectTypeinfo (const void *p, const std::type_info &ti)
 Release an object retrieved from the getter. More...
 
virtual StatusCode configureTypeinfo (const std::type_info &ti)=0
 Test type compatibility. More...
 

Protected Member Functions

StatusCode initializeImpl ()
 Initialize this mixin class. More...
 

Protected Attributes

std::string m_typename
 Property: Name of the type of the object being retrieved. More...
 
std::string m_sgkey
 Property: StoreGate key of the object being retrieved. More...
 
ServiceHandle< IClassIDSvc > m_clidsvc
 Property: Instance of the ClassIDSvc to use. More...
 
SGKeyResolver m_resolver
 Helper: Resolve the SG key to use. More...
 

Private Attributes

CLID m_clid
 CLID for the object being retrieved. More...
 
ServiceHandle< StoreGateSvc > & m_sg
 The event storage service. More...
 

Detailed Description

Common object getter code for retrieving from StoreGate.

This class fulfills part of the IObjGetterTool interface, fetching an object from StoreGate. It's structured as a mixin class, so it can be used both for single-object and container getter tools.

This class uses a few properties, but since it's a mixin (and doesn't derive from AlgTool) it can't declare the properties itself. Instead, it defines the macro SGGETTERIMPL_PROPS, which should be used in the constructor of the derived AlgTool class. You should also call initializeImpl() from initialize().

The object being retrieved is specified by the properties TypeName and SGKey. SGKey may be a comma or space-separated list; the first entry that's actually present in the event store will be used. In addition, the property ClassIDSvc may be used to specify the instance of this service.

Definition at line 50 of file SGGetterImpl.h.

Constructor & Destructor Documentation

◆ SGGetterImpl()

D3PD::SGGetterImpl::SGGetterImpl ( const std::string &  name,
ServiceHandle< StoreGateSvc > &  sg 
)

Constructor.

Parameters
nameName of this tool.
sgThe event storage service.

Definition at line 26 of file SGGetterImpl.cxx.

28  : m_clidsvc ("ClassIDSvc", name),
29  m_resolver (name, sg, m_sgkey),
30  m_clid (CLID_NULL),
31  m_sg (sg)
32 {
33 }

Member Function Documentation

◆ clid()

CLID D3PD::SGGetterImpl::clid ( ) const

Return the class ID being read by this tool.

Definition at line 54 of file SGGetterImpl.cxx.

55 {
56  return m_clid;
57 }

◆ configureD3PD()

template<class T >
StatusCode D3PD::IObjGetterTool::configureD3PD ( )
inherited

Test type compatibility.

Test to see if the object being returned by the tool can be converted to a pointer to T. This can be used to perform type checks during job initialization.

This is implemented in terms of configureTypeinfo.

◆ configureTypeinfo()

virtual StatusCode D3PD::IObjGetterTool::configureTypeinfo ( const std::type_info &  ti)
pure virtualinherited

Test type compatibility.

Parameters
tiThe desired type.

Test to see if the object being returned by the tool can be converted to a pointer to T. This can be used to perform type checks during job initialization.

◆ DeclareInterfaceID()

D3PD::IObjGetterTool::DeclareInterfaceID ( IObjGetterTool  ,
,
 
)
inherited

Gaudi interface definition.

◆ get()

template<class T >
const T* D3PD::IObjGetterTool::get ( bool  allowMissing = false)
inherited

Type-safe wrapper for get.

Parameters
allowMissingIf true, then we should not generate errors if the requested object is missing.

Return the object as a pointer to T. Return 0 if the get fails or if the pointer can't be converted.

This is implemented in terms of getTypeinfo().

◆ getTypeinfo()

virtual const void* D3PD::IObjGetterTool::getTypeinfo ( const std::type_info &  ti,
bool  allowMissing = false 
)
pure virtualinherited

Return the target object cast to a different pointer type.

Parameters
tiThe desired type.
allowMissingIf true, then we should not generate errors if the requested object is missing.

Return the object as a pointer to the ti type. Return 0 if the get fails or if the pointer can't be converted.

◆ getUntyped()

const void * D3PD::SGGetterImpl::getUntyped ( bool  allowMissing = false)
virtual

Return the target object.

Parameters
allowMissingIf true, then we should not generate errors if the requested object is missing.

Should be of the type given by typeinfo. Return 0 on failure.

Implements D3PD::IObjGetterTool.

Reimplemented in D3PD::SGCollectionGetterTool< CONT >, D3PD::SGCollectionGetterTool< Obj4Container >, D3PD::SGCollectionGetterTool< TileDigitsContainer >, D3PD::SGCollectionGetterTool< CaloCalibrationHitContainer >, D3PD::SGCollectionGetterTool< TileHitVector >, D3PD::SGCollectionGetterTool< TrackRecordCollection >, D3PD::SGCollectionGetterTool< TileRawChannelContainer >, D3PD::SGCollectionGetterTool< LArHitContainer >, D3PD::SGCollectionGetterTool< INav4MomLinkContainer >, D3PD::SGCollectionGetterTool< LArRawChannelContainer >, and D3PD::SGCollectionGetterTool< IParticleLinks >.

Definition at line 68 of file SGGetterImpl.cxx.

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 
83  if (!ptr) {
84  if (!allowMissing) {
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 }

◆ initializeImpl()

StatusCode D3PD::SGGetterImpl::initializeImpl ( )
protected

Initialize this mixin class.

Call this from initialize.

Definition at line 105 of file SGGetterImpl.cxx.

106 {
107  CHECK( m_clidsvc.retrieve() );
108 
110 
112 
113  return StatusCode::SUCCESS;
114 }

◆ releaseObject()

template<class T >
void D3PD::IObjGetterTool::releaseObject ( const T *  p)
inherited

Type-safe wrapper for releaseObjectUntyped.

Parameters
pThe object to release.

Call this when you are done with the object returned by get(). The default implementation is a no-op, but if the getter dynamically allocated the object which it returned, this gives it a chance to free it.

This is implemented in terms of releaseObjectTypeinfo().

◆ releaseObjectTypeinfo()

void D3PD::IObjGetterTool::releaseObjectTypeinfo ( const void *  p,
const std::type_info &  ti 
)
inherited

Release an object retrieved from the getter.

Parameters
pThe object to release.
tiThe type of p.

Call this when you are done with the object returned by getUntyped(). The default implementation is a no-op, but if the getter dynamically allocated the object which it returned, this gives it a chance to free it.

◆ releaseObjectUntyped()

virtual void D3PD::IObjGetterTool::releaseObjectUntyped ( const void *  p)
virtualinherited

Release an object retrieved from the getter.

Parameters
pThe object to release.

Call this when you are done with the object returned by getUntyped(). The default implementation is a no-op, but if the getter dynamically allocated the object which it returned, this gives it a chance to free it.

◆ typeinfo()

const std::type_info & D3PD::SGGetterImpl::typeinfo ( ) const
virtual

Return the type of object retrieved by this tool.

Implements D3PD::IObjGetterTool.

Reimplemented in D3PD::SGCollectionGetterTool< CONT >, D3PD::SGTileDigitsGetterTool, D3PD::SGTileHitGetterTool, D3PD::SGTileModuleBitsGetterTool, and D3PD::SGTileRawChannelGetterTool.

Definition at line 39 of file SGGetterImpl.cxx.

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 }

Member Data Documentation

◆ m_clid

CLID D3PD::SGGetterImpl::m_clid
private

CLID for the object being retrieved.

Definition at line 126 of file SGGetterImpl.h.

◆ m_clidsvc

ServiceHandle<IClassIDSvc> D3PD::SGGetterImpl::m_clidsvc
protected

Property: Instance of the ClassIDSvc to use.

Definition at line 119 of file SGGetterImpl.h.

◆ m_resolver

SGKeyResolver D3PD::SGGetterImpl::m_resolver
protected

Helper: Resolve the SG key to use.

Definition at line 122 of file SGGetterImpl.h.

◆ m_sg

ServiceHandle<StoreGateSvc>& D3PD::SGGetterImpl::m_sg
private

The event storage service.

Definition at line 129 of file SGGetterImpl.h.

◆ m_sgkey

std::string D3PD::SGGetterImpl::m_sgkey
protected

Property: StoreGate key of the object being retrieved.

Definition at line 116 of file SGGetterImpl.h.

◆ m_typename

std::string D3PD::SGGetterImpl::m_typename
protected

Property: Name of the type of the object being retrieved.

Definition at line 113 of file SGGetterImpl.h.


The documentation for this class was generated from the following files:
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
D3PD::SGKeyResolver::initialize
StatusCode initialize(CLID clid, const std::string &typname)
Initialize.
Definition: SGKeyResolver.cxx:44
D3PD::SGGetterImpl::m_sgkey
std::string m_sgkey
Property: StoreGate key of the object being retrieved.
Definition: SGGetterImpl.h:116
dbg::ptr
void * ptr(T *p)
Definition: SGImplSvc.cxx:74
D3PD::nameToCLID
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.
Definition: TypeNameConversions.cxx:72
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
D3PD::clidToTypeinfo
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.
Definition: TypeNameConversions.cxx:99
D3PD::SGGetterImpl::m_clid
CLID m_clid
CLID for the object being retrieved.
Definition: SGGetterImpl.h:126
SG::DataProxy_cast
DATA * DataProxy_cast(DataProxy *proxy)
cast the proxy into the concrete data object it proxies
D3PD::SGKeyResolver::key
std::string key()
Return the SG key we should use.
Definition: SGKeyResolver.cxx:55
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
REPORT_MESSAGE
#define REPORT_MESSAGE(LVL)
Report a message.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:365
D3PD::SGGetterImpl::m_typename
std::string m_typename
Property: Name of the type of the object being retrieved.
Definition: SGGetterImpl.h:113
D3PD::SGGetterImpl::m_resolver
SGKeyResolver m_resolver
Helper: Resolve the SG key to use.
Definition: SGGetterImpl.h:122
D3PD::SGGetterImpl::m_clidsvc
ServiceHandle< IClassIDSvc > m_clidsvc
Property: Instance of the ClassIDSvc to use.
Definition: SGGetterImpl.h:119
SG::IConstAuxStore
Interface for const operations on an auxiliary store.
Definition: IConstAuxStore.h:64
D3PD::SGGetterImpl::m_sg
ServiceHandle< StoreGateSvc > & m_sg
The event storage service.
Definition: SGGetterImpl.h:129
SG::DataProxy
Definition: DataProxy.h:44
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37