ATLAS Offline Software
MetaDataSvc.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ATHENASERVICES_METADATASVC_H
6 #define ATHENASERVICES_METADATASVC_H
7 
13 #include <map>
14 #include <set>
15 #include <typeinfo>
16 
21 #include "Gaudi/Property.h" // no forward decl: typedef
22 #include "GaudiKernel/IClassIDSvc.h"
23 #include "GaudiKernel/IFileMgr.h" // for FILEMGR_CALLBACK_ARGS
24 #include "GaudiKernel/IIncidentListener.h"
25 #include "GaudiKernel/IIoComponent.h"
26 #include "GaudiKernel/ServiceHandle.h"
27 #include "GaudiKernel/ToolHandle.h"
28 #include "GaudiKernel/FileIncident.h"
29 
30 // Forward declarations
31 class IAddressCreator;
32 class StoreGateSvc;
33 class IAlgTool;
35 
36 namespace Io {
37  class FileAttr;
38 }
39 
84 class MetaDataSvc : public extends<::AthService,
85  IAddressProvider,
86  IIncidentListener,
87  IAthMetaDataSvc,
88  IIoComponent>
89 {
90  public:
91  using IService::interfaceID;
92 
94  MetaDataSvc(const std::string& name, ISvcLocator* pSvcLocator);
96  virtual ~MetaDataSvc();
97 
98  public: // Non-static members
104  virtual StatusCode initialize() override;
106  virtual StatusCode stop() override;
108  virtual StatusCode finalize() override;
130  virtual StatusCode newMetadataSource(const Incident& /* inc */);
131 
139  virtual StatusCode retireMetadataSource(const Incident& /* inc */);
149  virtual StatusCode prepareOutput();
150 
162  virtual StatusCode prepareOutput(const std::string& outputName);
163 
171  virtual StatusCode shmProxy(const std::string& filename) override;
185  IAddressProvider::tadList& /* tads */) override {
186  return StatusCode::SUCCESS;
187  }
188 
200  IAddressProvider::tadList& tads) override;
201 
209  SG::TransientAddress* /* tad */,
210  const EventContext& /* ctx */) override {
211  return StatusCode::FAILURE;
212  }
220  virtual void handle(const Incident& incident) override;
221 
224  StatusCode transitionMetaDataFile(const std::string& outputConn, bool disconnect);
225 
231  virtual StatusCode io_reinit() override;
232 
233  StatusCode rootOpenAction(FILEMGR_CALLBACK_ARGS);
234 
235  virtual StoreGateSvc* outputDataStore() const override final {
236  return &*m_outputDataStore;
237  }
238 
239  virtual const std::string currentRangeID() const override final;
240 
242 
244  public:
245  ToolLockGuard(const MetaDataSvc& mds) : m_mds(mds) { m_mds.lockTools(); }
246  ~ToolLockGuard() { m_mds.unlockTools(); }
247  ToolLockGuard(const ToolLockGuard&) = delete;
248  void operator=(const ToolLockGuard&) = delete;
249 
250  private:
252  };
253 
254  void lockTools() const;
255  void unlockTools() const;
256 
257  void recordHook(const std::type_info&) override;
258  void removeHook(const std::type_info&) override;
259 
263  std::string removeStreamFromKey(std::string& key);
264 
268  virtual std::set<std::string> getPerStreamKeysFor(const std::string& key ) const override final;
269 
270  private:
292  StatusCode addProxyToInputMetaDataStore(const std::string& tokenStr);
295  StatusCode initInputMetaDataStore(const std::string& fileName);
296 
297  private: // data
305 
311  std::map<std::string, CLID> m_persToClid;
312 
313  std::set<CLID> m_handledClasses;
315  const std::string m_streamInKeyMark = "__STREAM[";
316 
317  std::map< std::string, std::set<std::string> > m_streamKeys;
318 
319  private: // properties
321  StringProperty m_metaDataCont;
323  ToolHandleArray<IMetaDataTool> m_metaDataTools;
324 };
325 
326 #endif
MetaDataSvc::preLoadAddresses
StatusCode preLoadAddresses(StoreID::type, IAddressProvider::tadList &) override
does nothing.
Definition: MetaDataSvc.h:184
MetaDataSvc::stop
virtual StatusCode stop() override
stop the metadata service
Definition: MetaDataSvc.cxx:176
MetaDataSvc::m_storageType
long m_storageType
Definition: MetaDataSvc.h:306
MetaDataSvc::initialize
virtual StatusCode initialize() override
initialize the metadata service at the beginning of the job
Definition: MetaDataSvc.cxx:99
IAthMetaDataSvc.h
This file contains the class definition for the IAthMetaDataSvc class.
MetaDataSvc::m_metaDataTools
ToolHandleArray< IMetaDataTool > m_metaDataTools
MetaDataTools, vector with the MetaData tools.
Definition: MetaDataSvc.h:323
MetaDataSvc::m_clearedInputDataStore
bool m_clearedInputDataStore
Definition: MetaDataSvc.h:307
MetaDataSvc::lockTools
void lockTools() const
Definition: MetaDataSvc.cxx:639
MetaDataSvc::m_clearedOutputDataStore
bool m_clearedOutputDataStore
Definition: MetaDataSvc.h:308
SG::TransientAddress
Definition: TransientAddress.h:32
IMetaDataTool.h
This file contains the class definition for the IMetaDataTool class.
MetaDataSvc::m_inputDataStore
ServiceHandle< StoreGateSvc > m_inputDataStore
Definition: MetaDataSvc.h:298
MetaDataSvc::m_metaDataCont
StringProperty m_metaDataCont
MetaDataContainer, POOL container name for MetaData.
Definition: MetaDataSvc.h:321
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
MetaDataSvc::~MetaDataSvc
virtual ~MetaDataSvc()
Destructor.
Definition: MetaDataSvc.cxx:96
MetaDataSvc::ToolLockGuard::~ToolLockGuard
~ToolLockGuard()
Definition: MetaDataSvc.h:246
MetaDataSvc::io_reinit
virtual StatusCode io_reinit() override
Implements IIoComponent interface sets m_outputPrepared to false and prints some information.
Definition: MetaDataSvc.cxx:395
MetaDataSvc::outputDataStore
virtual StoreGateSvc * outputDataStore() const override final
Definition: MetaDataSvc.h:235
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:125
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
MetaDataSvc::finalize
virtual StatusCode finalize() override
finalize the metadata service at the end of the job
Definition: MetaDataSvc.cxx:151
MetaDataSvc::ToolLockGuard
Definition: MetaDataSvc.h:243
MetaDataSvc::ToolLockGuard::ToolLockGuard
ToolLockGuard(const ToolLockGuard &)=delete
MetaDataSvc::m_outputPrepared
bool m_outputPrepared
Definition: MetaDataSvc.h:310
MetaDataSvc::newMetadataSource
virtual StatusCode newMetadataSource(const Incident &)
Fills the input metadata store with the content of the new input file.
Definition: MetaDataSvc.cxx:217
MetaDataSvc::m_addrCrtr
ServiceHandle< IAddressCreator > m_addrCrtr
Definition: MetaDataSvc.h:300
MetaDataSvc::initInputMetaDataStore
StatusCode initInputMetaDataStore(const std::string &fileName)
Initialize input metadata store - can be called directly or via BeginInputFile incident.
Definition: MetaDataSvc.cxx:519
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
MetaDataSvc::m_outputDataStore
ServiceHandle< StoreGateSvc > m_outputDataStore
Definition: MetaDataSvc.h:299
MetaDataSvc::addProxyToInputMetaDataStore
StatusCode addProxyToInputMetaDataStore(const std::string &tokenStr)
Definition: MetaDataSvc.cxx:432
MetaDataSvc::remapMetaContCLID
CLID remapMetaContCLID(const CLID &item_id) const
Definition: MetaDataSvc.cxx:592
MetaDataSvc::m_allowMetaDataStop
bool m_allowMetaDataStop
Definition: MetaDataSvc.h:309
MetaDataSvc::m_streamKeys
std::map< std::string, std::set< std::string > > m_streamKeys
Definition: MetaDataSvc.h:317
Io
Definition: MetaDataSvc.h:36
MetaDataSvc::MetaDataSvc
MetaDataSvc(const std::string &name, ISvcLocator *pSvcLocator)
Standard Service Constructor.
Definition: MetaDataSvc.cxx:52
MetaDataSvc
Manages the content of the metadata stores.
Definition: MetaDataSvc.h:89
MetaDataSvc::m_fileMgr
ServiceHandle< IFileMgr > m_fileMgr
Definition: MetaDataSvc.h:301
MetaDataSvc::retireMetadataSource
virtual StatusCode retireMetadataSource(const Incident &)
Allows metadata tools to act before an input file is closed.
Definition: MetaDataSvc.cxx:251
MetaDataSvc::prepareOutput
virtual StatusCode prepareOutput()
Makes the metadata store ready for output.
Definition: MetaDataSvc.cxx:271
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
MetaDataSvc::m_incSvc
ServiceHandle< IIncidentSvc > m_incSvc
Definition: MetaDataSvc.h:302
OutputStreamSequencerSvc
This class provides configuration properties to enable OutputStream file sequences.
Definition: OutputStreamSequencerSvc.h:30
MetaDataSvc::transitionMetaDataFile
StatusCode transitionMetaDataFile(const std::string &outputConn, bool disconnect)
Transition output metadata file - fire MeteDataStop incident to transition OutputStream and disconnec...
Definition: MetaDataSvc.cxx:368
MetaDataSvc::unlockTools
void unlockTools() const
Definition: MetaDataSvc.cxx:649
MetaDataSvc::shmProxy
virtual StatusCode shmProxy(const std::string &filename) override
Loads file metadata from memory shared between streams in SharedWriter This function clears the input...
Definition: MetaDataSvc.cxx:312
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
MetaDataSvc::removeHook
void removeHook(const std::type_info &) override
Definition: MetaDataSvc.cxx:626
MetaDataSvc::currentRangeID
virtual const std::string currentRangeID() const override final
Definition: MetaDataSvc.cxx:586
MetaDataSvc::getPerStreamKeysFor
virtual std::set< std::string > getPerStreamKeysFor(const std::string &key) const override final
Get all per-stream Key variants created for in-file metadata object with original key If no stream-sp...
Definition: MetaDataSvc.cxx:424
lumiFormat.outputName
string outputName
Definition: lumiFormat.py:65
MetaDataSvc::handle
virtual void handle(const Incident &incident) override
react to file incidents.
Definition: MetaDataSvc.cxx:336
StoreID::type
type
Definition: StoreID.h:24
MetaDataSvc::rootOpenAction
StatusCode rootOpenAction(FILEMGR_CALLBACK_ARGS)
Definition: MetaDataSvc.cxx:407
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
MetaDataSvc::m_persToClid
std::map< std::string, CLID > m_persToClid
Definition: MetaDataSvc.h:311
IAddressProvider::tadList
std::list< SG::TransientAddress * > tadList
Definition: IAddressProvider.h:32
AthService.h
IAddressProvider.h
MetaDataSvc::removeStreamFromKey
std::string removeStreamFromKey(std::string &key)
check if the metadata object key contains Stream name (added by SharedWriter in MetaDataSvc) remove s...
Definition: MetaDataSvc.cxx:413
MetaDataSvc::m_streamInKeyMark
const std::string m_streamInKeyMark
marker string for embedding stream name in MetaData object keys for SharedWriter server
Definition: MetaDataSvc.h:315
MetaDataSvc::recordHook
void recordHook(const std::type_info &) override
Definition: MetaDataSvc.cxx:613
MetaDataSvc::ToolLockGuard::m_mds
const MetaDataSvc & m_mds
Definition: MetaDataSvc.h:251
MetaDataSvc::loadAddresses
StatusCode loadAddresses(StoreID::type storeID, IAddressProvider::tadList &tads) override
loads addresses of versioned metadata object.
Definition: MetaDataSvc.cxx:185
MetaDataSvc::m_classIDSvc
ServiceHandle< IClassIDSvc > m_classIDSvc
Definition: MetaDataSvc.h:304
MetaDataSvc::updateAddress
StatusCode updateAddress(StoreID::type, SG::TransientAddress *, const EventContext &) override
always fails
Definition: MetaDataSvc.h:208
MetaDataSvc::ToolLockGuard::ToolLockGuard
ToolLockGuard(const MetaDataSvc &mds)
Definition: MetaDataSvc.h:245
ServiceHandle< StoreGateSvc >
MetaDataSvc::ToolLockGuard::operator=
void operator=(const ToolLockGuard &)=delete
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
MetaDataSvc::m_handledClasses
std::set< CLID > m_handledClasses
Definition: MetaDataSvc.h:313
MetaDataSvc::m_outSeqSvc
ServiceHandle< OutputStreamSequencerSvc > m_outSeqSvc
Definition: MetaDataSvc.h:303