1 // QueryIterator.h 2 3 #ifndef NET_FS_QUERY_ITERATOR_H 4 #define NET_FS_QUERY_ITERATOR_H 5 6 #include <Referenceable.h> 7 #include <util/DoublyLinkedList.h> 8 9 class HierarchicalQueryIterator; 10 class Volume; 11 12 // QueryIterator 13 class QueryIterator : public BReferenceable, 14 public DoublyLinkedListLinkImpl<QueryIterator> { 15 public: 16 QueryIterator(Volume* volume); 17 virtual ~QueryIterator(); 18 19 Volume* GetVolume() const; 20 21 void SetParentIterator( 22 HierarchicalQueryIterator* parent); 23 HierarchicalQueryIterator* GetParentIterator() const; 24 25 virtual status_t ReadQuery(struct dirent* buffer, 26 size_t bufferSize, int32 count, 27 int32* countRead, bool* done); 28 29 struct GetVolumeLink; 30 friend struct GetVolumeLink; 31 32 protected: 33 virtual void LastReferenceReleased(); 34 35 private: 36 Volume* fVolume; 37 HierarchicalQueryIterator* fParentIterator; 38 DoublyLinkedListLink<QueryIterator> fVolumeLink; 39 }; 40 41 // HierarchicalQueryIterator 42 class HierarchicalQueryIterator : public QueryIterator { 43 public: 44 HierarchicalQueryIterator(Volume* volume); 45 virtual ~HierarchicalQueryIterator(); 46 47 QueryIterator* GetCurrentSubIterator() const; 48 QueryIterator* NextSubIterator(); 49 void RewindSubIterator(); 50 void AddSubIterator(QueryIterator* subIterator); 51 void RemoveSubIterator(QueryIterator* subIterator); 52 void RemoveAllSubIterators( 53 DoublyLinkedList<QueryIterator>& 54 subIterators); 55 56 private: 57 DoublyLinkedList<QueryIterator> fSubIterators; 58 QueryIterator* fCurrentSubIterator; 59 }; 60 61 // GetVolumeLink 62 struct QueryIterator::GetVolumeLink { operatorGetVolumeLink63 DoublyLinkedListLink<QueryIterator>* operator()( 64 QueryIterator* iterator) const 65 { 66 return &iterator->fVolumeLink; 67 } 68 operatorGetVolumeLink69 const DoublyLinkedListLink<QueryIterator>* operator()( 70 const QueryIterator* iterator) const 71 { 72 return &iterator->fVolumeLink; 73 } 74 }; 75 76 #endif // NET_FS_QUERY_ITERATOR_H 77