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)
 Check if object is already is already in store.
virtual StoreGateSvcoutputDataStore () const =0
 The output MetaData Store.
virtual const std::string currentRangeID () const =0
 rangeID for the current EventContext - used to index MetaContainers -
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.

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

153 {
154 if (!outputDataStore()->contains< MetaCont<T> >(key))
155 return false;
156 const MetaCont<T>* container =
157 outputDataStore()->tryConstRetrieve< MetaCont<T> >(key);
158 return container && container->valid(currentRangeID());
159}
virtual StoreGateSvc * outputDataStore() const =0
The output MetaData Store.
virtual const std::string currentRangeID() const =0
rangeID for the current EventContext - used to index MetaContainers -
bool contains(const TKEY &key)
Check if object is already is already in store.
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 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.release(), key ).isSuccess() ) {
133 return StatusCode::SUCCESS;
134 }
135 return StatusCode::FAILURE;
136}
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 112 of file IAthMetaDataSvc.h.

113{
114 std::lock_guard lock(m_mutex);
115 MetaCont<T>* container = outputDataStore()->tryRetrieve< MetaCont<T> >(key);
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}
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 & )
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 140 of file IAthMetaDataSvc.h.

141{
142 std::lock_guard lock(m_mutex);
143 // change erase to setting nullptr?
144 MetaCont<T>* container = outputDataStore()->tryRetrieve< MetaCont<T> >(key);
145 if (container && container->erase(currentRangeID())) {
146 if (container->entries() == 0u) removeHook(typeid(T));
147 return StatusCode::SUCCESS;
148 }
149 return ignoreIfAbsent? StatusCode::SUCCESS : StatusCode::FAILURE;
150}
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 & )
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}
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 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: