ATLAS Offline Software
RDBAccessSvc.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
15 #ifndef RDBACCESSSVC_RDBACCESSSVC_H
16 #define RDBACCESSSVC_RDBACCESSSVC_H
17 
19 #include "RDBRecordset.h"
20 
22 
23 #include <string>
24 #include <map>
25 
26 class ISvcLocator;
27 class RDBRecordset;
28 
29 namespace coral
30 {
31  class ISessionProxy;
32 }
33 
34 template <class TYPE> class SvcFactory;
35 
36 
37 // Recordsets of single connection
38 typedef std::map<std::string, IRDBRecordset_ptr> RecordsetPtrMap;
39 
40 // Pointers to recordset maps by connection name
41 typedef std::map<std::string, RecordsetPtrMap> RecordsetPtrsByConn;
42 
43 // Session map
44 typedef std::map<std::string, coral::ISessionProxy*> SessionMap;
45 
46 // Lookup table for global tag contents quick access
47 typedef std::pair<std::string, std::string> TagNameId;
48 typedef std::map<std::string, TagNameId> TagNameIdByNode;
49 typedef std::map<std::string, TagNameIdByNode*> GlobalTagLookupMap; // Key - <Global_Tag_Name>::<Connection>
50 
58 class RDBAccessSvc final : public AthService, virtual public IRDBAccessSvc
59 {
60  public:
62  RDBAccessSvc(const std::string& name, ISvcLocator* svc);
63 
64  StatusCode initialize() override;
65  StatusCode finalize() override;
66  StatusCode queryInterface( const InterfaceID& riid, void** ppvInterface ) override;
67 
68  friend class SvcFactory<RDBAccessSvc>;
69 
71  static const InterfaceID& interfaceID() { return IID_IRDBAccessSvc; }
72 
77  bool connect(const std::string& connName) override;
78 
82  bool disconnect(const std::string& connName) override;
83 
86  bool shutdown(const std::string& connName) override;
87 
94  IRDBRecordset_ptr getRecordsetPtr(const std::string& node
95  , const std::string& tag
96  , const std::string& tag2node=""
97  , const std::string& connName = "ATLASDD") override;
98 
105  std::string getChildTag(const std::string& childNode
106  , const std::string& parentTag
107  , const std::string& parentNode
108  , const std::string& connName) override;
109 
110  std::string getChildTag(const std::string& childNode
111  , const std::string& parentTag
112  , const std::string& parentNode
113  , const std::string& connName
114  , bool force);
115 
116  std::unique_ptr<IRDBQuery> getQuery(const std::string& node
117  , const std::string& tag
118  , const std::string& tag2node
119  , const std::string& connName) override;
120 
121  void getTagDetails(RDBTagDetails& tagDetails
122  , const std::string& tag
123  , const std::string& connName = "ATLASDD") override;
124 
125  void getAllLeafNodes(std::vector<std::string>& list
126  , const std::string& connName = "ATLASDD");
127 
128  std::vector<std::string> getLockedSupportedTags(const std::string& supportedFlag
129  , const std::string& connName = "ATLASDD");
130 
131  coral::ISessionProxy* getSession(const std::string& connName = "ATLASDD");
132 
133 private:
135  std::map<std::string, unsigned int> m_openConnections;
136 
139 
142 
143  bool shutdown_connection(const std::string& connName);
144 };
145 
146 #endif
RDBAccessSvc::getQuery
std::unique_ptr< IRDBQuery > getQuery(const std::string &node, const std::string &tag, const std::string &tag2node, const std::string &connName) override
Definition: RDBAccessSvc.cxx:215
RDBAccessSvc::getChildTag
std::string getChildTag(const std::string &childNode, const std::string &parentTag, const std::string &parentNode, const std::string &connName) override
Gets the tag name for the node by giving its parent node tag.
Definition: RDBAccessSvc.cxx:271
RDBAccessSvc::m_recordsetMutex
std::mutex m_recordsetMutex
Definition: RDBAccessSvc.h:140
RDBAccessSvc::getLockedSupportedTags
std::vector< std::string > getLockedSupportedTags(const std::string &supportedFlag, const std::string &connName="ATLASDD")
Definition: RDBAccessSvc.cxx:454
calibdata.force
bool force
Definition: calibdata.py:19
RecordsetPtrMap
std::map< std::string, IRDBRecordset_ptr > RecordsetPtrMap
Definition: RDBAccessSvc.h:34
RDBAccessSvc::getSession
coral::ISessionProxy * getSession(const std::string &connName="ATLASDD")
Definition: RDBAccessSvc.cxx:496
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
RDBAccessSvc::initialize
StatusCode initialize() override
Definition: RDBAccessSvc.cxx:502
SvcFactory
Definition: AthCnvSvc.h:28
RDBAccessSvc::connect
bool connect(const std::string &connName) override
Connect to the relational DB.
Definition: RDBAccessSvc.cxx:42
RDBAccessSvc::finalize
StatusCode finalize() override
Definition: RDBAccessSvc.cxx:507
TagNameIdByNode
std::map< std::string, TagNameId > TagNameIdByNode
Definition: RDBAccessSvc.h:48
RDBAccessSvc::queryInterface
StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface) override
Definition: RDBAccessSvc.cxx:525
coral
Definition: ISecondaryEventSelector.h:19
SessionMap
std::map< std::string, coral::ISessionProxy * > SessionMap
Definition: RDBAccessSvc.h:44
IRDBAccessSvc.h
Definition of the abstract IRDBAccessSvc interface.
RDBAccessSvc
RDBAccessSvc is the implementation of IRDBAccessSvc interface.
Definition: RDBAccessSvc.h:59
RDBAccessSvc::RDBAccessSvc
RDBAccessSvc(const std::string &name, ISvcLocator *svc)
Standard Service Constructor.
Definition: RDBAccessSvc.cxx:37
IRDBAccessSvc
IRDBAccessSvc is an abstract interface to the athena service that provides the following functionalit...
Definition: IRDBAccessSvc.h:45
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AthService
Definition: AthService.h:32
RDBAccessSvc::m_globalTagLookup
GlobalTagLookupMap m_globalTagLookup
Definition: RDBAccessSvc.h:138
RecordsetPtrsByConn
std::map< std::string, RecordsetPtrMap > RecordsetPtrsByConn
Definition: RDBAccessSvc.h:41
RDBAccessSvc::interfaceID
static const InterfaceID & interfaceID()
Retrieve interface ID.
Definition: RDBAccessSvc.h:71
RDBAccessSvc::getRecordsetPtr
IRDBRecordset_ptr getRecordsetPtr(const std::string &node, const std::string &tag, const std::string &tag2node="", const std::string &connName="ATLASDD") override
Provides access to the Recordset object containing HVS-tagged data.
Definition: RDBAccessSvc.cxx:150
RDBAccessSvc::shutdown
bool shutdown(const std::string &connName) override
Closes the connection regardless of the counter value.
Definition: RDBAccessSvc.cxx:110
RDBAccessSvc::m_sessionMutex
std::mutex m_sessionMutex
Definition: RDBAccessSvc.h:141
RDBAccessSvc::m_sessions
SessionMap m_sessions
Definition: RDBAccessSvc.h:134
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
RDBAccessSvc::m_recordsetptrs
RecordsetPtrsByConn m_recordsetptrs
Definition: RDBAccessSvc.h:137
IRDBRecordset_ptr
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition: IRDBAccessSvc.h:25
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
RDBTagDetails
coral::AttributeList RDBTagDetails
Definition: IRDBAccessSvc.h:29
RDBRecordset.h
Definition of RDBRecordset class.
AthService.h
GlobalTagLookupMap
std::map< std::string, TagNameIdByNode * > GlobalTagLookupMap
Definition: RDBAccessSvc.h:49
RDBAccessSvc::shutdown_connection
bool shutdown_connection(const std::string &connName)
Definition: RDBAccessSvc.cxx:127
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
RDBAccessSvc::m_openConnections
std::map< std::string, unsigned int > m_openConnections
Definition: RDBAccessSvc.h:135
RDBAccessSvc::getTagDetails
void getTagDetails(RDBTagDetails &tagDetails, const std::string &tag, const std::string &connName="ATLASDD") override
Returns AttributeList with tag details Attributes in the list: Locked (bool), Supported (bool)
Definition: RDBAccessSvc.cxx:337
RDBAccessSvc::getAllLeafNodes
void getAllLeafNodes(std::vector< std::string > &list, const std::string &connName="ATLASDD")
Definition: RDBAccessSvc.cxx:415
node
Definition: memory_hooks-stdcmalloc.h:74
TagNameId
std::pair< std::string, std::string > TagNameId
Definition: RDBAccessSvc.h:47
RDBAccessSvc::disconnect
bool disconnect(const std::string &connName) override
If the counnection counter==1 closes the connection.
Definition: RDBAccessSvc.cxx:82
RDBRecordset
RDBRecordset is an implementation of IRDBRecordset interface.
Definition: RDBRecordset.h:39