fswatch
1.14.0
|
Object factory class for fsw::monitor instances. More...
#include <monitor_factory.hpp>
Public Member Functions | |
monitor_factory (const monitor_factory &orig)=delete | |
monitor_factory & | operator= (const monitor_factory &that)=delete |
Static Public Member Functions | |
static monitor * | create_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 monitor * | create_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... | |
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.
|
static |
Creates a monitor of the specified type
.
The other parameters are forwarded to the fsw::monitor() constructor.
type | The monitor type. |
paths | The paths to watch. |
callback | The callback to invoke during the notification of a change event. |
libfsw_exception | if a monitor of the specified type cannot be found. |
|
static |
Creates a monitor whose type is the specified by name
.
The other parameters are forwarded to the fsw::monitor() constructor.
name | The monitor type. |
paths | The paths to watch. |
callback | The callback to invoke during the notification of a change event. |
libfsw_exception | if a monitor of the type specified by name cannot be found. |
|
static |
Checks whether a monitor of the type specified by name
exists.
true
if name
specifies a valid monitor type, false
otherwise.name | The name of the monitor type to look for. |
true
if the type name
exists, false
otherwise.
|
static |
Get the available monitor types.