| 1 |
/* |
| 2 |
* Copyright (C) 2016-2024 Team Kodi |
| 3 |
* This file is part of Kodi - https://kodi.tv |
| 4 |
* |
| 5 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
* See LICENSES/README.md for more information. |
| 7 |
*/ |
| 8 |
|
| 9 |
#pragma once |
| 10 |
|
| 11 |
namespace PERIPHERALS |
| 12 |
{ |
| 13 |
class CEventPollHandle; |
| 14 |
|
| 15 |
/*! |
| 16 |
* \ingroup peripherals |
| 17 |
* |
| 18 |
* \brief Callback implemented by event scanner |
| 19 |
*/ |
| 20 |
class IEventPollCallback |
| 21 |
{ |
| 22 |
public: |
| 23 |
virtual ~IEventPollCallback(void) = default; |
| 24 |
|
| 25 |
virtual void Activate(CEventPollHandle& handle) = 0; |
| 26 |
virtual void Deactivate(CEventPollHandle& handle) = 0; |
| 27 |
virtual void HandleEvents(bool bWait) = 0; |
| 28 |
virtual void Release(CEventPollHandle& handle) = 0; |
| 29 |
}; |
| 30 |
|
| 31 |
/*! |
| 32 |
* \brief Handle returned by the event scanner to control scan timing |
| 33 |
* |
| 34 |
* When held, this allows one to control the timing of when events are |
| 35 |
* handled. |
| 36 |
*/ |
| 37 |
class CEventPollHandle |
| 38 |
{ |
| 39 |
public: |
| 40 |
/*! |
| 41 |
* \brief Create an active polling handle |
| 42 |
*/ |
| 43 |
CEventPollHandle(IEventPollCallback& callback); |
| 44 |
|
| 45 |
/*! |
| 46 |
* \brief Handle is automatically released when this class is destructed |
| 47 |
*/ |
| 48 |
~CEventPollHandle(); |
| 49 |
|
| 50 |
/*! |
| 51 |
* \brief Activate handle |
| 52 |
*/ |
| 53 |
void Activate(); |
| 54 |
|
| 55 |
/*! |
| 56 |
* \brief Deactivate handle |
| 57 |
*/ |
| 58 |
void Deactivate(); |
| 59 |
|
| 60 |
/*! |
| 61 |
* \brief Trigger a scan for events |
| 62 |
* |
| 63 |
* \param bWait If true, this blocks until all events are handled |
| 64 |
*/ |
| 65 |
void HandleEvents(bool bWait); |
| 66 |
|
| 67 |
private: |
| 68 |
IEventPollCallback& m_callback; |
| 69 |
}; |
| 70 |
} // namespace PERIPHERALS |