ATLAS Offline Software
Loading...
Searching...
No Matches
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
13
14#ifndef RDBACCESSSVC_RDBACCESSSVC_H
15#define RDBACCESSSVC_RDBACCESSSVC_H
16
18#include "RDBRecordset.h"
19
21
22#include <string>
23#include <string_view>
24#include <map>
25
26class ISvcLocator;
27class RDBRecordset;
28
29namespace coral
30{
31 class ISessionProxy;
32}
33
34template <class TYPE> class SvcFactory;
35
36
37// Recordsets of single connection
38typedef std::map<std::string, IRDBRecordset_ptr, std::less<>> RecordsetPtrMap;
39
40// Pointers to recordset maps by connection name
41typedef std::map<std::string, RecordsetPtrMap, std::less<>> RecordsetPtrsByConn;
42
43// Session map
44typedef std::map<std::string, coral::ISessionProxy*, std::less<>> SessionMap;
45
46// Lookup table for global tag contents quick access
47typedef std::pair<std::string, std::string> TagNameId;
48typedef std::map<std::string, TagNameId, std::less<>> TagNameIdByNode;
49typedef std::map<std::string, TagNameIdByNode*, std::less<>> GlobalTagLookupMap; // Key - <Global_Tag_Name>::<Connection>
50
57
58class RDBAccessSvc final : public extends<AthService, IRDBAccessSvc>
59{
60 public:
62 RDBAccessSvc(const std::string& name, ISvcLocator* svc);
63
64 StatusCode initialize() override;
65 StatusCode finalize() override;
66
71 bool connect(std::string_view connName) override;
72
76 bool disconnect(std::string_view connName) override;
77
80 bool shutdown(std::string_view connName) override;
81
89 , std::string_view tag
90 , std::string_view tag2node=""
91 , std::string_view connName = "ATLASDD") override;
92
99 std::string getChildTag(const std::string& childNode
100 , const std::string& parentTag
101 , const std::string& parentNode
102 , const std::string& connName) override;
103
104 std::string getChildTag(const std::string& childNode
105 , const std::string& parentTag
106 , const std::string& parentNode
107 , const std::string& connName
108 , bool force);
109
110 std::unique_ptr<IRDBQuery> getQuery(const std::string& node
111 , const std::string& tag
112 , const std::string& tag2node
113 , const std::string& connName) override;
114
115 void getTagDetails(RDBTagDetails& tagDetails
116 , const std::string& tag
117 , const std::string& connName = "ATLASDD") override;
118
119 void getAllLeafNodes(std::vector<std::string>& list
120 , const std::string& connName = "ATLASDD");
121
122 std::vector<std::string> getLockedSupportedTags(const std::string& supportedFlag
123 , const std::string& connName = "ATLASDD");
124
125 coral::ISessionProxy* getSession(const std::string& connName = "ATLASDD");
126
127private:
129 std::map<std::string, unsigned int, std::less<>> m_openConnections;
130
133
135 std::mutex m_sessionMutex;
136
137 bool shutdown_connection(std::string_view connName);
138};
139
140#endif
Definition of the abstract IRDBAccessSvc interface.
coral::AttributeList RDBTagDetails
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
std::map< std::string, IRDBRecordset_ptr, std::less<> > RecordsetPtrMap
std::pair< std::string, std::string > TagNameId
std::map< std::string, TagNameIdByNode *, std::less<> > GlobalTagLookupMap
std::map< std::string, RecordsetPtrMap, std::less<> > RecordsetPtrsByConn
std::map< std::string, TagNameId, std::less<> > TagNameIdByNode
std::map< std::string, coral::ISessionProxy *, std::less<> > SessionMap
Definition of RDBRecordset class.
bool disconnect(std::string_view connName) override
If the counnection counter==1 closes the connection.
std::vector< std::string > getLockedSupportedTags(const std::string &supportedFlag, const std::string &connName="ATLASDD")
bool shutdown_connection(std::string_view connName)
std::map< std::string, unsigned int, std::less<> > m_openConnections
bool shutdown(std::string_view connName) override
Closes the connection regardless of the counter value.
std::mutex m_sessionMutex
SessionMap m_sessions
StatusCode finalize() override
bool connect(std::string_view connName) override
Connect to the relational DB.
RecordsetPtrsByConn m_recordsetptrs
GlobalTagLookupMap m_globalTagLookup
RDBAccessSvc(const std::string &name, ISvcLocator *svc)
Standard Service Constructor.
void getAllLeafNodes(std::vector< std::string > &list, const std::string &connName="ATLASDD")
void getTagDetails(RDBTagDetails &tagDetails, const std::string &tag, const std::string &connName="ATLASDD") override
std::mutex m_recordsetMutex
StatusCode initialize() override
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.
std::unique_ptr< IRDBQuery > getQuery(const std::string &node, const std::string &tag, const std::string &tag2node, const std::string &connName) override
coral::ISessionProxy * getSession(const std::string &connName="ATLASDD")
IRDBRecordset_ptr getRecordsetPtr(std::string_view node, std::string_view tag, std::string_view tag2node="", std::string_view connName="ATLASDD") override
Provides access to the Recordset object containing HVS-tagged data.
RDBRecordset is an implementation of IRDBRecordset interface.
Definition node.h:24