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 
14 #ifndef RDBACCESSSVC_RDBACCESSSVC_H
15 #define RDBACCESSSVC_RDBACCESSSVC_H
16 
18 #include "RDBRecordset.h"
19 
21 
22 #include <string>
23 #include <map>
24 
25 class ISvcLocator;
26 class RDBRecordset;
27 
28 namespace coral
29 {
30  class ISessionProxy;
31 }
32 
33 template <class TYPE> class SvcFactory;
34 
35 
36 // Recordsets of single connection
37 typedef std::map<std::string, IRDBRecordset_ptr> RecordsetPtrMap;
38 
39 // Pointers to recordset maps by connection name
40 typedef std::map<std::string, RecordsetPtrMap> RecordsetPtrsByConn;
41 
42 // Session map
43 typedef std::map<std::string, coral::ISessionProxy*> SessionMap;
44 
45 // Lookup table for global tag contents quick access
46 typedef std::pair<std::string, std::string> TagNameId;
47 typedef std::map<std::string, TagNameId> TagNameIdByNode;
48 typedef std::map<std::string, TagNameIdByNode*> GlobalTagLookupMap; // Key - <Global_Tag_Name>::<Connection>
49 
57 class RDBAccessSvc final : public extends<AthService, IRDBAccessSvc>
58 {
59  public:
61  RDBAccessSvc(const std::string& name, ISvcLocator* svc);
62 
63  StatusCode initialize() override;
64  StatusCode finalize() override;
65 
70  bool connect(const std::string& connName) override;
71 
75  bool disconnect(const std::string& connName) override;
76 
79  bool shutdown(const std::string& connName) override;
80 
87  IRDBRecordset_ptr getRecordsetPtr(const std::string& node
88  , const std::string& tag
89  , const std::string& tag2node=""
90  , const std::string& connName = "ATLASDD") override;
91 
98  std::string getChildTag(const std::string& childNode
99  , const std::string& parentTag
100  , const std::string& parentNode
101  , const std::string& connName) override;
102 
103  std::string getChildTag(const std::string& childNode
104  , const std::string& parentTag
105  , const std::string& parentNode
106  , const std::string& connName
107  , bool force);
108 
109  std::unique_ptr<IRDBQuery> getQuery(const std::string& node
110  , const std::string& tag
111  , const std::string& tag2node
112  , const std::string& connName) override;
113 
114  void getTagDetails(RDBTagDetails& tagDetails
115  , const std::string& tag
116  , const std::string& connName = "ATLASDD") override;
117 
118  void getAllLeafNodes(std::vector<std::string>& list
119  , const std::string& connName = "ATLASDD");
120 
121  std::vector<std::string> getLockedSupportedTags(const std::string& supportedFlag
122  , const std::string& connName = "ATLASDD");
123 
124  coral::ISessionProxy* getSession(const std::string& connName = "ATLASDD");
125 
126 private:
128  std::map<std::string, unsigned int> m_openConnections;
129 
132 
135 
136  bool shutdown_connection(const std::string& connName);
137 };
138 
139 #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:214
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:270
columnar::final
CM final
Definition: ColumnAccessor.h:106
RDBAccessSvc::m_recordsetMutex
std::mutex m_recordsetMutex
Definition: RDBAccessSvc.h:133
RDBAccessSvc::getLockedSupportedTags
std::vector< std::string > getLockedSupportedTags(const std::string &supportedFlag, const std::string &connName="ATLASDD")
Definition: RDBAccessSvc.cxx:453
calibdata.force
bool force
Definition: calibdata.py:19
RecordsetPtrMap
std::map< std::string, IRDBRecordset_ptr > RecordsetPtrMap
Definition: RDBAccessSvc.h:33
RDBAccessSvc::getSession
coral::ISessionProxy * getSession(const std::string &connName="ATLASDD")
Definition: RDBAccessSvc.cxx:495
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
RDBAccessSvc::initialize
StatusCode initialize() override
Definition: RDBAccessSvc.cxx:501
SvcFactory
Definition: AthCnvSvc.h:28
RDBAccessSvc::connect
bool connect(const std::string &connName) override
Connect to the relational DB.
Definition: RDBAccessSvc.cxx:41
RDBAccessSvc::finalize
StatusCode finalize() override
Definition: RDBAccessSvc.cxx:506
TagNameIdByNode
std::map< std::string, TagNameId > TagNameIdByNode
Definition: RDBAccessSvc.h:47
coral
Definition: ISecondaryEventSelector.h:19
SessionMap
std::map< std::string, coral::ISessionProxy * > SessionMap
Definition: RDBAccessSvc.h:43
IRDBAccessSvc.h
Definition of the abstract IRDBAccessSvc interface.
RDBAccessSvc
RDBAccessSvc is the implementation of IRDBAccessSvc interface.
Definition: RDBAccessSvc.h:58
RDBAccessSvc::RDBAccessSvc
RDBAccessSvc(const std::string &name, ISvcLocator *svc)
Standard Service Constructor.
Definition: RDBAccessSvc.cxx:36
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
RDBAccessSvc::m_globalTagLookup
GlobalTagLookupMap m_globalTagLookup
Definition: RDBAccessSvc.h:131
RecordsetPtrsByConn
std::map< std::string, RecordsetPtrMap > RecordsetPtrsByConn
Definition: RDBAccessSvc.h:40
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:149
RDBAccessSvc::shutdown
bool shutdown(const std::string &connName) override
Closes the connection regardless of the counter value.
Definition: RDBAccessSvc.cxx:109
RDBAccessSvc::m_sessionMutex
std::mutex m_sessionMutex
Definition: RDBAccessSvc.h:134
RDBAccessSvc::m_sessions
SessionMap m_sessions
Definition: RDBAccessSvc.h:127
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:130
IRDBRecordset_ptr
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition: IRDBAccessSvc.h:25
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
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:48
RDBAccessSvc::shutdown_connection
bool shutdown_connection(const std::string &connName)
Definition: RDBAccessSvc.cxx:126
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
RDBAccessSvc::m_openConnections
std::map< std::string, unsigned int > m_openConnections
Definition: RDBAccessSvc.h:128
RDBAccessSvc::getTagDetails
void getTagDetails(RDBTagDetails &tagDetails, const std::string &tag, const std::string &connName="ATLASDD") override
Definition: RDBAccessSvc.cxx:336
RDBAccessSvc::getAllLeafNodes
void getAllLeafNodes(std::vector< std::string > &list, const std::string &connName="ATLASDD")
Definition: RDBAccessSvc.cxx:414
node
Definition: node.h:21
TagNameId
std::pair< std::string, std::string > TagNameId
Definition: RDBAccessSvc.h:46
RDBAccessSvc::disconnect
bool disconnect(const std::string &connName) override
If the counnection counter==1 closes the connection.
Definition: RDBAccessSvc.cxx:81
RDBRecordset
RDBRecordset is an implementation of IRDBRecordset interface.
Definition: RDBRecordset.h:39