My Project
|
monitoring file changes. More...
#include <FileSystemWatcher.h>
Public Types | |
typedef boost::asio::dir_monitor_event::event_type | FileActionEnum |
typedef boost::asio::dir_monitor_event | DirMonitorEvent |
typedef boost::signals2::signal< void(const DirMonitorEvent &)> | FileSystemEvent_t |
typedef boost::signals2::connection | FileSystemEvent_Connection_t |
Public Member Functions | |
CFileSystemWatcher (const std::string &filename) | |
void | Destroy () |
must be called before you wait for worker thread to exit. More... | |
bool | add_directory (const std::string &dirname) |
add a directory to monitor. More... | |
bool | remove_directory (const std::string &dirname) |
remove a directory to monitor. More... | |
int | DispatchEvents () |
this allows us to process queued messages in main thread's frame move. More... | |
void | SetDispatchInMainThread (bool bMainThread) |
if true(default), we will dispatch all callback event in the main thread. More... | |
bool | IsDispatchInMainThread () |
if true(default), we will dispatch all callback event in the main thread. More... | |
FileSystemEvent_Connection_t | AddEventCallback (FileSystemEvent_t::slot_type callback) |
add an event call back, please note that the event callback may be called from the main thread or the io thread, depending on the IsDispatchInMainThread(). More... | |
const std::string & | GetName () const |
void | SetName (const std::string &val) |
monitoring file changes.
under windows: it uses ReadDirectoryChangesW under linux: it uses inotify. under macOS: kqueue
bool ParaEngine::CFileSystemWatcher::add_directory | ( | const std::string & | dirname | ) |
add a directory to monitor.
CFileSystemWatcher::FileSystemEvent_Connection_t ParaEngine::CFileSystemWatcher::AddEventCallback | ( | FileSystemEvent_t::slot_type | callback | ) |
add an event call back, please note that the event callback may be called from the main thread or the io thread, depending on the IsDispatchInMainThread().
void ParaEngine::CFileSystemWatcher::Destroy | ( | ) |
must be called before you wait for worker thread to exit.
when worker thread is existed, You can safely delete this class.
int ParaEngine::CFileSystemWatcher::DispatchEvents | ( | ) |
this allows us to process queued messages in main thread's frame move.
this function only works when message are told to be dispatched from the main thread.
bool ParaEngine::CFileSystemWatcher::IsDispatchInMainThread | ( | ) |
if true(default), we will dispatch all callback event in the main thread.
Otherwise event callback will be invoked from a IO thread created by this file watcher object
bool ParaEngine::CFileSystemWatcher::remove_directory | ( | const std::string & | dirname | ) |
remove a directory to monitor.
void ParaEngine::CFileSystemWatcher::SetDispatchInMainThread | ( | bool | bMainThread | ) |
if true(default), we will dispatch all callback event in the main thread.
Otherwise event callback will be invoked from a IO thread created by this file watcher object