1 // Dear emacs, this is -*- c++ -*-
3 // Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
5 #ifndef XAODROOTACCESSINTERFACES_TVIRTUALEVENT_ICC
6 #define XAODROOTACCESSINTERFACES_TVIRTUALEVENT_ICC
13 /// This is the function used by all the smart pointers to get access
14 /// to objects in the event.
16 /// @param obj The pointer that should be set [output]
17 /// @param key The hashed key of the object to retrieve
18 /// @param silent When set to <code>true</code>, failure is handled silently
19 /// @returns <code>true</code> if the operation was successful,
20 /// <code>false</code> otherwise
22 template< typename T >
23 bool TVirtualEvent::retrieve( const T*& obj, sgkey_t key, bool silent ) {
25 // Look among the output objects first:
26 const void* result = getOutputObject( key, typeid( T ) );
27 // Check if it succeeded:
29 // Try the input then:
30 result = getInputObject( key, typeid( T ), silent );
33 ::Warning( "xAOD::TVirtualEvent::retrieve",
34 "Couldn't retrieve %s/0x%08x",
35 typeid( T ).name(), key );
41 // If we were successful:
42 obj = reinterpret_cast< const T* >( result );
46 /// This is a convenience function for human users for getting access to
47 /// an existing object, using a string key instead of a hashed identifier.
49 /// Internally it just creates a hash from the key, and perform the retrieve
52 /// @param obj The pointer that should be set [output]
53 /// @param key The key of the object to retrieve
54 /// @returns <code>true</code> if the operation was successful,
55 /// <code>false</code> otherwise
57 template< typename T >
58 bool TVirtualEvent::retrieve( const T*& obj, const std::string& key,
61 return retrieve( obj, getHash( key ), silent );
66 #endif // XAODROOTACCESSINTERFACES_TVIRTUALEVENT_ICC