ATLAS Offline Software
Loading...
Searching...
No Matches
RDBRecord.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
14
15#ifndef RDBACCESSSVC_RDBRECORD_H
16#define RDBACCESSSVC_RDBRECORD_H
17
18#include "CoralBase/AttributeList.h"
21#include <map>
22#include <string>
23#include <string_view>
24#include <iosfwd>
25
26namespace coral
27{
28 class ICursor;
29}
30
36class RDBRecord final : public IRDBRecord
37{
38 friend class RDBRecordset;
39
40 public:
41
42 RDBRecord (const RDBRecord&) = delete;
43 RDBRecord& operator= (const RDBRecord&) = delete;
44
46 ~RDBRecord() override;
47
51 bool isFieldNull(std::string_view fieldName) const override;
52
56 int getInt(std::string_view fieldName) const override;
57
61 long getLong(std::string_view fieldName) const override;
62
66 double getDouble(std::string_view fieldName) const override;
67
71 float getFloat(std::string_view fieldName) const override;
72
76 virtual const std::string& getString(std::string_view string_view) const override;
77
78 // Access array values by index
79 // arrays are implemented using the field with names like NAME_0, NAME_1 etc.
80
85 int getInt(std::string_view fieldName, unsigned int index) const override;
86
91 long getLong(std::string_view fieldName, unsigned int index) const override;
92
97 double getDouble(std::string_view fieldName, unsigned int index) const override;
98
103 float getFloat(std::string_view fieldName, unsigned int index) const override;
104
109 virtual const std::string& getString(std::string_view fieldName, unsigned int index) const override;
110
111 // Comparison operator
112 bool operator!=(const RDBRecord& rhs) const;
113
114 // Dump record to output stream
115 std::ostream& toOutputStream(std::ostream& os) const;
116
117 protected:
122 RDBRecord(const coral::AttributeList& attList, const std::string& tableName);
123
124 private:
125 typedef std::map<std::string, unsigned int, std::less<>> FieldName2ListIndex;
126
129
131 coral::AttributeList* m_values ATLAS_THREAD_SAFE;
132
133 std::string m_tableName;
134
135 template<typename T>
136 const T& getGeneric(std::string_view fieldName) const;
137 FieldName2ListIndex::const_iterator getItr(std::string_view fieldName) const;
138 FieldName2ListIndex::const_iterator getItr(std::string_view fieldName, int) const;
139
140};
141
142inline std::ostream& operator << (std::ostream& os, const RDBRecord& x)
143{
144 x.toOutputStream(os);
145 return os;
146}
147
148
149#endif
150
Definition of the abstract IRDBRecord interface.
std::ostream & operator<<(std::ostream &os, const RDBRecord &x)
Definition RDBRecord.h:142
#define x
Define macros for attributes used to control the static checker.
IRDBRecord is one record in the IRDBRecordset object.
Definition IRDBRecord.h:28
RDBRecord is one record in the RDBRecordset object.
Definition RDBRecord.h:37
long getLong(std::string_view fieldName) const override
Get long field value.
bool operator!=(const RDBRecord &rhs) const
RDBRecord(const RDBRecord &)=delete
std::map< std::string, unsigned int, std::less<> > FieldName2ListIndex
Definition RDBRecord.h:125
RDBRecord & operator=(const RDBRecord &)=delete
int getInt(std::string_view fieldName) const override
Get int field value.
Definition RDBRecord.cxx:93
float getFloat(std::string_view fieldName) const override
Get float field value.
const T & getGeneric(std::string_view fieldName) const
Definition RDBRecord.cxx:47
std::ostream & toOutputStream(std::ostream &os) const
friend class RDBRecordset
Definition RDBRecord.h:38
RDBRecord()
Empty private constructor.
Definition RDBRecord.h:128
~RDBRecord() override
Destructor.
Definition RDBRecord.cxx:41
coral::AttributeList *m_values ATLAS_THREAD_SAFE
Definition RDBRecord.h:131
virtual const std::string & getString(std::string_view string_view) const override
Get string field value.
std::string m_tableName
Definition RDBRecord.h:133
bool isFieldNull(std::string_view fieldName) const override
Check if the field value is NULL.
Definition RDBRecord.cxx:85
FieldName2ListIndex::const_iterator getItr(std::string_view fieldName) const
Definition RDBRecord.cxx:64
double getDouble(std::string_view fieldName) const override
Get double field value.
FieldName2ListIndex m_name2Index
Definition RDBRecord.h:130
Definition index.py:1