libfswatch  1.9.3
Classes | Namespaces | Macros | Typedefs
monitor.hpp File Reference

Header of the fsw::monitor class. More...

#include "filter.hpp"
#include <vector>
#include <string>
#include <mutex>
#include <atomic>
#include <chrono>
#include <map>
#include "event.hpp"
#include "../c/cmonitor.h"

Go to the source code of this file.

Classes

class  fsw::monitor
 Base class of all monitors. More...
 
class  fsw::monitor_factory
 Object factory class for fsw::monitor instances. More...
 
class  fsw::monitor_registrant< M >
 Helper class to register monitor factories. More...
 

Namespaces

 fsw
 Main namespace of libfswatch.
 

Macros

#define REGISTER_MONITOR(classname, monitor_type)
 
#define REGISTER_MONITOR_IMPL(classname, monitor_type)   const monitor_registrant<classname> classname::monitor_factory_registrant(#classname, monitor_type);
 

Typedefs

typedef void fsw::FSW_EVENT_CALLBACK(const std::vector< event > &, void *)
 Function definition of an event callback. More...
 
typedef monitor *(* fsw::FSW_FN_MONITOR_CREATOR) (std::vector< std::string > paths, FSW_EVENT_CALLBACK *callback, void *context)
 

Detailed Description

Header of the fsw::monitor class.

This header file defines the fsw::monitor class, the base type of a libfswatch monitor and fundamental type of the C++ API.

If HAVE_CXX_MUTEX is defined, this header includes <mutex>.

License:
GNU General Public License v. 3.0
Author
Enrico M. Crisostomo
Version
1.8.0

Macro Definition Documentation

#define REGISTER_MONITOR (   classname,
  monitor_type 
)
Value:
private: \
static const monitor_registrant<classname> monitor_factory_registrant;

This macro is used to simplify the registration process of a monitor type. Since registration of a monitor type is usually performed once, a static private instance monitor_factory_registrant of the monitor_registrant class is declared by this macro in the enclosing class.

Beware that since this macro adds a private qualifier, every field declared after it must be correctly qualified.

The use of the REGISTER_MONITOR macro in a class must always be matched by a corresponding use of the REGISTER_MONITOR_IMPL macro in the class definition.

To register class my_monitor with type my_type, use the REGISTER_MONITOR macro as in the following example:

[my_class.h] class my_monitor { REGISTER_MONITOR(my_monitor, my_monitor_type); ... };

#define REGISTER_MONITOR_IMPL (   classname,
  monitor_type 
)    const monitor_registrant<classname> classname::monitor_factory_registrant(#classname, monitor_type);

This macro is used to simplify the registration process of a monitor type. Since registration of a monitor type is usually performed once, a static private instance monitor_factory_registrant of the monitor_registrant class is defined in the monitor class specified by classname.

A invocation of the REGISTER_MONITOR_IMPL macro must always be matched by an invocation of the REGISTER_MONITOR macro in the class declaration.

To register class my_monitor with type my_type, use the REGISTER_MONITOR macro as in the following example:

[my_class.cpp]

REGISTER_MONITOR_IMPL(my_monitor, my_monitor_type);