1 // Dear emacs, this is -*- c++ -*-
3 // Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5 #ifndef XAODROOTACCESSINTERFACES_TVIRTUALEVENT_ICC
6 #define XAODROOTACCESSINTERFACES_TVIRTUALEVENT_ICC
8 #include "AthContainers/normalizedTypeinfoName.h"
15 /// This is the function used by all the smart pointers to get access
16 /// to objects in the event.
18 /// @param obj The pointer that should be set [output]
19 /// @param key The hashed key of the object to retrieve
20 /// @param silent When set to <code>true</code>, failure is handled silently
21 /// @returns <code>true</code> if the operation was successful,
22 /// <code>false</code> otherwise
24 template< typename T >
25 bool TVirtualEvent::retrieve( const T*& obj, sgkey_t key, bool silent ) {
27 // Look among the output objects first:
28 const void* result = getOutputObject( key, typeid( T ) );
29 // Check if it succeeded:
31 // Try the input then:
32 result = getInputObject( key, typeid( T ), silent );
35 ::Warning( "xAOD::TVirtualEvent::retrieve",
36 "Couldn't retrieve %s/0x%08x",
37 typeid( T ).name(), key );
43 // If we were successful:
44 obj = reinterpret_cast< const T* >( result );
48 /// This is a convenience function for human users for getting access to
49 /// an existing object, using a string key instead of a hashed identifier.
51 /// Internally it just creates a hash from the key, and perform the retrieve
54 /// @param obj The pointer that should be set [output]
55 /// @param key The key of the object to retrieve
56 /// @returns <code>true</code> if the operation was successful,
57 /// <code>false</code> otherwise
59 template< typename T >
60 bool TVirtualEvent::retrieve( const T*& obj, const std::string& key,
63 return retrieve( obj, getHash( key ), silent );
66 template< typename T >
67 void TVirtualEvent::keys( std::vector< std::string >& vkeys,
68 bool metadata ) const {
69 getNames( SG::normalizedTypeinfoName( typeid( T ) ), vkeys, metadata);
74 #endif // XAODROOTACCESSINTERFACES_TVIRTUALEVENT_ICC