ivi-main-loop
ivi::GLibTimeOutEventSource Class Reference
Inheritance diagram for ivi::GLibTimeOutEventSource:
Collaboration diagram for ivi::GLibTimeOutEventSource:

Public Types

typedef std::function< ReportStatus()> CallBackFunction
 
enum  ReportStatus { ReportStatus::KEEP_ENABLED, ReportStatus::DISABLE }
 

Public Member Functions

 GLibTimeOutEventSource (GLibEventDispatcher &mainLoop, CallBackFunction callBackFunction, DurationInMilliseconds duration)
 
void setDuration (DurationInMilliseconds duration) override
 
void enable () override
 Enables the source. More...
 
void disable () override
 Disables the source. More...
 
bool isEnabled () const override
 Returns true if the source is currently enabled, false otherwise. More...
 
DurationInMilliseconds getDuration () const
 

Protected Attributes

DurationInMilliseconds m_duration
 
CallBackFunction m_func
 

Detailed Description

Definition at line 57 of file ivi-main-loop-glib.h.

Member Enumeration Documentation

enum ivi::EventSource::ReportStatus
stronginherited
Enumerator
KEEP_ENABLED 

Returning that value from a source's callback function causes the source to remain enabled.

DISABLE 

Returning that value from a source's callback function causes the source to be disabled.

Definition at line 32 of file ivi-main-loop-common.h.

33  {
34  /// Returning that value from a source's callback function causes the source to remain enabled
35  KEEP_ENABLED,
36 
37  /// Returning that value from a source's callback function causes the source to be disabled
38  DISABLE
39  };

Member Function Documentation

void ivi::GLibTimeOutEventSource::enable ( )
overridevirtual

Enables the source.

Implements ivi::EventSource.

Definition at line 130 of file ivi-main-loop-glib.cpp.

References ivi::GLibEventDispatcher::getGMainContext(), and isEnabled().

131 {
132  if (!isEnabled()) {
133  m_source = g_timeout_source_new(getDuration());
134  g_source_set_callback(m_source, onTimerCallback, this, nullptr);
135  g_source_attach(m_source, m_mainLoop.getGMainContext());
136  }
137 }
bool isEnabled() const override
Returns true if the source is currently enabled, false otherwise.
GMainContext * getGMainContext()
Return the glib main context reference.

Here is the call graph for this function:

void ivi::GLibTimeOutEventSource::disable ( )
overridevirtual

Disables the source.

Implements ivi::EventSource.

Definition at line 139 of file ivi-main-loop-glib.cpp.

References isEnabled().

140 {
141  if (isEnabled()) {
142  g_source_destroy(m_source);
143  g_source_unref(m_source);
144  m_source = nullptr;
145  }
146 }
bool isEnabled() const override
Returns true if the source is currently enabled, false otherwise.

Here is the call graph for this function:

bool ivi::GLibTimeOutEventSource::isEnabled ( ) const
overridevirtual

Returns true if the source is currently enabled, false otherwise.

Implements ivi::EventSource.

Definition at line 126 of file ivi-main-loop-glib.cpp.

Referenced by disable(), and enable().

126  {
127  return (m_source != nullptr);
128 }

Here is the caller graph for this function:


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