1/*
2 * Copyright 2011, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef NAME_INDEX_H
6#define NAME_INDEX_H
7
8
9#include "Index.h"
10#include "NodeListener.h"
11
12
13template<typename Policy> class GenericIndexIterator;
14
15
16class NameIndex : public Index, private NodeListener {
17public:
18								NameIndex();
19	virtual						~NameIndex();
20
21			status_t			Init(Volume* volume);
22
23	virtual	int32				CountEntries() const;
24
25private:
26	virtual	void				NodeAdded(Node* node);
27	virtual	void				NodeRemoved(Node* node);
28	virtual	void				NodeChanged(Node* node, uint32 statFields,
29									const OldNodeAttributes& oldAttributes);
30
31protected:
32	virtual	AbstractIndexIterator* InternalGetIterator();
33	virtual	AbstractIndexIterator* InternalFind(const void* key,
34									size_t length);
35
36private:
37			class EntryTree;
38			struct IteratorPolicy;
39			struct Iterator;
40
41			friend struct IteratorPolicy;
42
43			void				_UpdateLiveQueries(Node* entry,
44									const char* oldName, const char* newName);
45
46private:
47			EntryTree*			fEntries;
48};
49
50
51#endif	// NAME_INDEX_H
52