summaryrefslogtreecommitdiffstats
path: root/xbmc/pvr/channels/PVRChannelGroupInternal.h
blob: 5f8a06d9a7e0c2ea041014d5e1cdf91e080f0208 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
 *  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 "pvr/channels/PVRChannelGroup.h"

#include <memory>
#include <vector>

namespace PVR
{
  enum class PVREvent;

  class CPVRChannel;
  class CPVRChannelNumber;

  class CPVRChannelGroupInternal : public CPVRChannelGroup
  {
  public:
    CPVRChannelGroupInternal() = delete;

    /*!
     * @brief Create a new internal channel group.
     * @param bRadio True if this group holds radio channels.
     */
    explicit CPVRChannelGroupInternal(bool bRadio);

    /*!
     * @brief Create a new internal channel group.
     * @param path The path for the new group.
     */
    explicit CPVRChannelGroupInternal(const CPVRChannelsPath& path);

    ~CPVRChannelGroupInternal() override;

    /**
     * @brief The amount of channels in this container.
     * @return The amount of channels in this container.
     */
    size_t GetNumHiddenChannels() const override { return m_iHiddenChannels; }

    /*!
     * @see CPVRChannelGroup::IsGroupMember
     */
    bool IsGroupMember(const std::shared_ptr<CPVRChannel>& channel) const override;

    /*!
     * @see CPVRChannelGroup::AppendToGroup
     */
    bool AppendToGroup(const std::shared_ptr<CPVRChannel>& channel) override;

    /*!
     * @see CPVRChannelGroup::RemoveFromGroup
     */
    bool RemoveFromGroup(const std::shared_ptr<CPVRChannel>& channel) override;

    /*!
     * @brief Check whether the group name is still correct after the language setting changed.
     */
    void CheckGroupName();

    /*!
     * @brief Create an EPG table for each channel.
     * @brief bForce Create the tables, even if they already have been created before.
     * @return True if all tables were created successfully, false otherwise.
     */
    bool CreateChannelEpgs(bool bForce = false) override;

  protected:
    /*!
     * @brief Remove deleted group members from this group. Delete stale channels.
     * @param groupMembers The group members to use to update this list.
     * @return The removed members .
     */
    std::vector<std::shared_ptr<CPVRChannelGroupMember>> RemoveDeletedGroupMembers(
        const std::vector<std::shared_ptr<CPVRChannelGroupMember>>& groupMembers) override;

    /*!
     * @brief Update data with 'all channels' group members from the given clients, sync with local data.
     * @param clients The clients to fetch data from. Leave empty to fetch data from all created clients.
     * @return True on success, false otherwise.
     */
    bool UpdateFromClients(const std::vector<std::shared_ptr<CPVRClient>>& clients) override;

    /*!
     * @brief Load the channels from the database.
     * @param channels All available channels.
     * @param clients The PVR clients data should be loaded for. Leave empty for all clients.
     * @return True when loaded successfully, false otherwise.
     */
    bool LoadFromDatabase(
        const std::map<std::pair<int, int>, std::shared_ptr<CPVRChannel>>& channels,
        const std::vector<std::shared_ptr<CPVRClient>>& clients) override;

    /*!
     * @brief Clear all data.
     */
    void Unload() override;

    /*!
     * @brief Update the vfs paths of all channels.
     */
    void UpdateChannelPaths();

    size_t m_iHiddenChannels; /*!< the amount of hidden channels in this container */

  private:
    void OnPVRManagerEvent(const PVREvent& event);
  };
}