|
CeresEngine 0.2.0
A game development framework
|
Watcher that reports on changes of files or directories. More...
#include <CeresEngine/Foundation/IO/FileWatcher.hpp>
Public Types | |
| using | ImplementationType = SPtr< IFileWatcher > |
| using | EventFunc = std::function< void(const FileHandle &, FileEvent)> |
| Callback function for file system events. | |
Public Member Functions | |
| FileWatcher (ExecutionContext &executionContext, const FileHandle &directory, const FileEvent &events=FileEvent::Default, bool recursive=true) | |
| Creates a new watcher for the given directory. | |
| FileWatcher (ImplementationType &&implementation) | |
Creates a new FileWatcher from a concrete implementation. | |
| FileWatcher (const FileWatcher &fileWatcher)=delete | |
| FileWatcher & | operator= (const FileWatcher &fileWatcher)=delete |
| FileWatcher & | operator= (FileWatcher &&other) noexcept |
| FileWatcher (FileWatcher &&other) noexcept | |
| ~FileWatcher () noexcept | |
| IFileSystem * | getFileSystem () const |
| Gets file system that this watcher watches for. | |
| void | start () |
| Starts the file watching operation. | |
| void | stop () |
| Stops the file watching operation. | |
| void | addHandler (FileEventHandler &eventHandler) |
| Adds an event handler. | |
| void | addHandler (EventFunc &&funcFileEvent) |
| Adds a callback function as event handler. | |
| void | removeHandler (const FileEventHandler &eventHandler) |
| Remove an event handler. | |
Protected Member Functions | |
| void | onFileEvent (const FileHandle &handle, FileEvent event) |
| Called on file event. | |
Private Attributes | |
| ImplementationType | mImplementation |
| The file handle implementation. | |
| Vector< FileEventHandler * > | mEventHandlers |
| List of registered file event handlers. | |
| Vector< UPtr< FunctionalFileEventHandler > > | mOwnEventHandlers |
| Functional event handlers that are owned by the file watcher. | |
Friends | |
| class | IFileWatcher |
Watcher that reports on changes of files or directories.
| using CeresEngine::FileWatcher::EventFunc = std::function<void(const FileHandle&, FileEvent)> |
Callback function for file system events.
|
explicit |
Creates a new watcher for the given directory.
| CeresEngine::FileWatcher::FileWatcher | ( | ImplementationType && | implementation | ) |
Creates a new FileWatcher from a concrete implementation.
|
delete |
|
noexcept |
|
noexcept |
Adds a callback function as event handler.
| funcFileEvent | The function that is call on each file system event. |
| void CeresEngine::FileWatcher::addHandler | ( | FileEventHandler & | eventHandler | ) |
Adds an event handler.
| eventHandler | The File event handler. |
| IFileSystem * CeresEngine::FileWatcher::getFileSystem | ( | ) | const |
Gets file system that this watcher watches for.
|
protected |
Called on file event.
| handle | The file handle that received the event. |
| event | The type of event that has occurred. |
|
delete |
|
noexcept |
| void CeresEngine::FileWatcher::removeHandler | ( | const FileEventHandler & | eventHandler | ) |
Remove an event handler.
| eventHandler | The file event handler. |
| void CeresEngine::FileWatcher::start | ( | ) |
Starts the file watching operation.
stop(). | void CeresEngine::FileWatcher::stop | ( | ) |
Stops the file watching operation.
|
friend |
|
private |
List of registered file event handlers.
|
private |
The file handle implementation.
|
private |
Functional event handlers that are owned by the file watcher.