xref: /haiku/headers/private/debugger/files/LocatableEntry.h (revision fce4895d1884da5ae6fb299d23c735c598e690b1)
1 /*
2  * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef LOCATABLE_ENTRY_H
6 #define LOCATABLE_ENTRY_H
7 
8 #include <String.h>
9 
10 #include <Referenceable.h>
11 #include <util/DoublyLinkedList.h>
12 #include <util/OpenHashTable.h>
13 
14 
15 enum locatable_entry_state {
16 	LOCATABLE_ENTRY_UNLOCATED,
17 	LOCATABLE_ENTRY_LOCATED_IMPLICITLY,
18 	LOCATABLE_ENTRY_LOCATED_EXPLICITLY
19 };
20 
21 
22 class LocatableDirectory;
23 class LocatableEntry;
24 
25 
26 class LocatableEntryOwner {
27 public:
28 	virtual						~LocatableEntryOwner();
29 
30 	virtual	bool				Lock() = 0;
31 	virtual	void				Unlock() = 0;
32 
33 	virtual	void				LocatableEntryUnused(LocatableEntry* entry) = 0;
34 };
35 
36 
37 class LocatableEntry : public BReferenceable,
38 	public DoublyLinkedListLinkImpl<LocatableEntry> {
39 public:
40 								LocatableEntry(LocatableEntryOwner* owner,
41 									LocatableDirectory* parent);
42 								~LocatableEntry();
43 
Parent()44 			LocatableDirectory*	Parent() const	{ return fParent; }
45 	virtual	const char*			Name() const = 0;
46 
47 			// mutable (requires locking)
State()48 			locatable_entry_state State() const	{ return fState; }
49 	virtual	bool				GetLocatedPath(BString& _path) const = 0;
50 	virtual	void				SetLocatedPath(const BString& path,
51 									bool implicit) = 0;
52 
53 protected:
54 	virtual	void				LastReferenceReleased();
55 
56 protected:
57 			LocatableEntryOwner* fOwner;
58 			LocatableDirectory*	fParent;
59 			locatable_entry_state fState;
60 
61 public:
62 			LocatableEntry* fNext;
63 };
64 
65 
66 typedef DoublyLinkedList<LocatableEntry> LocatableEntryList;
67 
68 
69 #endif	// LOCATABLE_ENTRY_H
70