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
13class SizeIndex : public Index, private NodeListener {
14public:
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
22private:
23	virtual void NodeAdded(Node *node);
24	virtual void NodeRemoved(Node *node);
25
26protected:
27	virtual AbstractIndexEntryIterator *InternalGetIterator();
28	virtual AbstractIndexEntryIterator *InternalFind(const uint8 *key,
29													 size_t length);
30
31private:
32	class Iterator;
33	class IteratorList;
34	class NodeTree;
35	friend class Iterator;
36
37private:
38	void _AddIterator(Iterator *iterator);
39	void _RemoveIterator(Iterator *iterator);
40
41private:
42	NodeTree		*fNodes;
43	IteratorList	*fIterators;
44};
45
46#endif	// SIZE_INDEX_H
47