summaryrefslogtreecommitdiffstats
path: root/xbmc/pvr/addons/PVRClientMenuHooks.h
blob: 69d7f79539da1f7a22ef2bd5001142aad4acca58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
 *  Copyright (C) 2012-2018 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#pragma once

#include <functional>
#include <memory>
#include <string>
#include <vector>

struct PVR_MENUHOOK;

namespace PVR
{
  class CPVRClientMenuHook
  {
  public:
    CPVRClientMenuHook() = delete;
    virtual ~CPVRClientMenuHook() = default;

    CPVRClientMenuHook(const std::string& addonId, const PVR_MENUHOOK& hook);

    bool operator ==(const CPVRClientMenuHook& right) const;

    bool IsAllHook() const;
    bool IsChannelHook() const;
    bool IsTimerHook() const;
    bool IsEpgHook() const;
    bool IsRecordingHook() const;
    bool IsDeletedRecordingHook() const;
    bool IsSettingsHook() const;

    std::string GetAddonId() const;
    unsigned int GetId() const;
    unsigned int GetLabelId() const;
    std::string GetLabel() const;

  private:
    std::string m_addonId;
    std::shared_ptr<PVR_MENUHOOK> m_hook;
  };

  class CPVRClientMenuHooks
  {
  public:
    CPVRClientMenuHooks() = default;
    virtual ~CPVRClientMenuHooks() = default;

    explicit CPVRClientMenuHooks(const std::string& addonId) : m_addonId(addonId) {}

    void AddHook(const PVR_MENUHOOK& addonHook);
    void Clear();

    std::vector<CPVRClientMenuHook> GetChannelHooks() const;
    std::vector<CPVRClientMenuHook> GetTimerHooks() const;
    std::vector<CPVRClientMenuHook> GetEpgHooks() const;
    std::vector<CPVRClientMenuHook> GetRecordingHooks() const;
    std::vector<CPVRClientMenuHook> GetDeletedRecordingHooks() const;
    std::vector<CPVRClientMenuHook> GetSettingsHooks() const;

  private:
    std::vector<CPVRClientMenuHook> GetHooks(
        const std::function<bool(const CPVRClientMenuHook& hook)>& function) const;

    std::string m_addonId;
    std::unique_ptr<std::vector<CPVRClientMenuHook>> m_hooks;
  };
}