My Project
Public Types | Public Member Functions | List of all members
ParaEngine::CFileSystemWatcher Class Reference

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)
 

Detailed Description

monitoring file changes.

under windows: it uses ReadDirectoryChangesW under linux: it uses inotify. under macOS: kqueue

Member Function Documentation

§ add_directory()

bool ParaEngine::CFileSystemWatcher::add_directory ( const std::string &  dirname)

add a directory to monitor.

§ AddEventCallback()

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().

§ Destroy()

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.

§ DispatchEvents()

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.

Returns
number of events dispatched.

§ IsDispatchInMainThread()

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

§ remove_directory()

bool ParaEngine::CFileSystemWatcher::remove_directory ( const std::string &  dirname)

remove a directory to monitor.

§ SetDispatchInMainThread()

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


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