lfilesystem  0.0.1
C++ filesystem library
limes::files::SimpleFileWatcher Class Referencefinal

This class implements all of FileWatcher's virtual methods, and allows you to easily specify a lambda function that will be called for any event type. More...

#include <lfilesystem_SimpleWatcher.h>

+ Inheritance diagram for limes::files::SimpleFileWatcher:

Public Types

using Callback = std::function< void(const FilesystemEntry &)>
 The type of the lambda that will be called for any event type. More...
 

Public Member Functions

 SimpleFileWatcher (const FilesystemEntry &fileToWatch, Callback &&callbackToUse)
 Creates a file watcher that will call the given callback for every event type on the watched path. More...
 
- Public Member Functions inherited from limes::files::FileWatcher
 FileWatcher () noexcept
 Creates an inactive FileWatcher that does nothing. More...
 
 FileWatcher (const FilesystemEntry &fileToWatch)
 Creates a FileWatcher to watch the given file or directory. More...
 
 FileWatcher (const FileWatcher &)=delete
 
 FileWatcher (FileWatcher &&)=delete
 
virtual ~FileWatcher ()
 Destructor. More...
 
FilesystemEntry getWatchedPath () const noexcept
 Returns the path that is currently being watched. More...
 
bool isRunning ()
 Returns true if the FilesystemWatcher is currently monitoring events. More...
 
FileWatcheroperator= (const FileWatcher &)=delete
 
FileWatcheroperator= (FileWatcher &&)=delete
 
bool start ()
 Restarts watching the path specified at construction. More...
 
bool start (const FilesystemEntry &newPathToWatch)
 Begins watching the new specified path. More...
 
void stop ()
 Stops the FilesystemWatcher's event callbacks. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from limes::files::FileWatcher
static bool supportedBySystem () noexcept
 Returns true if the current system supports file event watching. More...
 

Detailed Description

This class implements all of FileWatcher's virtual methods, and allows you to easily specify a lambda function that will be called for any event type.

See also
FileWatcher

Definition at line 37 of file lfilesystem_SimpleWatcher.h.

Member Typedef Documentation

◆ Callback

using limes::files::SimpleFileWatcher::Callback = std::function<void (const FilesystemEntry&)>

The type of the lambda that will be called for any event type.

The argument is the file that was affected by the action, so if a directory is being watched, this may be a child path of the watched directory.

Definition at line 46 of file lfilesystem_SimpleWatcher.h.

Constructor & Destructor Documentation

◆ SimpleFileWatcher()

limes::files::SimpleFileWatcher::SimpleFileWatcher ( const FilesystemEntry fileToWatch,
Callback &&  callbackToUse 
)
explicit

Creates a file watcher that will call the given callback for every event type on the watched path.

Exceptions
std::runtime_errorThrows an exception if the file watcher fails to initialize for any reason. An exception will always be thrown if the file you request to watch does not exist at the time of the object's construction.

The documentation for this class was generated from the following file: