idle_detect  0.8.3.0
Provides overall idle detection for a linux computer
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | List of all members
EventMessage Class Reference

The EventMessage class is a small class that encapsulates the "event message", which is a message sent from the local idle_detect instance to event_detect indicating an event that updates the last active time. The message is effectively timestamp:m_event_type in string format (to make use of pipe easier). More...

#include <util.h>

Public Types

enum  EventType {
  UNKNOWN, USER_ACTIVE, USER_UNFORCE, USER_FORCE_ACTIVE,
  USER_FORCE_IDLE
}
 The EventType enum defines event types for the EventMessage class. Currently there is only one event type in use, USER_ACTIVE.
 

Public Member Functions

 EventMessage ()
 Constructs an "empty" EventMessage with timestamp of 0 and EventType of UNKNOWN.
 
 EventMessage (int64_t timestamp, EventType event_type)
 Constructs an EventMessage from the provided parameters. More...
 
 EventMessage (std::string timestamp_str, std::string event_type_str)
 Constructs an EventMessage from the provided strings. More...
 
std::string EventTypeToString ()
 Converts m_event_type member variable in the EventMessage object to a string. More...
 
bool IsValid ()
 Validates the EventMessage object. More...
 
std::string ToString ()
 Returns the string message format of the EventMessage object. This is meant to go on the pipe. This is in lieu of a full serialization approach, which is overkill here. More...
 

Static Public Member Functions

static std::string EventTypeToString (const EventType &event_type)
 Static version that takes the event_type enum as a parameter and provides the string representation. More...
 

Public Attributes

int64_t m_timestamp
 
EventType m_event_type
 

Private Member Functions

EventType EventTypeStringToEnum (const std::string &event_type_str)
 This converts the event type string to the proper enum value. It is the converse of EventTypeToString(). More...
 

Detailed Description

The EventMessage class is a small class that encapsulates the "event message", which is a message sent from the local idle_detect instance to event_detect indicating an event that updates the last active time. The message is effectively timestamp:m_event_type in string format (to make use of pipe easier).

The class stores these in their native format.

A validation method and conversion to string format are provided.

Constructor & Destructor Documentation

◆ EventMessage() [1/2]

EventMessage::EventMessage ( int64_t  timestamp,
EventType  event_type 
)

Constructs an EventMessage from the provided parameters.

Parameters
timestamp
event_type

◆ EventMessage() [2/2]

EventMessage::EventMessage ( std::string  timestamp_str,
std::string  event_type_str 
)

Constructs an EventMessage from the provided strings.

Parameters
timestamp_str
event_type_str
Here is the call graph for this function:

Member Function Documentation

◆ EventTypeStringToEnum()

EventMessage::EventType EventMessage::EventTypeStringToEnum ( const std::string &  event_type_str)
private

This converts the event type string to the proper enum value. It is the converse of EventTypeToString().

Parameters
event_type_str
Returns
EventType enum value
Here is the caller graph for this function:

◆ EventTypeToString() [1/2]

std::string EventMessage::EventTypeToString ( )

Converts m_event_type member variable in the EventMessage object to a string.

Returns
string representation of enum value
Here is the caller graph for this function:

◆ EventTypeToString() [2/2]

std::string EventMessage::EventTypeToString ( const EventType event_type)
static

Static version that takes the event_type enum as a parameter and provides the string representation.

Parameters
event_type
Returns
string representation of enum value

◆ IsValid()

bool EventMessage::IsValid ( )

Validates the EventMessage object.

Returns
true if EventMessage is valid.
Here is the caller graph for this function:

◆ ToString()

std::string EventMessage::ToString ( )

Returns the string message format of the EventMessage object. This is meant to go on the pipe. This is in lieu of a full serialization approach, which is overkill here.

Returns
std::string in the format of <timestamp>:<event_type string>="">
Here is the call graph for this function:

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