RADLib
RADical C++ application framework
RADCore::RADFileSystemWatcher Class Reference

inotify-backed filesystem watcher that emits on a RADCore EventLoop. More...

#include <RADCore.h>

+ Inheritance diagram for RADCore::RADFileSystemWatcher:
+ Collaboration diagram for RADCore::RADFileSystemWatcher:

Public Member Functions

 RADFileSystemWatcher (EventLoop &loop)
 Creates a watcher that posts events to loop. More...
 
 ~RADFileSystemWatcher () override
 Stops the watcher. More...
 
bool addPath (const std::string &path)
 Adds a non-recursive path watch. More...
 
bool addPath (const std::string &path, bool recursive)
 Adds a path watch, recursively when requested. More...
 
void removePath (const std::string &path)
 Removes a watched path. More...
 
void clear ()
 Removes all watched paths. More...
 
std::vector< std::string > paths () const
 Returns currently watched paths. More...
 
- Public Member Functions inherited from RADCore::RADObject
 RADObject ()
 Creates a RADObject bound to the current thread. More...
 
virtual ~RADObject ()
 Disconnects tracked event links and releases lifetime token. More...
 
void registerLink (const ConnectionRecord &record)
 Registers a connection for cleanup when this object is destroyed. More...
 
std::thread::id threadId () const
 Returns the thread id this object is currently associated with. More...
 
EventLoopassociatedEventLoop () const
 Returns the associated event loop, if any. More...
 
ThreadAffinity threadAffinity () const
 Returns both thread id and associated loop atomically. More...
 
std::weak_ptr< void > lifetimeToken () const
 Returns a weak token used to drop queued callbacks after destruction. More...
 
void moveToThread (std::thread::id tId, EventLoop *loop=nullptr)
 Moves the object's affinity to tId and optional loop. More...
 

Public Attributes

RADCore::Event< void(std::string, FileSystemEvent) > changed
 Raised with path and event type when a watched path changes. More...
 
RADCore::Event< void(std::string) > errorOccurred
 Raised when watcher setup or event processing fails. More...
 

Detailed Description

inotify-backed filesystem watcher that emits on a RADCore EventLoop.

Constructor & Destructor Documentation

◆ RADFileSystemWatcher()

RADCore::RADFileSystemWatcher::RADFileSystemWatcher ( EventLoop loop)
explicit

Creates a watcher that posts events to loop.

◆ ~RADFileSystemWatcher()

RADCore::RADFileSystemWatcher::~RADFileSystemWatcher ( )
override

Stops the watcher.

Member Function Documentation

◆ addPath() [1/2]

bool RADCore::RADFileSystemWatcher::addPath ( const std::string &  path)

Adds a non-recursive path watch.

◆ addPath() [2/2]

bool RADCore::RADFileSystemWatcher::addPath ( const std::string &  path,
bool  recursive 
)

Adds a path watch, recursively when requested.

◆ clear()

void RADCore::RADFileSystemWatcher::clear ( )

Removes all watched paths.

◆ paths()

std::vector<std::string> RADCore::RADFileSystemWatcher::paths ( ) const

Returns currently watched paths.

◆ removePath()

void RADCore::RADFileSystemWatcher::removePath ( const std::string &  path)

Removes a watched path.

Member Data Documentation

◆ changed

RADCore::Event<void (std::string, FileSystemEvent) > RADCore::RADFileSystemWatcher::changed

Raised with path and event type when a watched path changes.

◆ errorOccurred

RADCore::Event<void (std::string) > RADCore::RADFileSystemWatcher::errorOccurred

Raised when watcher setup or event processing fails.


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