1 #include <memory> 2 #include <functional> 3 #include <string> 4 5 class WatchTower { 6 public: 7 // Registration object to implement RAII 8 using Registration = std::shared_ptr<void>; 9 10 // Create an empty watchtower 11 WatchTower() {}; 12 // Destroy the object 13 virtual ~WatchTower() {}; 14 15 // Add a file to the notification list. notification will be called when 16 // the file is modified, moved or deleted. 17 // Lifetime of the notification is tied to the Registration object returned. 18 // Note the notification function is called with a mutex held and in a 19 // third party thread, beware of races! 20 virtual Registration addFile( const std::string& file_name, 21 std::function<void()> notification ) = 0; 22 }; 23