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 13class LocatableFile : public LocatableEntry { 14public: 15 class Listener; 16 17public: 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 34private: 35 typedef BObjectList<Listener> ListenerList; 36 37private: 38 void _NotifyListeners(); 39 40private: 41 BString fName; 42 BString fLocatedPath; 43 ListenerList fListeners; 44}; 45 46 47class LocatableFile::Listener { 48public: 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