PcapPlusPlus
pcpp::ApplicationEventHandler Class Reference

#include <SystemUtils.h>

Public Types

typedef void(* EventHandlerCallback) (void *cookie)
 

Public Member Functions

void onApplicationInterrupted (EventHandlerCallback handler, void *cookie)
 

Static Public Member Functions

static ApplicationEventHandlergetInstance ()
 

Detailed Description

A singleton class that provides callbacks for events that occur during application life-cycle such as ctrl+c pressed, application closed, killed, etc.

Member Typedef Documentation

◆ EventHandlerCallback

pcpp::ApplicationEventHandler::EventHandlerCallback

The callback to be invoked when the event occurs

Parameters
[in]cookieA pointer the the cookie provided by the user in ApplicationEventHandler c'tor

Member Function Documentation

◆ getInstance()

static ApplicationEventHandler& pcpp::ApplicationEventHandler::getInstance ( )
inlinestatic

As ApplicationEventHandler is a singleton, this is the static getter to retrieve its instance

Returns
The singleton instance of ApplicationEventHandler

◆ onApplicationInterrupted()

void pcpp::ApplicationEventHandler::onApplicationInterrupted ( EventHandlerCallback  handler,
void *  cookie 
)

Register for an application-interrupted event, meaning ctrl+c was pressed

Parameters
[in]handlerThe callback to be activated when the event occurs
[in]cookieA pointer to a user provided object. This object will be transferred to the EventHandlerCallback callback. This cookie is very useful for transferring objects that give context to the event callback