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