62 bool recursive =
true);
#define CE_EXPLICIT(EXPR)
Definition Macros.hpp:413
A context for function object execution.
Definition ExecutionContext.hpp:90
A handler that is informed about file system events.
Definition FileWatcher.hpp:143
FileEventHandler()=default
virtual void onFileEvent(const FileHandle &handle, FileEvent event)
virtual void onFileModified(const FileHandle &handle)
Called when a file or directory has been modified.
virtual void onFileRemoved(const FileHandle &handle)
Called when a file or directory has been removed.
virtual ~FileEventHandler()=default
virtual void onFileAttributesChanged(const FileHandle &handle)
Called when file attributes have been modified.
virtual void onFileCreated(const FileHandle &handle)
Called when a file or directory has been created.
Handle for a file or directory.
Definition FileHandle.hpp:46
Watcher that reports on changes of files or directories.
Definition FileWatcher.hpp:41
FileWatcher(ExecutionContext &executionContext, const FileHandle &directory, const FileEvent &events=FileEvent::Default, bool recursive=true)
Creates a new watcher for the given directory.
void onFileEvent(const FileHandle &handle, FileEvent event)
Called on file event.
SPtr< IFileWatcher > ImplementationType
Definition FileWatcher.hpp:43
IFileSystem * getFileSystem() const
Gets file system that this watcher watches for.
Vector< UPtr< FunctionalFileEventHandler > > mOwnEventHandlers
Functional event handlers that are owned by the file watcher.
Definition FileWatcher.hpp:53
void start()
Starts the file watching operation.
void addHandler(FileEventHandler &eventHandler)
Adds an event handler.
std::function< void(const FileHandle &, FileEvent)> EventFunc
Callback function for file system events.
Definition FileWatcher.hpp:57
void removeHandler(const FileEventHandler &eventHandler)
Remove an event handler.
ImplementationType mImplementation
The file handle implementation.
Definition FileWatcher.hpp:47
void stop()
Stops the file watching operation.
Vector< FileEventHandler * > mEventHandlers
List of registered file event handlers.
Definition FileWatcher.hpp:50
A FileEventHandler that calls a function or a lambda.
Definition FileWatcher.hpp:172
FunctionalFileEventHandler()
~FunctionalFileEventHandler() final
FunctionalFileEventHandler(EventFunc &&funcFileEvent)
Creates a new FunctionalFileEventHandler.
std::function< void(const FileHandle &, FileEvent)> EventFunc
Callback function type for file system events.
Definition FileWatcher.hpp:175
EventFunc mFuncFileEvent
A Callback function for file system events.
Definition FileWatcher.hpp:179
Interface for accessing file systems.
Definition FileSystem.hpp:28
Interface for file watcher implementations.
Definition FileWatcher.hpp:114
virtual IFileSystem * getFileSystem() const =0
Gets file system that this watcher watches for.
FileWatcher * mFileWatcher
File watcher that owns the implementation.
Definition FileWatcher.hpp:120
void onFileEvent(const FileHandle &handle, FileEvent event)
Called on file event.
virtual void start()=0
Starts the file watching operation.
virtual void stop()=0
Stops the file watching operation.
Definition Application.hpp:19
std::shared_ptr< T > SPtr
SPtr is a smart pointer that retains shared ownership of an object through a pointer.
Definition SmartPtr.hpp:37
FileEvent
Type of event on the file system.
Definition FileWatcher.hpp:28
@ Created
A file or directory has been created.
@ AttributeChanged
Attributes on a file or directory have been modified.
@ Modified
A file or directory has been modified.
std::vector< T, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > Vector
Vector is a sequence container that encapsulates dynamic size arrays.
Definition Vector.hpp:17
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25