ImplicitCollectionIterator.h 3.78 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/

#ifndef IMPLICITCOLLECTION_COLLECTIONITERATOR_H
#define IMPLICITCOLLECTION_COLLECTIONITERATOR_H

//#include "CollectionBase/ICollectionDescription.h"
#include "CollectionBase/ICollectionQuery.h"
#include "CollectionBase/ICollectionCursor.h"

#include "CollectionBase/CollectionRowBuffer.h"

#include "PersistencySvc/IPositionSeek.h"
#include "AthenaKernel/ICollectionSize.h"

class Token;

namespace coral { class AttributeList; }

namespace pool {

   // forward declarations
   class IContainer;
   class ITokenIterator;
   class TokenList;
   class ICollectionDescription;
   
   /** 
    * @class ImplicitCollectionIterator ImplicitCollectionIterator.h Implicitcollection/ImplicitCollectionIterator.h
    *
    * Iterator over an implicit collection.
    * Single class implementing both Query and Cursor interfaces
    * to simplify backward compatibility
    */
   class ImplicitCollectionIterator : public ICollectionQuery,
                                      public ICollectionCursor,
                                      virtual public IPositionSeek,
                                      virtual public ICollectionSize
   {
  public:
     /// Constructor
     ImplicitCollectionIterator(IContainer& container,
                                const pool::ICollectionDescription& description );

     // ------------------- Query interface
     
     /**
      * Sets the query.
      * @param whereClause The query.
      * @param attributeBindData  - unused
      * @param tokenBindData  - unused
      */
     virtual void setCondition( const std::string& whereClause,
                                coral::AttributeList* attributeBindData = 0,
                                TokenList* tokenBindData = 0 ) ;

     /// Returns the where clause of the query.
     virtual const std::string& whereClause() const;

     /// Processes the query and returns a cursor over the query result.
     /// this method returns self
     virtual pool::ICollectionCursor& execute();


     // ------------------- Cursor interface 

     /** Retrieves the next token in the collection.
         Returns false if the end of the collection has been reached.
     */
     virtual bool                         next();

     /// Returns the token of the current position
     virtual Token*                         token() const;
     virtual const Token&                 eventRef() const { return *token(); }

     virtual const CollectionRowBuffer& currentRow() const;

     // ------------------- Seek interface 
     /**
      * @brief Seek to a given position in the collection
      * @param position  The position to which to seek.
      * @returns True if successful, false otherwise.
      */
     virtual bool seek (long long int position);

     /**
      * @brief Return the size of the collection.
      */
     virtual int size ();

     
     //------------------------------------------

     /// Destructor
     virtual ~ImplicitCollectionIterator();


     // ------------------- Unimplemented methods

     virtual void addToOutputList( const std::string& ) {}
     virtual void addToOutputList( const std::vector<std::string>& ) {}
     virtual void selectAllAttributes() {}
     virtual void selectAllTokens() {}
     virtual void selectAll() {}
     virtual void addToCollectionFragmentList( const std::string& ) {}
     virtual void addToCollectionFragmentList( const std::vector< std::string >& ) {}
     virtual void addAllCollectionFragments() {}
     virtual void setRowCacheSize( int ) {}

     virtual void close() {}


  protected:
     IContainer&        m_container;
     ITokenIterator*    m_tokenIterator;
     Token*             m_token;

     mutable CollectionRowBuffer        m_rowBuffer;

     std::string                m_whereClause;
   };

}

#endif