[Windows] Fix driver version detection of AMD RDNA+ GPU on Windows 10
[xbmc.git] / xbmc / pvr / PVRChannelNumberInputHandler.h
blobefa28ca6f2a80fee144f03e989c5cd0a2b73d7e6
1 /*
2 * Copyright (C) 2012-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include "pvr/channels/PVRChannelNumber.h"
12 #include "threads/CriticalSection.h"
13 #include "threads/Timer.h"
14 #include "utils/EventStream.h"
16 #include <string>
17 #include <vector>
19 namespace PVR
21 struct PVRChannelNumberInputChangedEvent
23 explicit PVRChannelNumberInputChangedEvent(const std::string& input) : m_input(input) {}
24 virtual ~PVRChannelNumberInputChangedEvent() = default;
26 std::string m_input;
29 class CPVRChannelNumberInputHandler : private ITimerCallback
31 public:
32 static const int CHANNEL_NUMBER_INPUT_MAX_DIGITS = 5;
34 CPVRChannelNumberInputHandler();
36 /*!
37 * @brief ctor.
38 * @param iDelay timer delay in millisecods.
39 * @param iMaxDigits maximum number of display digits to use.
41 CPVRChannelNumberInputHandler(int iDelay, int iMaxDigits = CHANNEL_NUMBER_INPUT_MAX_DIGITS);
43 ~CPVRChannelNumberInputHandler() override = default;
45 /*!
46 * @brief Get the events available for CEventStream.
47 * @return The events.
49 CEventStream<PVRChannelNumberInputChangedEvent>& Events() { return m_events; }
51 // implementation of ITimerCallback
52 void OnTimeout() override;
54 /*!
55 * @brief Get the currently available channel numbers.
56 * @param channelNumbers The list to fill with the channel numbers.
58 virtual void GetChannelNumbers(std::vector<std::string>& channelNumbers) = 0;
60 /*!
61 * @brief This method gets called after the channel number input timer has expired.
63 virtual void OnInputDone() = 0;
65 /*!
66 * @brief Appends a channel number character.
67 * @param cCharacter The character to append. value must be CPVRChannelNumber::SEPARATOR ('.') or any char in the range from '0' to '9'.
69 virtual void AppendChannelNumberCharacter(char cCharacter);
71 /*!
72 * @brief Check whether a channel number was entered.
73 * @return True if the handler currently holds a channel number, false otherwise.
75 bool HasChannelNumber() const;
77 /*!
78 * @brief Get the currently entered channel number as a formatted string.
79 * @return the channel number string.
81 std::string GetChannelNumberLabel() const;
83 /*!
84 * @brief If a number was entered, execute the associated action.
85 * @return True, if the action was executed, false otherwise.
87 bool CheckInputAndExecuteAction();
89 protected:
90 /*!
91 * @brief Get the currently entered channel number.
92 * @return the channel number.
94 CPVRChannelNumber GetChannelNumber() const;
96 /*!
97 * @brief Get the currently entered number of digits.
98 * @return the number of digits.
100 size_t GetCurrentDigitCount() const { return m_inputBuffer.size(); }
102 mutable CCriticalSection m_mutex;
104 private:
105 void ExecuteAction();
107 void SetLabel(const std::string& label);
109 std::vector<std::string> m_sortedChannelNumbers;
110 const int m_iDelay;
111 const int m_iMaxDigits;
112 std::string m_inputBuffer;
113 std::string m_label;
114 CTimer m_timer;
115 CEventSource<PVRChannelNumberInputChangedEvent> m_events;
118 } // namespace PVR