ATLAS Offline Software
Loading...
Searching...
No Matches
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
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.
template<typename T, class TKEY>
T * tryRetrieve (const TKEY &key) const
 Retrieve an object of type T from MetaDataStore Return 0 if not found.
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.
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.
template<typename T, typename TKEY>
StatusCode remove (const TKEY &key, bool ignoreIfAbsent=false)
 Remove object with this type+key.
template<typename T, typename TKEY>
bool contains (const TKEY &key) const
 Check if object is already is already in store.
virtual const std::string currentRangeID () const =0
 rangeID for the current EventContext - used to index MetaContainers -

Protected Member Functions

virtual void recordHook (const std::type_info &)
 Hook for implementation to react to recording an object.
virtual void removeHook (const std::type_info &)
 Hook for implementation to react to removing an object.
virtual StoreGateSvcoutputDataStore () const =0
 The output MetaData Store.

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) const

Check if object is already is already in store.

Definition at line 154 of file IAthMetaDataSvc.h.

154 {
155 if (!outputDataStore()->contains< MetaCont<T> >(key))
156 return false;
157 const MetaCont<T>* container =
158 outputDataStore()->tryConstRetrieve< MetaCont<T> >(key);
159 return container && container->valid(currentRangeID());
160}
virtual StoreGateSvc * outputDataStore() const =0
The output MetaData Store.
bool contains(const TKEY &key) const
Check if object is already is already in store.
virtual const std::string currentRangeID() const =0
rangeID for the current EventContext - used to index MetaContainers -
virtual bool valid(const SourceID &sid) const override final
Definition MetaCont.h:141
const T * tryConstRetrieve() const

◆ currentRangeID()

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

rangeID for the current EventContext - used to index MetaContainers -

◆ DeclareInterfaceID()

IAthMetaDataSvc::DeclareInterfaceID ( IAthMetaDataSvc ,
1 ,
0  )

◆ 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 83 of file IAthMetaDataSvc.h.

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

◆ outputDataStore()

virtual StoreGateSvc * IAthMetaDataSvc::outputDataStore ( ) const
protectedpure 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 131 of file IAthMetaDataSvc.h.

132{
133 if( this->record( pUnique.release(), key ).isSuccess() ) {
134 return StatusCode::SUCCESS;
135 }
136 return StatusCode::FAILURE;
137}
StatusCode record(T *p2BRegistered, const TKEY &key)
Record an object with a key.

◆ 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 113 of file IAthMetaDataSvc.h.

114{
115 std::lock_guard lock(m_mutex);
116 MetaCont<T>* container = outputDataStore()->tryRetrieve< MetaCont<T> >(key);
117 StatusCode sc = StatusCode::FAILURE;
118 if( !container ) {
119 auto cont_uptr = std::make_unique< MetaCont<T> >();
120 if( cont_uptr->insert( currentRangeID() , pObject) )
121 sc = outputDataStore()->record( std::move(cont_uptr), key );
122 } else {
123 if (container->insert(currentRangeID(), pObject)) sc = StatusCode::SUCCESS;
124 }
125 if (sc.isSuccess()) recordHook(typeid(T));
126 return sc;
127}
static Double_t sc
virtual void recordHook(const std::type_info &)
Hook for implementation to react to recording an object.
virtual bool insert(const SourceID &sid, void *obj) override final
Definition MetaCont.h:117
StatusCode record(T *p2BRegistered, const TKEY &key)
Record an object with a key.
T * tryRetrieve() const
Variant of the above which doesn't print a warning message.
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ recordHook()

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

Hook for implementation to react to recording an object.

Definition at line 68 of file IAthMetaDataSvc.h.

68{}

◆ remove()

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

Remove object with this type+key.

Definition at line 141 of file IAthMetaDataSvc.h.

142{
143 std::lock_guard lock(m_mutex);
144 // change erase to setting nullptr?
145 MetaCont<T>* container = outputDataStore()->tryRetrieve< MetaCont<T> >(key);
146 if (container && container->erase(currentRangeID())) {
147 if (container->entries() == 0u) removeHook(typeid(T));
148 return StatusCode::SUCCESS;
149 }
150 return ignoreIfAbsent? StatusCode::SUCCESS : StatusCode::FAILURE;
151}
virtual void removeHook(const std::type_info &)
Hook for implementation to react to removing an object.
virtual int entries() const override
Definition MetaCont.h:192
virtual size_t erase(const SourceID &sid) override final
Definition MetaCont.h:125

◆ removeHook()

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

Hook for implementation to react to removing an object.

Definition at line 71 of file IAthMetaDataSvc.h.

71{}

◆ 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 103 of file IAthMetaDataSvc.h.

104{
105 const MetaCont<T>* container = outputDataStore()->tryRetrieve< MetaCont<T> >(key);
106 if( container ) {
107 return container->get( currentRangeID() );
108 }
109 return nullptr;
110}
T * get(const SourceID &sid) const
Definition MetaCont.h:165

◆ 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 93 of file IAthMetaDataSvc.h.

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

Member Data Documentation

◆ m_mutex

std::mutex IAthMetaDataSvc::m_mutex
private

Definition at line 77 of file IAthMetaDataSvc.h.


The documentation for this class was generated from the following file: