#ifndef ENTRY_H
#define ENTRY_H
#include <fs_interface.h>
#include <SupportDefs.h>
#include <util/DoublyLinkedList.h>
#include "String.h"
class AllocationInfo;
class Directory;
class EntryIterator;
class Node;
class Entry : public DoublyLinkedListLinkImpl<Entry> {
public:
Entry(const char *name, Node *node = NULL, Directory *parent = NULL);
~Entry();
status_t InitCheck() const;
Entry*& HashLink() { return fHashLink; }
inline void SetParent(Directory *parent) { fParent = parent; }
Directory *GetParent() const { return fParent; }
status_t Link(Node *node);
status_t Unlink();
Node *GetNode() const { return fNode; }
status_t SetName(const char *newName);
inline const char *GetName() const { return fName.GetString(); }
inline DoublyLinkedListLink<Entry> *GetReferrerLink()
{ return &fReferrerLink; }
void AttachEntryIterator(EntryIterator *iterator);
void DetachEntryIterator(EntryIterator *iterator);
inline DoublyLinkedList<EntryIterator> *GetEntryIteratorList()
{ return &fIterators; }
void GetAllocationInfo(AllocationInfo &info);
private:
Entry *fHashLink;
Directory *fParent;
Node *fNode;
String fName;
DoublyLinkedListLink<Entry> fReferrerLink;
DoublyLinkedList<EntryIterator> fIterators;
};
class GetNodeReferrerLink {
private:
typedef DoublyLinkedListLink<Entry> Link;
public:
inline Link *operator()(Entry *entry) const
{
return entry->GetReferrerLink();
}
};
#endif