xref: /haiku/src/add-ons/kernel/file_systems/ramfs/EntryIterator.h (revision bb83316a5811a550c4f850d07fa8e328e7ac0a94)
1 /*
2  * Copyright 2007, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * All rights reserved. Distributed under the terms of the MIT license.
4  */
5 #ifndef ENTRY_ITERATOR_H
6 #define ENTRY_ITERATOR_H
7 
8 #include <SupportDefs.h>
9 
10 #include <util/DoublyLinkedList.h>
11 
12 class Directory;
13 class Entry;
14 
15 class EntryIterator : public DoublyLinkedListLinkImpl<EntryIterator> {
16 public:
17 	EntryIterator(Directory *directory = NULL);
18 	~EntryIterator();
19 
20 	status_t SetTo(Directory *directory);
21 	void Unset();
22 
23 	Directory *GetDirectory() const { return fDirectory; }
24 
25 	status_t Suspend();
26 	status_t Resume();
27 	bool IsSuspended() const { return fSuspended; }
28 
29 	status_t GetNext(Entry **entry);
30 	Entry *GetCurrent() const { return fEntry; }
31 
32 	status_t Rewind();
33 
34 private:
35 	void SetCurrent(Entry *entry, bool isNext);
36 
37 private:
38 	friend class Directory;
39 
40 private:
41 	Directory					*fDirectory;
42 	Entry						*fEntry;
43 	bool						fSuspended;
44 	bool						fIsNext;
45 	bool						fDone;
46 };
47 
48 #endif	// ENTRY_ITERATOR_H
49