fswatch 1.20.1
Loading...
Searching...
No Matches
fsw::event Class Reference

Type representing a file change event. More...

#include <event.hpp>

Public Member Functions

 event (std::string path, time_t evt_time, std::vector< fsw_event_flag > flags)
 Constructs an event.
 event (std::string path, time_t evt_time, std::vector< fsw_event_flag > flags, unsigned long correlation_id)
 Constructs an event.
 event (std::string path, time_t evt_time, std::vector< fsw_event_flag > flags, unsigned long correlation_id, process_metadata process)
 Constructs an event with optional process metadata.
virtual ~event ()
 Destructs an event.
std::string get_path () const
 Returns the path of the event.
time_t get_time () const
 Returns the time of the event.
std::vector< fsw_event_flagget_flags () const
 Returns the flags of the event.
unsigned long get_correlation_id () const
 Returns the correlation_id of the file of the event.
bool has_process_id () const
 Returns true if the event has process attribution metadata.
long long get_process_id () const
 Returns the process or thread identifier associated with this event.
process_id_kind get_process_id_kind () const
 Returns the process identifier kind.
bool has_process_pidfd () const
 Returns true if the event has a process file descriptor.
int get_process_pidfd () const
 Returns the process file descriptor associated with this event.

Static Public Member Functions

static std::string get_process_id_kind_name (process_id_kind kind)
 Get the display name of a process identifier kind.
static fsw_event_flag get_event_flag_by_name (const std::string &name)
 Get event flag by name.
static std::string get_event_flag_name (const fsw_event_flag &flag)
 Get the name of an event flag.

Detailed Description

Type representing a file change event.

This class represents a file change event in the libfswatch API. An event contains:

  • The path.
  • The time the event was raised.
  • A vector of flags specifying the type of the event.
  • The correlation id of the event, if supported by the monitor, otherwise 0.

Constructor & Destructor Documentation

◆ event() [1/3]

fsw::event::event ( std::string path,
time_t evt_time,
std::vector< fsw_event_flag > flags )

Constructs an event.

Parameters
pathThe path the event refers to.
evt_timeThe time the event was raised.
flagsThe vector of flags specifying the type of the event.

◆ event() [2/3]

fsw::event::event ( std::string path,
time_t evt_time,
std::vector< fsw_event_flag > flags,
unsigned long correlation_id )

Constructs an event.

Parameters
pathThe path the event refers to.
evt_timeThe time the event was raised.
flagsThe vector of flags specifying the type of the event.
correlation_idThe correlation_id of the file the event refers to.

◆ event() [3/3]

fsw::event::event ( std::string path,
time_t evt_time,
std::vector< fsw_event_flag > flags,
unsigned long correlation_id,
process_metadata process )

Constructs an event with optional process metadata.

Parameters
pathThe path the event refers to.
evt_timeThe time the event was raised.
flagsThe vector of flags specifying the type of the event.
correlation_idThe correlation_id of the file the event refers to.
processThe optional process metadata associated with the event.

◆ ~event()

fsw::event::~event ( )
virtualdefault

Destructs an event.

This is a virtual destructor that performs no operations.

Member Function Documentation

◆ get_correlation_id()

unsigned long fsw::event::get_correlation_id ( ) const

Returns the correlation_id of the file of the event.

Returns
The correlation_id of the file of the event.

◆ get_event_flag_by_name()

fsw_event_flag fsw::event::get_event_flag_by_name ( const std::string & name)
static

Get event flag by name.

Parameters
nameThe name of the event flag to look for.
Returns
The event flag whose name is name, otherwise
Exceptions
libfsw_exceptionif no event flag is found.

◆ get_event_flag_name()

string fsw::event::get_event_flag_name ( const fsw_event_flag & flag)
static

Get the name of an event flag.

Parameters
flagThe event flag.
Returns
The name of flag.
Exceptions
libfsw_exceptionif no event flag is found.

◆ get_flags()

vector< fsw_event_flag > fsw::event::get_flags ( ) const

Returns the flags of the event.

Returns
The flags of the event.

◆ get_path()

string fsw::event::get_path ( ) const

Returns the path of the event.

Returns
The path of the event.

◆ get_process_id()

long long fsw::event::get_process_id ( ) const

Returns the process or thread identifier associated with this event.

Returns 0 when no process attribution metadata is available.

◆ get_process_pidfd()

int fsw::event::get_process_pidfd ( ) const

Returns the process file descriptor associated with this event.

Returns -1 when no process file descriptor is available. The descriptor is owned by the event producer and is only valid during callback processing.

◆ get_time()

time_t fsw::event::get_time ( ) const

Returns the time of the event.

Returns
The time of the event.

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