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