1 /* 2 * Copyright 2011, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef ATTRIBUTE_INDEX_H 6 #define ATTRIBUTE_INDEX_H 7 8 9 #include "Index.h" 10 #include "NodeListener.h" 11 12 13 class AttributeIndexer; 14 struct AttributeIndexTreeKey; 15 struct AttributeIndexTreeValue; 16 17 18 class AttributeIndex : public Index, private NodeListener { 19 public: 20 AttributeIndex(); 21 virtual ~AttributeIndex(); 22 23 status_t Init(Volume* volume, const char* name, 24 uint32 type, size_t keyLength); 25 26 virtual int32 CountEntries() const; 27 28 private: 29 virtual void NodeAdded(Node* node); 30 virtual void NodeRemoved(Node* node); 31 virtual void NodeChanged(Node* node, uint32 statFields, 32 const OldNodeAttributes& oldAttributes); 33 34 protected: 35 virtual AbstractIndexIterator* InternalGetIterator(); 36 virtual AbstractIndexIterator* InternalFind(const void* key, 37 size_t length); 38 39 private: 40 typedef AttributeIndexTreeKey TreeKey; 41 typedef AttributeIndexTreeValue TreeValue; 42 struct TreeDefinition; 43 struct NodeTree; 44 45 struct IteratorPolicy; 46 class Iterator; 47 class IteratorList; 48 friend class Iterator; 49 friend struct IteratorPolicy; 50 51 friend class AttributeIndexer; 52 53 private: 54 void _AddIteratorToUpdate(Iterator* iterator); 55 56 private: 57 NodeTree* fNodes; 58 IteratorList* fIteratorsToUpdate; 59 AttributeIndexer* fIndexer; 60 }; 61 62 63 #endif // ATTRIBUTE_INDEX_H 64