fswatch  1.14.0
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_factory.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...
 

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 are registered at compile time.

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

◆ create_monitor() [1/2]

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()

◆ create_monitor() [2/2]

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()

◆ exists_type()

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.

◆ get_types()

std::vector< std::string > fsw::monitor_factory::get_types ( )
static

Get the available monitor types.

Returns
A vector with the available monitor types.

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