RDBRecord is one record in the RDBRecordset object.
More...
#include <RDBRecord.h>
|
| | RDBRecord (const RDBRecord &)=delete |
| RDBRecord & | operator= (const RDBRecord &)=delete |
| | ~RDBRecord () override |
| | Destructor.
|
| bool | isFieldNull (const std::string &fieldName) const override |
| | Check if the field value is NULL.
|
| int | getInt (const std::string &fieldName) const override |
| | Get int field value.
|
| long | getLong (const std::string &fieldName) const override |
| | Get long field value.
|
| double | getDouble (const std::string &fieldName) const override |
| | Get double field value.
|
| float | getFloat (const std::string &fieldName) const override |
| | Get float field value.
|
| virtual const std::string & | getString (const std::string &fieldName) const override |
| | Get string field value.
|
| int | getInt (const std::string &fieldName, unsigned int index) const override |
| | Get array int field value.
|
| long | getLong (const std::string &fieldName, unsigned int index) const override |
| | Get array long field value.
|
| double | getDouble (const std::string &fieldName, unsigned int index) const override |
| | Get array double field value.
|
| float | getFloat (const std::string &fieldName, unsigned int index) const override |
| | Get array float field value.
|
| virtual const std::string & | getString (const std::string &fieldName, unsigned int index) const override |
| | Get array string field value.
|
| bool | operator!= (const RDBRecord &rhs) const |
| std::ostream & | toOutputStream (std::ostream &os) const |
|
| | RDBRecord (const coral::AttributeList &attList, const std::string &tableName) |
| | Constructor used by RDBRecordset class.
|
RDBRecord is one record in the RDBRecordset object.
Definition at line 34 of file RDBRecord.h.
◆ FieldName2ListIndex
◆ RDBRecord() [1/3]
◆ ~RDBRecord()
| RDBRecord::~RDBRecord |
( |
| ) |
|
|
override |
Destructor.
Definition at line 42 of file RDBRecord.cxx.
43{
44 delete m_values;
45}
◆ RDBRecord() [2/3]
| RDBRecord::RDBRecord |
( |
const coral::AttributeList & | attList, |
|
|
const std::string & | tableName ) |
|
protected |
Constructor used by RDBRecordset class.
- Parameters
-
| attList | [IN] pointer to the attribute list, source of the Record object |
| cursor | [IN] need to check if the field values are NULL |
| tableName | [IN] data table name in the database |
Definition at line 27 of file RDBRecord.cxx.
29 : m_values(0)
31{
32
33 m_values = new coral::AttributeList(attList.specification(), false);
34 m_values->fastCopyData (attList);
35
36 for(
unsigned int i=0;
i<m_values->size();
i++) {
37 std::string
key = (*m_values)[
i].specification().name();
39 }
40}
FieldName2ListIndex m_name2Index
◆ RDBRecord() [3/3]
Empty private constructor.
Definition at line 126 of file RDBRecord.h.
◆ getDouble() [1/2]
| double RDBRecord::getDouble |
( |
const std::string & | fieldName | ) |
const |
|
overridevirtual |
Get double field value.
- Parameters
-
- Returns
- field value
Implements IRDBRecord.
Definition at line 99 of file RDBRecord.cxx.
100{
103 throw std::runtime_error(
"Wrong name for the field " +
m_tableName+
"."+fieldName);
104 }
105
106 const coral::AttributeList&
values = *m_values;
107 if(values[
it->second].specification().type()==
typeid(
double)) {
108 return values[
it->second].data<
double>();
109 }
110 else {
111 throw std::runtime_error( "Field " + fieldName + " is NOT of double type");
112 }
113}
◆ getDouble() [2/2]
| double RDBRecord::getDouble |
( |
const std::string & | fieldName, |
|
|
unsigned int | index ) const |
|
overridevirtual |
Get array double field value.
- Parameters
-
| fieldName | [IN] field name |
| index | [IN] index in the array |
- Returns
- field value
Implements IRDBRecord.
Definition at line 185 of file RDBRecord.cxx.
186{
189 throw std::runtime_error(
"Wrong name for the array field " +
m_tableName+
"."+fieldName +
" or index=" + std::to_string(index) +
" is out of range");
190 }
191
192 const coral::AttributeList&
values = *m_values;
193 if(values[
it->second].specification().type()==
typeid(
double)) {
194 return values[
it->second].data<
double>();
195 }
196 else {
197 throw std::runtime_error( "Field " + fieldName + " is NOT of double type");
198 }
199}
◆ getFloat() [1/2]
| float RDBRecord::getFloat |
( |
const std::string & | fieldName | ) |
const |
|
overridevirtual |
Get float field value.
- Parameters
-
- Returns
- field value
Implements IRDBRecord.
Definition at line 115 of file RDBRecord.cxx.
116{
119 throw std::runtime_error(
"Wrong name for the field " +
m_tableName+
"."+fieldName);
120 }
121
122 const coral::AttributeList&
values = *m_values;
123 if(values[
it->second].specification().type()==
typeid(
float)) {
124 return values[
it->second].data<
float>();
125 }
126 else {
127 throw std::runtime_error( "Field " + fieldName + " is NOT of float type");
128 }
129}
◆ getFloat() [2/2]
| float RDBRecord::getFloat |
( |
const std::string & | fieldName, |
|
|
unsigned int | index ) const |
|
overridevirtual |
Get array float field value.
- Parameters
-
| fieldName | [IN] field name |
| index | [IN] index in the array |
- Returns
- field value
Implements IRDBRecord.
Definition at line 201 of file RDBRecord.cxx.
202{
205 throw std::runtime_error(
"Wrong name for the array field " +
m_tableName+
"."+fieldName +
" or index=" + std::to_string(index) +
" is out of range");
206 }
207
208 const coral::AttributeList&
values = *m_values;
209 if(values[
it->second].specification().type()==
typeid(
float)) {
210 return values[
it->second].data<
float>();
211 }
212 else {
213 throw std::runtime_error( "Field " + fieldName + " is NOT of float type");
214 }
215}
◆ getInt() [1/2]
| int RDBRecord::getInt |
( |
const std::string & | fieldName | ) |
const |
|
overridevirtual |
Get int field value.
- Parameters
-
- Returns
- field value
Implements IRDBRecord.
Definition at line 58 of file RDBRecord.cxx.
59{
62 throw std::runtime_error(
"Wrong name for the field " +
m_tableName+
"."+fieldName);
63 }
64
65 const coral::AttributeList&
values = *m_values;
66 if(values[
it->second].specification().type()==
typeid(
int)) {
67 return values[
it->second].data<
int>();
68 }
69 else if(values[
it->second].specification().type()==
typeid(
long)) {
70 return (
int)
values[
it->second].data<
long>();
71 }
72 else {
73 throw std::runtime_error( "Field " + fieldName + " is NOT of integer type\n");
74 }
75}
◆ getInt() [2/2]
| int RDBRecord::getInt |
( |
const std::string & | fieldName, |
|
|
unsigned int | index ) const |
|
overridevirtual |
Get array int field value.
- Parameters
-
| fieldName | [IN] field name |
| index | [IN] index in the array |
- Returns
- field value
Implements IRDBRecord.
Definition at line 147 of file RDBRecord.cxx.
148{
151 throw std::runtime_error(
"Wrong name for the array field " +
m_tableName+
"."+fieldName +
" or index=" + std::to_string(index) +
" is out of range");
152 }
153
154 const coral::AttributeList&
values = *m_values;
155 if(values[
it->second].specification().type()==
typeid(
int)) {
156 return values[
it->second].data<
int>();
157 }
158 else if(values[
it->second].specification().type()==
typeid(
long)) {
159 return (
int)
values[
it->second].data<
long>();
160 }
161 else {
162 throw std::runtime_error( "Field " + fieldName + " is NOT of integer type\n");
163 }
164}
◆ getLong() [1/2]
| long RDBRecord::getLong |
( |
const std::string & | fieldName | ) |
const |
|
overridevirtual |
Get long field value.
- Parameters
-
- Returns
- field value
Implements IRDBRecord.
Definition at line 77 of file RDBRecord.cxx.
78{
81 throw std::runtime_error(
"Wrong name for the field " +
m_tableName+
"."+fieldName);
82 }
83
84 const coral::AttributeList&
values = *m_values;
85 if(values[
it->second].specification().type()==
typeid(
long)) {
86 return values[
it->second].data<
long>();
87 }
88 else if(values[
it->second].specification().type()==
typeid(
int)) {
89 return (
long)
values[
it->second].data<
int>();
90 }
91 else if(values[
it->second].specification().type()==
typeid(
long long)) {
92 return (
long)
values[
it->second].data<
long long>();
93 }
94 else {
95 throw std::runtime_error( "Field " + fieldName + " is NOT of long type");
96 }
97}
◆ getLong() [2/2]
| long RDBRecord::getLong |
( |
const std::string & | fieldName, |
|
|
unsigned int | index ) const |
|
overridevirtual |
Get array long field value.
- Parameters
-
| fieldName | [IN] field name |
| index | [IN] index in the array |
- Returns
- field value
Implements IRDBRecord.
Definition at line 166 of file RDBRecord.cxx.
167{
170 throw std::runtime_error(
"Wrong name for the array field " +
m_tableName+
"."+fieldName +
" or index=" + std::to_string(index) +
" is out of range");
171 }
172
173 const coral::AttributeList&
values = *m_values;
174 if(values[
it->second].specification().type()==
typeid(
long)) {
175 return values[
it->second].data<
long>();
176 }
177 else if(values[
it->second].specification().type()==
typeid(
int)) {
178 return (
long)
values[
it->second].data<
int>();
179 }
180 else {
181 throw std::runtime_error( "Field " + fieldName + " is NOT of long type");
182 }
183}
◆ getString() [1/2]
| const std::string & RDBRecord::getString |
( |
const std::string & | fieldName | ) |
const |
|
overridevirtual |
Get string field value.
- Parameters
-
- Returns
- field value
Implements IRDBRecord.
Definition at line 131 of file RDBRecord.cxx.
132{
135 throw std::runtime_error(
"Wrong name for the field " +
m_tableName+
"."+fieldName);
136 }
137
138 const coral::AttributeList&
values = *m_values;
139 if(values[
it->second].specification().type()==
typeid(std::string)) {
140 return values[
it->second].data<std::string>();
141 }
142 else {
143 throw std::runtime_error( "Field " + fieldName + " is NOT of string type");
144 }
145}
◆ getString() [2/2]
| const std::string & RDBRecord::getString |
( |
const std::string & | fieldName, |
|
|
unsigned int | index ) const |
|
overridevirtual |
Get array string field value.
- Parameters
-
| fieldName | [IN] field name |
| index | [IN] index in the array |
- Returns
- field value
Implements IRDBRecord.
Definition at line 217 of file RDBRecord.cxx.
218{
221 throw std::runtime_error(
"Wrong name for the array field " +
m_tableName+
"."+fieldName +
" or index=" + std::to_string(index) +
" is out of range");
222 }
223
224 const coral::AttributeList&
values = *m_values;
225 if(values[
it->second].specification().type()==
typeid(std::string)) {
226 return values[
it->second].data<std::string>();
227 }
228 else {
229 throw std::runtime_error( "Field " + fieldName + " is NOT of string type");
230 }
231}
◆ isFieldNull()
| bool RDBRecord::isFieldNull |
( |
const std::string & | fieldName | ) |
const |
|
overridevirtual |
Check if the field value is NULL.
- Parameters
-
| fieldName | [IN] field name @retun TRUE if the field is NULL, FALSE otherwise |
Implements IRDBRecord.
Definition at line 47 of file RDBRecord.cxx.
48{
51 throw std::runtime_error(
"Wrong name for the field " +
m_tableName+
"."+fieldName);
52 }
53
54 const coral::AttributeList&
values = *m_values;
56}
◆ operator!=()
| bool RDBRecord::operator!= |
( |
const RDBRecord & | rhs | ) |
const |
Definition at line 233 of file RDBRecord.cxx.
234{
235 const coral::AttributeList& myAttList = *m_values;
236 const coral::AttributeList& rhsAttList = *rhs.m_values;
237
238 if(myAttList.size()!=rhsAttList.size()) return true;
239
240 for(
size_t i(0);
i<myAttList.size(); ++
i) {
241 const coral::Attribute& myAtt = myAttList[
i];
242 const std::string
name = myAtt.specification().name();
244 for(size_t j(0); j<rhsAttList.size(); ++j) {
245 const coral::Attribute& rhsAtt = rhsAttList[j];
246 if(rhsAtt.specification().name()==name) {
247 if(myAtt!=rhsAtt) {
248 return true;
249 }
251 break;
252 }
253 }
255 return true;
256 }
257 return false;
258}
bool exists(const std::string &filename)
does a file exist
◆ operator=()
◆ toOutputStream()
| std::ostream & RDBRecord::toOutputStream |
( |
std::ostream & | os | ) |
const |
Definition at line 260 of file RDBRecord.cxx.
261{
262 m_values->toOutputStream(os);
264}
◆ RDBRecordset
◆ ATLAS_THREAD_SAFE
| coral::AttributeList* m_values RDBRecord::ATLAS_THREAD_SAFE |
|
private |
◆ m_name2Index
◆ m_tableName
| std::string RDBRecord::m_tableName |
|
private |
The documentation for this class was generated from the following files: