home *** CD-ROM | disk | FTP | other *** search
/ Hackers Magazine 57 / CdHackersMagazineNr57.iso / Software / Multimedia / k3d-setup-0.7.11.0.exe / include / k3d / k3dsdk / ifile_change_notifier.h < prev    next >
C/C++ Source or Header  |  2008-12-29  |  3KB  |  81 lines

  1. #ifndef K3DSDK_IFILE_CHANGE_NOTIFIER_H
  2. #define K3DSDK_IFILE_CHANGE_NOTIFIER_H
  3.  
  4. // K-3D
  5. // Copyright (c) 1995-2008, Timothy M. Shead
  6. //
  7. // Contact: tshead@k-3d.com
  8. //
  9. // This program is free software; you can redistribute it and/or
  10. // modify it under the terms of the GNU General Public
  11. // License as published by the Free Software Foundation; either
  12. // version 2 of the License, or (at your option) any later version.
  13. //
  14. // This program is distributed in the hope that it will be useful,
  15. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17. // General Public License for more details.
  18. //
  19. // You should have received a copy of the GNU General Public
  20. // License along with this program; if not, write to the Free Software
  21. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  22.  
  23. /** \file ifile_change_notifier.h
  24.     \author Tim Shead (tshead@k-3d.com)
  25.     \author Bart Janssens (bart.janssens@lid.kviv.be)
  26.     \created Dec 17, 2008
  27. */
  28.  
  29. #include "iunknown.h"
  30. #include "signal_system.h"
  31. #include "types.h"
  32.  
  33. namespace k3d
  34. {
  35.  
  36. namespace filesystem
  37. {
  38.  
  39. class path;
  40.  
  41. }
  42.  
  43. /// Interface implemented by objects that can signal changes to files.
  44. class ifile_change_notifier :
  45.     public virtual iunknown
  46. {
  47. public:
  48.     virtual ~ifile_change_notifier() {}
  49.     
  50.     /// Call a slot whenever given filesystem path is modified.
  51.     /**
  52.     * Note that we are watching the
  53.     * path, not an inode, so it isn't an error to specify a path for a nonexistent file.
  54.     * The slot will be called when a file is created / modified / renamed / deleted at that
  55.     * location.  Returns a nonzero watch identifier that can be used to cancel the watch later-on,
  56.     * or 0 if there is an error.
  57.     */
  58.     virtual uint_t watch_file(const filesystem::path& Path, const sigc::slot<void>& Slot) = 0;
  59.  
  60.     /// Stop watching the given path.
  61.     virtual void unwatch_file(const uint_t WatchID) = 0;
  62.  
  63.     /// Blocks indefinitely until there is at least one file change ready to be signalled.
  64.     virtual void wait_for_changes() = 0;
  65.  
  66.     /// Returns the number of file changes that are pending and ready to be signalled.  This method never blocks.
  67.     virtual const uint_t change_count() = 0;
  68.  
  69.     /// Handles signalling for the next file change that is pending, if any.  This method never blocks.
  70.     virtual void signal_change() = 0;
  71.   
  72. protected:
  73.     ifile_change_notifier() {}
  74.     ifile_change_notifier(const ifile_change_notifier&) {}
  75.     ifile_change_notifier& operator=(const ifile_change_notifier&) {return *this;}
  76. };
  77.  
  78. } // namespace k3d
  79.  
  80. #endif // !K3DSDK_IFILE_CHANGE_NOTIFIER_H
  81.