ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
IAthMetaDataSvc Class Referenceabstract

This class provides the interface for MetaDataSvc. More...

#include <IAthMetaDataSvc.h>

Inheritance diagram for IAthMetaDataSvc:
Collaboration diagram for IAthMetaDataSvc:

Public Member Functions

 DeclareInterfaceID (IAthMetaDataSvc, 1, 0)
 
virtual StatusCode shmProxy (const std::string &filename)=0
 used by AthenaPoolCnvSvc More...
 
virtual std::set< std::string > getPerStreamKeysFor (const std::string &key) const
 Get all per-stream Key variants created for in-file metadata object with original key - if none, return key. More...
 
template<typename T , class TKEY >
T * tryRetrieve (const TKEY &key) const
 Retrieve an object of type T from MetaDataStore Return 0 if not found. More...
 
template<typename T , class TKEY >
const T * tryConstRetrieve (const TKEY &key) const
 
template<typename T , typename TKEY >
StatusCode record (T *p2BRegistered, const TKEY &key)
 Record an object with a key. More...
 
template<typename T , typename TKEY >
StatusCode record (std::unique_ptr< T > pUnique, const TKEY &key)
 Record an object with a key, take ownership of the unique_ptr obj. More...
 
template<typename T , typename TKEY >
StatusCode remove (const TKEY &key, bool ignoreIfAbsent=false)
 Remove object with this type+key. More...
 
template<typename T , typename TKEY >
bool contains (const TKEY &key)
 Check if object is already is already in store. More...
 
virtual StoreGateSvcoutputDataStore () const =0
 The output MetaData Store. More...
 
virtual const std::string currentRangeID () const =0
 rangeID for the current EventContext - used to index MetaContainers - More...
 
virtual void recordHook (const std::type_info &)
 Hook for implementation to react to recording an object. More...
 
virtual void removeHook (const std::type_info &)
 Hook for implementation to react to removing an object. More...
 

Private Attributes

std::mutex m_mutex
 

Detailed Description

This class provides the interface for MetaDataSvc.

Note that Gaudi has an IMetaDataSvc, so we don't want to use that name.

Definition at line 28 of file IAthMetaDataSvc.h.

Member Function Documentation

◆ contains()

template<typename T , typename TKEY >
bool IAthMetaDataSvc::contains ( const TKEY &  key)

Check if object is already is already in store.

Definition at line 155 of file IAthMetaDataSvc.h.

155  {
157  return false;
158  const MetaCont<T>* container =
160  return container && container->valid(currentRangeID());
161 }

◆ currentRangeID()

virtual const std::string IAthMetaDataSvc::currentRangeID ( ) const
pure virtual

rangeID for the current EventContext - used to index MetaContainers -

◆ DeclareInterfaceID()

IAthMetaDataSvc::DeclareInterfaceID ( IAthMetaDataSvc  ,
,
 
)

◆ getPerStreamKeysFor()

std::set< std::string > IAthMetaDataSvc::getPerStreamKeysFor ( const std::string &  key) const
inlinevirtual

Get all per-stream Key variants created for in-file metadata object with original key - if none, return key.

default implementation that maps a key to itself - overwritten in MetaDataSvc

Definition at line 82 of file IAthMetaDataSvc.h.

82  {
83  return std::set<std::string>( {key} );
84 }

◆ outputDataStore()

virtual StoreGateSvc* IAthMetaDataSvc::outputDataStore ( ) const
pure virtual

The output MetaData Store.

◆ record() [1/2]

template<typename T , typename TKEY >
StatusCode IAthMetaDataSvc::record ( std::unique_ptr< T >  pUnique,
const TKEY &  key 
)

Record an object with a key, take ownership of the unique_ptr obj.

Definition at line 130 of file IAthMetaDataSvc.h.

131 {
132  if( this->record( pUnique.get(), key ).isSuccess() ) {
133  (void)pUnique.release();
134  return StatusCode::SUCCESS;
135  }
136  pUnique.reset();
137  return StatusCode::FAILURE;
138 }

◆ record() [2/2]

template<typename T , typename TKEY >
StatusCode IAthMetaDataSvc::record ( T *  p2BRegistered,
const TKEY &  key 
)

Record an object with a key.

Definition at line 112 of file IAthMetaDataSvc.h.

113 {
114  std::lock_guard lock(m_mutex);
116  StatusCode sc = StatusCode::FAILURE;
117  if( !container ) {
118  auto cont_uptr = std::make_unique< MetaCont<T> >();
119  if( cont_uptr->insert( currentRangeID() , pObject) )
120  sc = outputDataStore()->record( std::move(cont_uptr), key );
121  } else {
122  if (container->insert(currentRangeID(), pObject)) sc = StatusCode::SUCCESS;
123  }
124  if (sc.isSuccess()) recordHook(typeid(T));
125  return sc;
126 }

◆ recordHook()

virtual void IAthMetaDataSvc::recordHook ( const std::type_info &  )
inlinevirtual

Hook for implementation to react to recording an object.

Definition at line 70 of file IAthMetaDataSvc.h.

70 {}

◆ remove()

template<typename T , class TKEY >
StatusCode IAthMetaDataSvc::remove ( const TKEY &  key,
bool  ignoreIfAbsent = false 
)

Remove object with this type+key.

Definition at line 142 of file IAthMetaDataSvc.h.

143 {
144  std::lock_guard lock(m_mutex);
145  // change erase to setting nullptr?
147  if (container && container->erase(currentRangeID())) {
148  if (container->entries() == 0u) removeHook(typeid(T));
149  return StatusCode::SUCCESS;
150  }
151  return ignoreIfAbsent? StatusCode::SUCCESS : StatusCode::FAILURE;
152 }

◆ removeHook()

virtual void IAthMetaDataSvc::removeHook ( const std::type_info &  )
inlinevirtual

Hook for implementation to react to removing an object.

Definition at line 73 of file IAthMetaDataSvc.h.

73 {}

◆ shmProxy()

virtual StatusCode IAthMetaDataSvc::shmProxy ( const std::string &  filename)
pure virtual

◆ tryConstRetrieve()

template<typename T , class TKEY >
const T * IAthMetaDataSvc::tryConstRetrieve ( const TKEY &  key) const

Definition at line 102 of file IAthMetaDataSvc.h.

103 {
104  const MetaCont<T>* container = outputDataStore()->tryRetrieve< MetaCont<T> >(key);
105  if( container ) {
106  return container->get( currentRangeID() );
107  }
108  return nullptr;
109 }

◆ tryRetrieve()

template<typename T , class TKEY >
T * IAthMetaDataSvc::tryRetrieve ( const TKEY &  key) const

Retrieve an object of type T from MetaDataStore Return 0 if not found.

Don't print any WARNINGs

Parameters
keyThe key to use for the lookup.

Definition at line 92 of file IAthMetaDataSvc.h.

93 {
94  const MetaCont<T>* container = outputDataStore()->tryRetrieve< MetaCont<T> >(key);
95  if( container ) {
96  return container->get( currentRangeID() );
97  }
98  return nullptr;
99 }

Member Data Documentation

◆ m_mutex

std::mutex IAthMetaDataSvc::m_mutex
private

Definition at line 76 of file IAthMetaDataSvc.h.


The documentation for this class was generated from the following file:
StoreGateSvc::record
StatusCode record(T *p2BRegistered, const TKEY &key)
Record an object with a key.
IAthMetaDataSvc::contains
bool contains(const TKEY &key)
Check if object is already is already in store.
Definition: IAthMetaDataSvc.h:155
StoreGateSvc::tryRetrieve
T * tryRetrieve() const
Variant of the above which doesn't print a warning message.
MetaCont::get
T * get(const SourceID &sid) const
Definition: MetaCont.h:166
IAthMetaDataSvc::currentRangeID
virtual const std::string currentRangeID() const =0
rangeID for the current EventContext - used to index MetaContainers -
IAthMetaDataSvc::record
StatusCode record(T *p2BRegistered, const TKEY &key)
Record an object with a key.
Definition: IAthMetaDataSvc.h:112
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:83
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
MetaCont::insert
virtual bool insert(const SourceID &sid, void *obj) override final
Definition: MetaCont.h:118
MetaCont
Definition: MetaCont.h:48
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
IAthMetaDataSvc::removeHook
virtual void removeHook(const std::type_info &)
Hook for implementation to react to removing an object.
Definition: IAthMetaDataSvc.h:73
MetaCont::erase
virtual size_t erase(const SourceID &sid) override final
Definition: MetaCont.h:126
MetaCont::valid
virtual bool valid(const SourceID &sid) const override final
Definition: MetaCont.h:142
StoreGateSvc::tryConstRetrieve
const T * tryConstRetrieve() const
IAthMetaDataSvc::recordHook
virtual void recordHook(const std::type_info &)
Hook for implementation to react to recording an object.
Definition: IAthMetaDataSvc.h:70
MetaCont::entries
virtual int entries() const override
Definition: MetaCont.h:193
IAthMetaDataSvc::m_mutex
std::mutex m_mutex
Definition: IAthMetaDataSvc.h:76
IAthMetaDataSvc::outputDataStore
virtual StoreGateSvc * outputDataStore() const =0
The output MetaData Store.
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37