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

Public Types

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

Public Member Functions

 GLibIdleEventSource (GLibEventDispatcher &mainLoop, CallBackFunction callBackFunction)
 
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...
 

Protected Attributes

CallBackFunction m_func
 

Detailed Description

Definition at line 28 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::GLibIdleEventSource::enable ( )
overridevirtual

Enables the source.

Implements ivi::EventSource.

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

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

83 {
84  if (!isEnabled()) {
85  m_source = g_idle_source_new();
86  g_source_set_callback(m_source, &onGLibCallback, this, nullptr);
87  g_source_attach(m_source, m_mainLoop.getGMainContext());
88  }
89 }
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::GLibIdleEventSource::disable ( )
overridevirtual

Disables the source.

Implements ivi::EventSource.

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

References isEnabled().

92 {
93  if (isEnabled()) {
94  g_source_destroy(m_source);
95  g_source_unref(m_source);
96  m_source = nullptr;
97  }
98 }
bool isEnabled() const override
Returns true if the source is currently enabled, false otherwise.

Here is the call graph for this function:

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

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

Implements ivi::EventSource.

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

Referenced by disable(), and enable().

78  {
79  return (m_source != nullptr);
80 }

Here is the caller graph for this function:


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