xbmc
PVRChannelGroupsContainer.h
1 /*
2  * Copyright (C) 2012-2018 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 #include "threads/CriticalSection.h"
12 
13 #include <memory>
14 #include <vector>
15 
16 namespace PVR
17 {
18  class CPVRChannel;
19  class CPVRChannelGroup;
20  class CPVRChannelGroupMember;
21  class CPVRChannelGroups;
22  class CPVRClient;
23  class CPVREpgInfoTag;
24 
26  {
27  public:
32 
37 
43  bool Update(const std::vector<std::shared_ptr<CPVRClient>>& clients);
44 
51  bool UpdateFromClients(const std::vector<std::shared_ptr<CPVRClient>>& clients,
52  bool bChannelsOnly = false);
53 
57  void Unload();
58 
63  CPVRChannelGroups* GetTV() const { return Get(false); }
64 
69  CPVRChannelGroups* GetRadio() const { return Get(true); }
70 
76  CPVRChannelGroups* Get(bool bRadio) const;
77 
82  std::shared_ptr<CPVRChannelGroup> GetGroupAllTV() const { return GetGroupAll(false); }
83 
88  std::shared_ptr<CPVRChannelGroup> GetGroupAllRadio() const { return GetGroupAll(true); }
89 
95  std::shared_ptr<CPVRChannelGroup> GetGroupAll(bool bRadio) const;
96 
102  std::shared_ptr<CPVRChannelGroup> GetByIdFromAll(int iGroupId) const;
103 
109  std::shared_ptr<CPVRChannel> GetChannelById(int iChannelId) const;
110 
116  std::shared_ptr<CPVRChannel> GetChannelForEpgTag(const std::shared_ptr<CPVREpgInfoTag>& epgTag) const;
117 
123  std::shared_ptr<CPVRChannel> GetByPath(const std::string& strPath) const;
124 
130  std::shared_ptr<CPVRChannelGroupMember> GetChannelGroupMemberByPath(
131  const std::string& strPath) const;
132 
139  std::shared_ptr<CPVRChannel> GetByUniqueID(int iUniqueChannelId, int iClientID) const;
140 
145  std::shared_ptr<CPVRChannelGroupMember> GetLastPlayedChannelGroupMember() const;
146 
151  int CleanupCachedImages();
152 
153  private:
154  CPVRChannelGroupsContainer& operator=(const CPVRChannelGroupsContainer&) = delete;
156 
162  bool LoadFromDatabase(const std::vector<std::shared_ptr<CPVRClient>>& clients);
163 
164  CPVRChannelGroups* m_groupsRadio;
165  CPVRChannelGroups* m_groupsTV;
166  CCriticalSection m_critSection;
167  bool m_bIsUpdating = false;
168  };
169 }
CPVRChannelGroups * GetTV() const
Get the TV channel groups.
Definition: PVRChannelGroupsContainer.h:63
virtual ~CPVRChannelGroupsContainer()
Destroy this container.
Definition: PVRChannelGroupsContainer.cpp:28
Definition: ContextMenuManager.h:24
std::shared_ptr< CPVRChannel > GetChannelForEpgTag(const std::shared_ptr< CPVREpgInfoTag > &epgTag) const
Get the channel for the given epg tag.
Definition: PVRChannelGroupsContainer.cpp:100
std::shared_ptr< CPVRChannelGroup > GetGroupAllRadio() const
Get the group containing all radio channels.
Definition: PVRChannelGroupsContainer.h:88
std::shared_ptr< CPVRChannelGroup > GetGroupAll(bool bRadio) const
Get the group containing all TV or radio channels.
Definition: PVRChannelGroupsContainer.cpp:77
std::shared_ptr< CPVRChannel > GetByPath(const std::string &strPath) const
Get a channel given it&#39;s path.
Definition: PVRChannelGroupsContainer.cpp:118
CPVRChannelGroups * GetRadio() const
Get the radio channel groups.
Definition: PVRChannelGroupsContainer.h:69
A container class for channel groups.
Definition: PVRChannelGroups.h:30
Definition: PVRChannelGroupsContainer.h:25
std::shared_ptr< CPVRChannelGroupMember > GetChannelGroupMemberByPath(const std::string &strPath) const
Get a channel group member given it&#39;s path.
Definition: PVRChannelGroupsContainer.cpp:108
std::shared_ptr< CPVRChannelGroup > GetGroupAllTV() const
Get the group containing all TV channels.
Definition: PVRChannelGroupsContainer.h:82
std::shared_ptr< CPVRChannelGroup > GetByIdFromAll(int iGroupId) const
Get a group given it&#39;s ID.
Definition: PVRChannelGroupsContainer.cpp:82
std::shared_ptr< CPVRChannel > GetChannelById(int iChannelId) const
Get a channel given it&#39;s database ID.
Definition: PVRChannelGroupsContainer.cpp:91
std::shared_ptr< CPVRChannel > GetByUniqueID(int iUniqueChannelId, int iClientID) const
Get a channel given it&#39;s channel ID from all containers.
Definition: PVRChannelGroupsContainer.cpp:127
CPVRChannelGroupsContainer()
Create a new container for all channel groups.
Definition: PVRChannelGroupsContainer.cpp:22
bool Update(const std::vector< std::shared_ptr< CPVRClient >> &clients)
Update all channel groups and all channels from PVR database and from given clients.
Definition: PVRChannelGroupsContainer.cpp:35
std::shared_ptr< CPVRChannelGroupMember > GetLastPlayedChannelGroupMember() const
Get the channel group member that was played last.
Definition: PVRChannelGroupsContainer.cpp:143
void Unload()
Unload and destruct all channel groups and all channels in them.
Definition: PVRChannelGroupsContainer.cpp:66
bool UpdateFromClients(const std::vector< std::shared_ptr< CPVRClient >> &clients, bool bChannelsOnly=false)
Update data with groups and channels from the given clients, sync with local data.
Definition: PVRChannelGroupsContainer.cpp:46
int CleanupCachedImages()
Erase stale texture db entries and image files.
Definition: PVRChannelGroupsContainer.cpp:157
CPVRChannelGroups * Get(bool bRadio) const
Get the radio or TV channel groups.
Definition: PVRChannelGroupsContainer.cpp:72