xref: /haiku/src/add-ons/kernel/file_systems/packagefs/indices/SizeIndex.h (revision 17889a8c70dbb3d59c1412f6431968753c767bab)
1 /*
2  * Copyright 2011, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef SIZE_INDEX_H
6 #define SIZE_INDEX_H
7 
8 
9 #include "Index.h"
10 #include "NodeListener.h"
11 
12 
13 class SizeIndex : public Index, private NodeListener {
14 public:
15 								SizeIndex();
16 	virtual						~SizeIndex();
17 
18 			status_t			Init(Volume* volume);
19 
20 	virtual	int32				CountEntries() const;
21 
22 private:
23 	virtual	void				NodeAdded(Node* node);
24 	virtual	void				NodeRemoved(Node* node);
25 	virtual	void				NodeChanged(Node* node, uint32 statFields,
26 									const OldNodeAttributes& oldAttributes);
27 
28 protected:
29 	virtual	AbstractIndexIterator* InternalGetIterator();
30 	virtual	AbstractIndexIterator* InternalFind(const void* key,
31 									size_t length);
32 
33 private:
34 			struct IteratorPolicy;
35 			class Iterator;
36 			class IteratorList;
37 			class NodeTree;
38 			friend class Iterator;
39 			friend struct IteratorPolicy;
40 
41 private:
42 			void				_AddIteratorToUpdate(Iterator* iterator);
43 
44 private:
45 			NodeTree*			fNodes;
46 			IteratorList*		fIteratorsToUpdate;
47 };
48 
49 
50 #endif	// SIZE_INDEX_H
51