$search

fawkes::FileAlterationMonitor Class Reference

#include <fam.h>

List of all members.

Public Member Functions

void add_filter (const char *regex)
void add_listener (FamListener *listener)
 FileAlterationMonitor ()
void interrupt ()
void process_events (int timeout=0)
void remove_listener (FamListener *listener)
void watch_dir (const char *dirpath)
void watch_file (const char *filepath)
 ~FileAlterationMonitor ()

Private Attributes

char * __inotify_buf
size_t __inotify_bufsize
int __inotify_fd
std::map< int, std::string > __inotify_watches
std::map< int, std::string >
::iterator 
__inotify_wit
bool __interrupted
bool __interruptible
std::list< FamListener * > __listeners
std::list< FamListener * >
::iterator 
__lit
int __pipe_fds [2]
std::list< regex_t * > __regexes
std::list< regex_t * >::iterator __rxit

Detailed Description

Monitors files for changes. This is a wrapper around inotify. It will watch directories and files for modifications. If a modifiacation, removal or addition of a file is detected one or more listeners are called. The files which trigger the event can be constrained with regular expressions.

Author:
Tim Niemueller

Definition at line 70 of file fam.h.


Constructor & Destructor Documentation

fawkes::FileAlterationMonitor::FileAlterationMonitor (  ) 

Constructor. Opens the inotify context.

Definition at line 121 of file fam.cpp.

fawkes::FileAlterationMonitor::~FileAlterationMonitor (  ) 

Destructor.

Definition at line 141 of file fam.cpp.


Member Function Documentation

void fawkes::FileAlterationMonitor::add_filter ( const char *  regex  ) 

Add a filter. Filters are applied to path names that triggered an event. All pathnames are checked against this regex and if any does not match the event is not posted to listeners. An example regular expression is

 ^[^.].*\\.lua$

This regular expression matches to all files that does not start with a dot and have an .lua ending.

Parameters:
regex regular expression to add

Definition at line 244 of file fam.cpp.

void fawkes::FileAlterationMonitor::add_listener ( FamListener listener  ) 

Add a listener.

Parameters:
listener listener to add

Definition at line 262 of file fam.cpp.

void fawkes::FileAlterationMonitor::interrupt (  ) 

Interrupt a running process_events(). This method will interrupt e.g. a running inifinetly blocking call of process_events().

Definition at line 402 of file fam.cpp.

void fawkes::FileAlterationMonitor::process_events ( int  timeout = 0  ) 

Process events. Call this when you want file events to be processed.

Parameters:
timeout timeout in milliseconds to wait for an event, 0 to just check and no wait, -1 to wait forever until an event is received

Definition at line 284 of file fam.cpp.

void fawkes::FileAlterationMonitor::remove_listener ( FamListener listener  ) 

Remove a listener.

Parameters:
listener listener to remove

Definition at line 272 of file fam.cpp.

void fawkes::FileAlterationMonitor::watch_dir ( const char *  dirpath  ) 

Watch a directory. This adds the given directory recursively to this FAM.

Parameters:
dirpath path to directory to add

Definition at line 166 of file fam.cpp.

void fawkes::FileAlterationMonitor::watch_file ( const char *  filepath  ) 

Watch a file. This adds the given fileto this FAM.

Parameters:
filepath path to file to add

Definition at line 215 of file fam.cpp.


Member Data Documentation

Definition at line 93 of file fam.h.

Definition at line 94 of file fam.h.

Definition at line 92 of file fam.h.

std::map<int, std::string> fawkes::FileAlterationMonitor::__inotify_watches [private]

Definition at line 95 of file fam.h.

std::map<int, std::string>::iterator fawkes::FileAlterationMonitor::__inotify_wit [private]

Definition at line 96 of file fam.h.

Definition at line 98 of file fam.h.

Definition at line 99 of file fam.h.

Definition at line 87 of file fam.h.

std::list<FamListener *>::iterator fawkes::FileAlterationMonitor::__lit [private]

Definition at line 88 of file fam.h.

Definition at line 100 of file fam.h.

std::list<regex_t *> fawkes::FileAlterationMonitor::__regexes [private]

Definition at line 89 of file fam.h.

std::list<regex_t *>::iterator fawkes::FileAlterationMonitor::__rxit [private]

Definition at line 90 of file fam.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends


lua_utils
Author(s): Tim Niemueller
autogenerated on Tue Mar 5 12:26:31 2013