xref: /haiku/headers/private/debugger/files/LocatableFile.h (revision cbe0a0c436162d78cc3f92a305b64918c839d079)
1 /*
2  * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef LOCATABLE_FILE_H
6 #define LOCATABLE_FILE_H
7 
8 #include <ObjectList.h>
9 
10 #include "LocatableEntry.h"
11 
12 
13 class LocatableFile : public LocatableEntry {
14 public:
15 	class Listener;
16 
17 public:
18 								LocatableFile(LocatableEntryOwner* owner,
19 									LocatableDirectory* directory,
20 									const BString& name);
21 								~LocatableFile();
22 
23 	virtual	const char*			Name() const;
24 			void				GetPath(BString& _path) const;
25 
26 			// mutable (requires/does locking)
27 	virtual	bool				GetLocatedPath(BString& _path) const;
28 	virtual	void				SetLocatedPath(const BString& path,
29 									bool implicit);
30 
31 			bool				AddListener(Listener* listener);
32 			void				RemoveListener(Listener* listener);
33 
34 private:
35 			typedef BObjectList<Listener> ListenerList;
36 
37 private:
38 			void				_NotifyListeners();
39 
40 private:
41 			BString				fName;
42 			BString				fLocatedPath;
43 			ListenerList		fListeners;
44 };
45 
46 
47 class LocatableFile::Listener {
48 public:
49 	virtual						~Listener();
50 
51 	virtual	void				LocatableFileChanged(LocatableFile* file) = 0;
52 									// called with lock held
53 };
54 
55 
56 #endif	// LOCATABLE_FILE_H
57