13c5dbb46SIngo Weinhold/*
23c5dbb46SIngo Weinhold * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
33c5dbb46SIngo Weinhold * Distributed under the terms of the MIT License.
43c5dbb46SIngo Weinhold */
53c5dbb46SIngo Weinhold#ifndef LOCATABLE_FILE_H
63c5dbb46SIngo Weinhold#define LOCATABLE_FILE_H
73c5dbb46SIngo Weinhold
83c5dbb46SIngo Weinhold#include <ObjectList.h>
93c5dbb46SIngo Weinhold
103c5dbb46SIngo Weinhold#include "LocatableEntry.h"
113c5dbb46SIngo Weinhold
123c5dbb46SIngo Weinhold
133c5dbb46SIngo Weinholdclass LocatableFile : public LocatableEntry {
143c5dbb46SIngo Weinholdpublic:
153c5dbb46SIngo Weinhold	class Listener;
163c5dbb46SIngo Weinhold
173c5dbb46SIngo Weinholdpublic:
183c5dbb46SIngo Weinhold								LocatableFile(LocatableEntryOwner* owner,
193c5dbb46SIngo Weinhold									LocatableDirectory* directory,
203c5dbb46SIngo Weinhold									const BString& name);
213c5dbb46SIngo Weinhold								~LocatableFile();
223c5dbb46SIngo Weinhold
233c5dbb46SIngo Weinhold	virtual	const char*			Name() const;
243c5dbb46SIngo Weinhold			void				GetPath(BString& _path) const;
253c5dbb46SIngo Weinhold
263c5dbb46SIngo Weinhold			// mutable (requires/does locking)
273c5dbb46SIngo Weinhold	virtual	bool				GetLocatedPath(BString& _path) const;
283c5dbb46SIngo Weinhold	virtual	void				SetLocatedPath(const BString& path,
293c5dbb46SIngo Weinhold									bool implicit);
303c5dbb46SIngo Weinhold
313c5dbb46SIngo Weinhold			bool				AddListener(Listener* listener);
323c5dbb46SIngo Weinhold			void				RemoveListener(Listener* listener);
333c5dbb46SIngo Weinhold
343c5dbb46SIngo Weinholdprivate:
353c5dbb46SIngo Weinhold			typedef BObjectList<Listener> ListenerList;
363c5dbb46SIngo Weinhold
373c5dbb46SIngo Weinholdprivate:
383c5dbb46SIngo Weinhold			void				_NotifyListeners();
393c5dbb46SIngo Weinhold
403c5dbb46SIngo Weinholdprivate:
413c5dbb46SIngo Weinhold			BString				fName;
423c5dbb46SIngo Weinhold			BString				fLocatedPath;
433c5dbb46SIngo Weinhold			ListenerList		fListeners;
443c5dbb46SIngo Weinhold};
453c5dbb46SIngo Weinhold
463c5dbb46SIngo Weinhold
473c5dbb46SIngo Weinholdclass LocatableFile::Listener {
483c5dbb46SIngo Weinholdpublic:
493c5dbb46SIngo Weinhold	virtual						~Listener();
503c5dbb46SIngo Weinhold
513c5dbb46SIngo Weinhold	virtual	void				LocatableFileChanged(LocatableFile* file) = 0;
523c5dbb46SIngo Weinhold									// called with lock held
533c5dbb46SIngo Weinhold};
543c5dbb46SIngo Weinhold
553c5dbb46SIngo Weinhold
563c5dbb46SIngo Weinhold#endif	// LOCATABLE_FILE_H
57