QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgscachedfeatureiterator.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgscachedfeatureiterator.cpp
3  --------------------------------------
4  Date : 12.2.2013
5  Copyright : (C) 2013 Matthias Kuhn
6  Email : matthias dot kuhn at gmx dot ch
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
17 #include "qgsvectorlayercache.h"
18 
20  : QgsAbstractFeatureIterator( featureRequest )
21  , mFeatureIds( featureIds )
22  , mVectorLayerCache( vlCache )
23 {
24  mFeatureIdIterator = featureIds.begin();
25 }
26 
28 {
30 
31  if ( mFeatureIdIterator == mFeatureIds.end() )
32  {
33  return false;
34  }
35  else
36  {
38  return true;
39  }
40 }
41 
43 {
45  return true;
46 }
47 
49 {
50  // Nothing to clean...
51  return true;
52 }
53 
55  : QgsAbstractFeatureIterator( featureRequest )
56  , mVectorLayerCache( vlCache )
57 {
58  mFeatIt = vlCache->layer()->getFeatures( featureRequest );
59 }
60 
62 {
63  if ( mFeatIt.nextFeature( f ) )
64  {
65  // As long as features can be fetched from the provider: Write them to cache
67  mFids.insert( f.id() );
68  return true;
69  }
70  else
71  {
72  // Once no more features can be fetched: Inform the cache, that
73  // the request has been completed
75  return false;
76  }
77 }
78 
80 {
81  mFids.clear();
82  return mFeatIt.rewind();
83 }
84 
86 {
87  return mFeatIt.close();
88 }