ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Database
CoraCool
CoraCool
CoraCoolObjectIter.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef CORACOOL_CORACOOLOBJECTITER_H
6
#define CORACOOL_CORACOOLOBJECTITER_H
7
// CoraCoolObjectIter.h - allows to iterate over the result of a CoraCool
8
// bulk query from the CoraCoolFolder browseObject method
9
//
10
// usage pattern is the same as for the COOL IObjectIterator, i.e.
11
// CoraCoolObjectIterPtr itr=CoraCoolFolderPtr->browseObjects(..)
12
// while (itr->hasNext()) {
13
// CoraCoolObjectPtr obj=itr->next()
14
// // do something with the object
15
// }
16
// itr->close()
17
//
18
// Richard Hawkings, started 10/2006
19
31
32
#include "CoolKernel/IObjectIterator.h"
33
#include "
CoraCool/CoraCoolTypes.h
"
34
35
class
CoraCoolFolder
;
36
37
class
CoraCoolObjectIter
{
38
public
:
39
// constructor - do not use this directly but create iterators using
40
// CoraCoolFolder::browseObject(..)
41
CoraCoolObjectIter
(
CoraCoolFolder
* coracoolfolder, cool::IObjectIteratorPtr coolptr);
42
~CoraCoolObjectIter
();
43
44
// get the next object - call hasNext() first to check there is one
45
// throws CoraCoolException if there is none
46
CoraCoolObjectPtr
next
();
47
48
// does the iterator have a next object
49
bool
hasNext
();
50
51
// go to next, if the folder has
52
bool
goToNext
();
53
54
// return a reference to the current object
55
CoraCoolObject
&
currentRef
();
56
57
// close the iterator, releasing resources
58
void
close
();
59
60
private
:
61
// hide default and copy constructors, and assignment operator
62
// declared but not implemented
63
CoraCoolObjectIter
();
64
CoraCoolObjectIter
(
const
CoraCoolObjectIter
&);
65
CoraCoolObjectIter
&
operator=
(
const
CoraCoolObjectIter
&);
66
67
// implementation class to build queries
68
class
QueryBuilder
{
69
public
:
70
// setup query builder with specified number size of range pairs
71
QueryBuilder
(
const
unsigned
int
size
);
72
~QueryBuilder
();
73
74
// return current size (num of range pairs) and number of terms in query
75
unsigned
int
size
()
const
;
76
unsigned
int
terms
()
const
;
77
// add a FK value to the query list
78
unsigned
int
add
(
const
long
long
value);
79
// prepare the DB query - return the where clause and the list of foreign
80
// key bind variables, given the coralkey name and FK attribute spec
81
void
getQuery
(std::string& where,
const
std::string& coralkey,
82
coral::AttributeList& fkeys,
const
coral::AttributeSpecification& spec);
83
84
private
:
85
// hide default and copy constructors, and assignment operator
86
QueryBuilder
();
87
QueryBuilder
(
const
QueryBuilder
&);
88
QueryBuilder
&
operator=
(
const
QueryBuilder
&);
89
90
std::string
addKey
(
unsigned
int
& key,
91
coral::AttributeList& fkeys,
92
const
coral::AttributeSpecification& spec,
93
const
long
long
value);
94
unsigned
int
m_terms
;
95
unsigned
int
m_size
;
// number of ranges stored
96
unsigned
int
m_maxsize
;
// max size of the array
97
long
long
*
m_lower
;
// array of lower and upper bounds for ranges
98
long
long
*
m_upper
;
// assumed to be store in ascending numerical order
99
};
100
void
readDataToBuffer
();
101
bool
iHasNext
();
102
bool
equalAttr
(
const
coral::Attribute& a1,
const
coral::Attribute& a2)
const
;
103
bool
isNumAttr
(
const
std::string& spec)
const
;
104
long
long
numAttr
(
const
std::string& spec,
const
coral::Attribute&
a
)
const
;
105
106
unsigned
int
m_buflen
;
// size of the buffer for payload data
107
unsigned
int
m_inbuf
;
// number of objects in the buffer
108
unsigned
int
m_nextobj
;
// pointer to next object
109
bool
m_refValid
;
// COOL iterator contains valid reference
110
bool
m_allDone
;
// COOL iterator is exhausted
111
CoraCoolFolder
*
m_folder
;
112
cool::IObjectIteratorPtr
m_coolitr
;
113
coral::AttributeListSpecification*
m_spec
;
114
std::vector<CoraCoolObjectPtr>
m_data
;
115
};
116
117
inline
unsigned
int
CoraCoolObjectIter::QueryBuilder::size
()
const
118
{
return
m_size
; }
119
inline
unsigned
int
CoraCoolObjectIter::QueryBuilder::terms
()
const
120
{
return
m_terms
; }
121
122
#endif
// CORACOOL_CORACOOLOBJECTITER_H
123
CoraCoolTypes.h
CoraCoolObjectPtr
boost::shared_ptr< CoraCoolObject > CoraCoolObjectPtr
Definition
CoraCoolTypes.h:19
a
static Double_t a
Definition
LArPhysWaveHECTool.cxx:38
CoraCoolFolder
Definition
CoraCoolFolder.h:37
CoraCoolObjectIter::QueryBuilder::m_size
unsigned int m_size
Definition
CoraCoolObjectIter.h:95
CoraCoolObjectIter::QueryBuilder::QueryBuilder
QueryBuilder(const unsigned int size)
Definition
CoraCoolObjectIter.cxx:250
CoraCoolObjectIter::QueryBuilder::size
unsigned int size() const
Definition
CoraCoolObjectIter.h:117
CoraCoolObjectIter::QueryBuilder::operator=
QueryBuilder & operator=(const QueryBuilder &)
CoraCoolObjectIter::QueryBuilder::QueryBuilder
QueryBuilder()
CoraCoolObjectIter::QueryBuilder::m_maxsize
unsigned int m_maxsize
Definition
CoraCoolObjectIter.h:96
CoraCoolObjectIter::QueryBuilder::m_lower
long long * m_lower
Definition
CoraCoolObjectIter.h:97
CoraCoolObjectIter::QueryBuilder::~QueryBuilder
~QueryBuilder()
Definition
CoraCoolObjectIter.cxx:256
CoraCoolObjectIter::QueryBuilder::terms
unsigned int terms() const
Definition
CoraCoolObjectIter.h:119
CoraCoolObjectIter::QueryBuilder::m_upper
long long * m_upper
Definition
CoraCoolObjectIter.h:98
CoraCoolObjectIter::QueryBuilder::addKey
std::string addKey(unsigned int &key, coral::AttributeList &fkeys, const coral::AttributeSpecification &spec, const long long value)
Definition
CoraCoolObjectIter.cxx:353
CoraCoolObjectIter::QueryBuilder::add
unsigned int add(const long long value)
Definition
CoraCoolObjectIter.cxx:261
CoraCoolObjectIter::QueryBuilder::m_terms
unsigned int m_terms
Definition
CoraCoolObjectIter.h:94
CoraCoolObjectIter::QueryBuilder::QueryBuilder
QueryBuilder(const QueryBuilder &)
CoraCoolObjectIter::QueryBuilder::getQuery
void getQuery(std::string &where, const std::string &coralkey, coral::AttributeList &fkeys, const coral::AttributeSpecification &spec)
Definition
CoraCoolObjectIter.cxx:302
CoraCoolObjectIter::next
CoraCoolObjectPtr next()
Definition
CoraCoolObjectIter.cxx:53
CoraCoolObjectIter::m_coolitr
cool::IObjectIteratorPtr m_coolitr
Definition
CoraCoolObjectIter.h:112
CoraCoolObjectIter::isNumAttr
bool isNumAttr(const std::string &spec) const
Definition
CoraCoolObjectIter.cxx:225
CoraCoolObjectIter::close
void close()
Definition
CoraCoolObjectIter.cxx:182
CoraCoolObjectIter::numAttr
long long numAttr(const std::string &spec, const coral::Attribute &a) const
Definition
CoraCoolObjectIter.cxx:231
CoraCoolObjectIter::goToNext
bool goToNext()
Definition
CoraCoolObjectIter.cxx:166
CoraCoolObjectIter::CoraCoolObjectIter
CoraCoolObjectIter(const CoraCoolObjectIter &)
CoraCoolObjectIter::m_buflen
unsigned int m_buflen
Definition
CoraCoolObjectIter.h:106
CoraCoolObjectIter::equalAttr
bool equalAttr(const coral::Attribute &a1, const coral::Attribute &a2) const
Definition
CoraCoolObjectIter.cxx:190
CoraCoolObjectIter::m_refValid
bool m_refValid
Definition
CoraCoolObjectIter.h:109
CoraCoolObjectIter::m_spec
coral::AttributeListSpecification * m_spec
Definition
CoraCoolObjectIter.h:113
CoraCoolObjectIter::CoraCoolObjectIter
CoraCoolObjectIter(CoraCoolFolder *coracoolfolder, cool::IObjectIteratorPtr coolptr)
Definition
CoraCoolObjectIter.cxx:32
CoraCoolObjectIter::hasNext
bool hasNext()
Definition
CoraCoolObjectIter.cxx:162
CoraCoolObjectIter::m_nextobj
unsigned int m_nextobj
Definition
CoraCoolObjectIter.h:108
CoraCoolObjectIter::m_data
std::vector< CoraCoolObjectPtr > m_data
Definition
CoraCoolObjectIter.h:114
CoraCoolObjectIter::CoraCoolObjectIter
CoraCoolObjectIter()
CoraCoolObjectIter::~CoraCoolObjectIter
~CoraCoolObjectIter()
Definition
CoraCoolObjectIter.cxx:49
CoraCoolObjectIter::operator=
CoraCoolObjectIter & operator=(const CoraCoolObjectIter &)
CoraCoolObjectIter::m_folder
CoraCoolFolder * m_folder
Definition
CoraCoolObjectIter.h:111
CoraCoolObjectIter::iHasNext
bool iHasNext()
Definition
CoraCoolObjectIter.cxx:210
CoraCoolObjectIter::currentRef
CoraCoolObject & currentRef()
Definition
CoraCoolObjectIter.cxx:178
CoraCoolObjectIter::m_inbuf
unsigned int m_inbuf
Definition
CoraCoolObjectIter.h:107
CoraCoolObjectIter::m_allDone
bool m_allDone
Definition
CoraCoolObjectIter.h:110
CoraCoolObjectIter::readDataToBuffer
void readDataToBuffer()
Definition
CoraCoolObjectIter.cxx:66
CoraCoolObject
Definition
CoraCoolObject.h:20
Generated on
for ATLAS Offline Software by
1.17.0