te::core::FileWatcher Class Reference

#include <FileWatcher.h>

Public Member Functions

 FileWatcher (const std::string &path, const std::function< void()> &callback)
 It initializes a new FileWatcher from a given path and callback function. More...
 
void unwatch ()
 Stops the thread watching the file. More...
 
void watch ()
 Starts a thread that will monitor the given file and call the previously given callback function. More...
 
 ~FileWatcher ()
 Destructor. More...
 

Private Attributes

std::function< void()> m_callback
 
std::string m_file
 
std::mutex m_mutex
 
bool m_running
 
std::thread m_watcher
 

Detailed Description

Definition at line 46 of file FileWatcher.h.

Constructor & Destructor Documentation

te::core::FileWatcher::FileWatcher ( const std::string &  path,
const std::function< void()> &  callback 
)

It initializes a new FileWatcher from a given path and callback function.

Parameters
pathA UTF-8 String with a path to a file.
callbackA function with zero parameters and void return that will be called when the file is changed.
te::core::FileWatcher::~FileWatcher ( )

Destructor.

Member Function Documentation

void te::core::FileWatcher::unwatch ( )

Stops the thread watching the file.

void te::core::FileWatcher::watch ( )

Starts a thread that will monitor the given file and call the previously given callback function.

Member Data Documentation

std::function<void()> te::core::FileWatcher::m_callback
private

Definition at line 84 of file FileWatcher.h.

std::string te::core::FileWatcher::m_file
private

Definition at line 83 of file FileWatcher.h.

std::mutex te::core::FileWatcher::m_mutex
private

Definition at line 82 of file FileWatcher.h.

bool te::core::FileWatcher::m_running
private

Definition at line 86 of file FileWatcher.h.

std::thread te::core::FileWatcher::m_watcher
private

Definition at line 85 of file FileWatcher.h.


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