xref: /haiku/src/add-ons/kernel/file_systems/ramfs/SizeIndex.h (revision 13581b3d2a71545960b98fefebc5225b5bf29072)
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 SIZE_INDEX_H
6 #define SIZE_INDEX_H
7 
8 #include "Index.h"
9 #include "NodeListener.h"
10 #include "TwoKeyAVLTree.h"
11 
12 // SizeIndex
13 class SizeIndex : public Index, private NodeListener {
14 public:
15 	SizeIndex(Volume *volume);
16 	virtual ~SizeIndex();
17 
18 	virtual int32 CountEntries() const;
19 
20 	virtual status_t Changed(Node *node, off_t oldSize);
21 
22 private:
23 	virtual void NodeAdded(Node *node);
24 	virtual void NodeRemoved(Node *node);
25 
26 protected:
27 	virtual AbstractIndexEntryIterator *InternalGetIterator();
28 	virtual AbstractIndexEntryIterator *InternalFind(const uint8 *key,
29 													 size_t length);
30 
31 private:
32 	class Iterator;
33 	class IteratorList;
34 	class NodeTree;
35 	friend class Iterator;
36 
37 private:
38 	void _AddIterator(Iterator *iterator);
39 	void _RemoveIterator(Iterator *iterator);
40 
41 private:
42 	NodeTree		*fNodes;
43 	IteratorList	*fIterators;
44 };
45 
46 #endif	// SIZE_INDEX_H
47