libcommonc++
0.7
|
A class that watches for changes in a given directory. More...
#include <DirectoryWatcher.h++>
Public Member Functions | |
virtual | ~DirectoryWatcher () |
Destructor. More... | |
void | init () |
Initialize the watcher. More... | |
virtual void | start () |
Start executing the thread. More... | |
virtual void | stop () |
Stop execution of the thread. More... | |
bool | join () |
Wait for the thread to terminate. More... | |
bool | isRunning () const |
Test if the thread is currently running. More... | |
bool | isDetached () const |
Test if the thread is detached. More... | |
void | setPriority (Priority priority) |
Set the thread priority. More... | |
Priority | getPriority () const |
Get the thread priority. More... | |
void | setName (const String &name) |
Set the name of this thread. More... | |
String | getName () const |
Get the name of this thread. More... | |
Static Public Member Functions | |
static void | sleep (timespan_ms_t msec) |
Suspend the calling thread for the given time interval. More... | |
static Thread * | currentThread () |
Obtain a pointer to the Thread object for the calling thread. More... | |
static ThreadID | currentThreadID () |
Get the calling thread's thread ID. More... | |
Protected Member Functions | |
DirectoryWatcher (const String &directory) | |
Construct a new DirectoryWatcher that will watch the specified directory. More... | |
void | run () |
Main function. More... | |
virtual void | fileCreated (const String &path)=0 |
Called when a file is created in the watched directory. More... | |
virtual void | fileDeleted (const String &path)=0 |
Called when a file is deleted in the watched directory. More... | |
virtual void | fileModified (const String &path)=0 |
Called when a file is modified in the watched directory. More... | |
virtual void | fileRenamed (const String &oldPath, const String &newPath)=0 |
Called when a file is renamed in the watched directory. More... | |
virtual void | cleanup () |
Cleanup function. More... | |
bool | trySleep (timespan_ms_t msec) |
Suspend the thread for the given time interval, returning early if the thread was cancelled via a call to stop(). More... | |
bool | testCancel () |
Test for asynchronous cancellation requests. More... | |
void | yield () |
Yield the CPU to (potentially) another thread. More... | |
Static Protected Member Functions | |
static void | exit () |
Exit (terminate) the calling thread. More... | |
A class that watches for changes in a given directory.
When a file within the watched directory is created, deleted, modified, or renamed, the corresponding handler method is called. This is an abstract class which must be subclassed to implement the handler methods. A watcher must run in its own thread.
NOTE: This class is currently not implemented on Mac OS X.
|
virtual |
Destructor.
|
protected |
Construct a new DirectoryWatcher that will watch the specified directory.
directory | The directory to watch. |
|
protectedvirtualinherited |
Cleanup function.
This function will be executed by the thread just prior to termination. The default implementation is a no-op.
Reimplemented in SocketSelector, and PulseTimer.
|
staticinherited |
Obtain a pointer to the Thread object for the calling thread.
If the calling thread is the main thread, or some other thread that was not created via commonc++, a NULL pointer is returned. Never delete the object returned by this method.
|
staticinherited |
Get the calling thread's thread ID.
|
staticprotectedinherited |
Exit (terminate) the calling thread.
|
protectedpure virtual |
Called when a file is created in the watched directory.
path | The path (relative to the watched directory) of the new file. |
|
protectedpure virtual |
Called when a file is deleted in the watched directory.
path | The path (relative to the watched directory) of the deleted file. |
|
protectedpure virtual |
Called when a file is modified in the watched directory.
path | The path (relative to the watched directory) of the modified file. |
Called when a file is renamed in the watched directory.
oldPath | The old path (relative to the watched directory) of the renamed file. |
newPath | The new path (relative to the watched directory) of the renamed file. |
|
inlineinherited |
Get the name of this thread.
|
inherited |
Get the thread priority.
void init | ( | ) |
Initialize the watcher.
SystemException | If an error occurs. |
|
inlineinherited |
Test if the thread is detached.
|
inherited |
Test if the thread is currently running.
|
inherited |
Wait for the thread to terminate.
|
protectedvirtual |
|
inlineinherited |
Set the name of this thread.
|
inherited |
Set the thread priority.
|
staticinherited |
Suspend the calling thread for the given time interval.
msec | The number of milliseconds to sleep. |
|
virtualinherited |
|
virtualinherited |
Stop execution of the thread.
The thread is not forcibly killed; instead, an asynchronous cancellation request is posted to the thread. If the thread is not running, the call has no effect.
|
protectedinherited |
Test for asynchronous cancellation requests.
|
protectedinherited |
Suspend the thread for the given time interval, returning early if the thread was cancelled via a call to stop().
msec | The number of milliseconds to sleep. |
|
protectedinherited |
Yield the CPU to (potentially) another thread.