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 ENTRY_H 6 #define ENTRY_H 7 8 #include <fs_interface.h> 9 #include <SupportDefs.h> 10 11 #include <util/DoublyLinkedList.h> 12 13 #include "String.h" 14 15 class AllocationInfo; 16 class Directory; 17 class EntryIterator; 18 class Node; 19 20 class Entry : public DoublyLinkedListLinkImpl<Entry> { 21 public: 22 Entry(const char *name, Node *node = NULL, Directory *parent = NULL); 23 ~Entry(); 24 25 status_t InitCheck() const; 26 27 Entry*& HashLink() { return fHashLink; } 28 29 inline void SetParent(Directory *parent) { fParent = parent; } 30 Directory *GetParent() const { return fParent; } 31 32 // inline void SetNode(Node *node) { fNode = node; } 33 status_t Link(Node *node); 34 status_t Unlink(); 35 Node *GetNode() const { return fNode; } 36 37 status_t SetName(const char *newName); 38 inline const char *GetName() const { return fName.GetString(); } 39 40 // inline Volume *GetVolume() const { return fVolume; } 41 42 inline DoublyLinkedListLink<Entry> *GetReferrerLink() 43 { return &fReferrerLink; } 44 45 // entry iterator management 46 void AttachEntryIterator(EntryIterator *iterator); 47 void DetachEntryIterator(EntryIterator *iterator); 48 inline DoublyLinkedList<EntryIterator> *GetEntryIteratorList() 49 { return &fIterators; } 50 51 // debugging 52 void GetAllocationInfo(AllocationInfo &info); 53 54 private: 55 Entry *fHashLink; 56 Directory *fParent; 57 Node *fNode; 58 String fName; 59 DoublyLinkedListLink<Entry> fReferrerLink; 60 // iterator management 61 DoublyLinkedList<EntryIterator> fIterators; 62 }; 63 64 // GetNodeReferrerLink 65 class GetNodeReferrerLink { 66 private: 67 typedef DoublyLinkedListLink<Entry> Link; 68 69 public: 70 inline Link *operator()(Entry *entry) const 71 { 72 return entry->GetReferrerLink(); 73 } 74 }; 75 76 #endif // ENTRY_H 77