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 ATTRIBUTE_H 6 #define ATTRIBUTE_H 7 8 #include <util/DoublyLinkedList.h> 9 10 #include "AttributeIndex.h" 11 #include "AttributeIterator.h" 12 #include "DataContainer.h" 13 #include "String.h" 14 15 class AllocationInfo; 16 class Node; 17 class Volume; 18 19 class Attribute : public DataContainer, 20 public DoublyLinkedListLinkImpl<Attribute> { 21 public: 22 Attribute(Volume *volume, Node *node, const char *name, uint32 type = 0); 23 ~Attribute(); 24 25 status_t InitCheck() const; 26 27 void SetNode(Node *node) { fNode = node; } 28 Node *GetNode() const { return fNode; } 29 30 const char *GetName() { return fName.GetString(); } 31 32 void SetType(uint32 type); 33 uint32 GetType() const { return fType; } 34 35 status_t SetSize(off_t newSize); 36 off_t GetSize() const { return DataContainer::GetSize(); } 37 38 virtual status_t WriteAt(off_t offset, const void *buffer, size_t size, 39 size_t *bytesWritten); 40 41 // index support 42 void SetIndex(AttributeIndex *index, bool inIndex); 43 AttributeIndex *GetIndex() const { return fIndex; } 44 bool IsInIndex() const { return fInIndex; } 45 void GetKey(uint8 *key, size_t *length); 46 47 // iterator management 48 void AttachAttributeIterator(AttributeIterator *iterator); 49 void DetachAttributeIterator(AttributeIterator *iterator); 50 inline DoublyLinkedList<AttributeIterator> *GetAttributeIteratorList() 51 { return &fIterators; } 52 53 // debugging 54 void GetAllocationInfo(AllocationInfo &info); 55 56 private: 57 Node *fNode; 58 String fName; 59 uint32 fType; 60 AttributeIndex *fIndex; 61 bool fInIndex; 62 63 // iterator management 64 DoublyLinkedList<AttributeIterator> fIterators; 65 }; 66 67 #endif // ATTRIBUTE_H 68