libfswatch  1.9.3
Public Member Functions | Static Public Member Functions | List of all members
fsw::monitor_factory Class Reference

Object factory class for fsw::monitor instances. More...

#include <monitor.hpp>

Public Member Functions

 monitor_factory (const monitor_factory &orig)=delete
 
monitor_factoryoperator= (const monitor_factory &that)=delete
 

Static Public Member Functions

static monitorcreate_monitor (fsw_monitor_type type, std::vector< std::string > paths, FSW_EVENT_CALLBACK *callback, void *context=nullptr)
 Creates a monitor of the specified type. More...
 
static monitorcreate_monitor (const std::string &name, std::vector< std::string > paths, FSW_EVENT_CALLBACK *callback, void *context=nullptr)
 Creates a monitor whose type is the specified by name. More...
 
static std::vector< std::string > get_types ()
 Get the available monitor types. More...
 
static bool exists_type (const std::string &name)
 Checks whether a monitor of the type specified by name exists. More...
 
static bool exists_type (const fsw_monitor_type &type)
 Checks whether a monitor of the type specified type. More...
 
static void register_creator (const std::string &name, FSW_FN_MONITOR_CREATOR creator)
 Registers a creator for the specified monitor type name. More...
 
static void register_creator_by_type (const fsw_monitor_type &type, FSW_FN_MONITOR_CREATOR creator)
 Registers a creator for the specified monitor type. More...
 

Detailed Description

Object factory class for fsw::monitor instances.

Since multiple monitor implementations exist and the caller potentially ignores which monitors will be available at run time, there must exist a way to query the API for the list of available monitor and request a particular instance. The fsw::monitor_factory is an object factory class that provides basic monitor registration and discovery functionality: API clients can query the monitor registry to get a list of available monitors and get an instance of a monitor either by type or by name.

In order for monitor types to be visible to the factory they have to be registered. Currently, monitor implementations can be registered using the register_creator() and register_creator_by_type(), or using:

The same monitor type cannot be used to register multiple monitor implementations. No checks are in place to detect this situation and the registration will succeed; however, the registration process of multiple monitor implementations for the same monitor type is not deterministic.

Member Function Documentation

static monitor* fsw::monitor_factory::create_monitor ( fsw_monitor_type  type,
std::vector< std::string >  paths,
FSW_EVENT_CALLBACK callback,
void *  context = nullptr 
)
static

Creates a monitor of the specified type.

The other parameters are forwarded to the fsw::monitor() constructor.

Parameters
typeThe monitor type.
pathsThe paths to watch.
callbackThe callback to invoke during the notification of a change event.
Returns
The newly created monitor.
Exceptions
libfsw_exceptionif a monitor of the specified type cannot be found.
See also
fsw::monitor()
static monitor* fsw::monitor_factory::create_monitor ( const std::string &  name,
std::vector< std::string >  paths,
FSW_EVENT_CALLBACK callback,
void *  context = nullptr 
)
static

Creates a monitor whose type is the specified by name.

The other parameters are forwarded to the fsw::monitor() constructor.

Parameters
nameThe monitor type.
pathsThe paths to watch.
callbackThe callback to invoke during the notification of a change event.
Returns
The newly created monitor.
Exceptions
libfsw_exceptionif a monitor of the type specified by name cannot be found.
See also
fsw::monitor()
static bool fsw::monitor_factory::exists_type ( const std::string &  name)
static

Checks whether a monitor of the type specified by name exists.

Returns
true if name specifies a valid monitor type, false otherwise.
Parameters
nameThe name of the monitor type to look for.
Returns
true if the type name exists, false otherwise.
bool fsw::monitor_factory::exists_type ( const fsw_monitor_type type)
static

Checks whether a monitor of the type specified type.

Parameters
typeThe type of the monitor to look for.
Returns
true if name specifies a valid monitor type, false otherwise.
vector< string > fsw::monitor_factory::get_types ( )
static

Get the available monitor types.

Returns
A vector with the available monitor types.
void fsw::monitor_factory::register_creator ( const std::string &  name,
FSW_FN_MONITOR_CREATOR  creator 
)
static

Registers a creator for the specified monitor type name.

Parameters
nameThe name of the monitor type.
creatorThe monitor creator function.
void fsw::monitor_factory::register_creator_by_type ( const fsw_monitor_type type,
FSW_FN_MONITOR_CREATOR  creator 
)
static

Registers a creator for the specified monitor type.

Parameters
typeThe monitor type.
creatorThe monitor creator function.

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