ATLAS Offline Software
Loading...
Searching...
No Matches
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"
34
35class CoraCoolFolder;
36
38 public:
39 // constructor - do not use this directly but create iterators using
40 // CoraCoolFolder::browseObject(..)
41 CoraCoolObjectIter(CoraCoolFolder* coracoolfolder, cool::IObjectIteratorPtr coolptr);
43
44 // get the next object - call hasNext() first to check there is one
45 // throws CoraCoolException if there is none
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
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
66
67 // implementation class to build queries
69 public:
70 // setup query builder with specified number size of range pairs
71 QueryBuilder(const unsigned int size);
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
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
112 cool::IObjectIteratorPtr m_coolitr;
113 coral::AttributeListSpecification* m_spec;
114 std::vector<CoraCoolObjectPtr> m_data;
115};
116
117inline unsigned int CoraCoolObjectIter::QueryBuilder::size() const
118{ return m_size; }
119inline unsigned int CoraCoolObjectIter::QueryBuilder::terms() const
120{ return m_terms; }
121
122#endif // CORACOOL_CORACOOLOBJECTITER_H
123
boost::shared_ptr< CoraCoolObject > CoraCoolObjectPtr
static Double_t a
QueryBuilder(const unsigned int size)
QueryBuilder & operator=(const QueryBuilder &)
std::string addKey(unsigned int &key, coral::AttributeList &fkeys, const coral::AttributeSpecification &spec, const long long value)
unsigned int add(const long long value)
QueryBuilder(const QueryBuilder &)
void getQuery(std::string &where, const std::string &coralkey, coral::AttributeList &fkeys, const coral::AttributeSpecification &spec)
CoraCoolObjectPtr next()
cool::IObjectIteratorPtr m_coolitr
bool isNumAttr(const std::string &spec) const
long long numAttr(const std::string &spec, const coral::Attribute &a) const
CoraCoolObjectIter(const CoraCoolObjectIter &)
bool equalAttr(const coral::Attribute &a1, const coral::Attribute &a2) const
coral::AttributeListSpecification * m_spec
CoraCoolObjectIter(CoraCoolFolder *coracoolfolder, cool::IObjectIteratorPtr coolptr)
std::vector< CoraCoolObjectPtr > m_data
CoraCoolObjectIter & operator=(const CoraCoolObjectIter &)
CoraCoolFolder * m_folder
CoraCoolObject & currentRef()