xbmc
MultiProvider.h
1 /*
2  * Copyright (C) 2013-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 "IListProvider.h"
12 #include "threads/CriticalSection.h"
13 
14 #include <map>
15 #include <vector>
16 
17 typedef std::unique_ptr<IListProvider> IListProviderPtr;
18 
24 {
25 public:
26  CMultiProvider(const TiXmlNode *first, int parentID);
27  explicit CMultiProvider(const CMultiProvider& other);
28 
29  // Implementation of IListProvider
30  std::unique_ptr<IListProvider> Clone() override;
31  bool Update(bool forceRefresh) override;
32  void Fetch(std::vector<CGUIListItemPtr> &items) override;
33  bool IsUpdating() const override;
34  void Reset() override;
35  bool OnClick(const CGUIListItemPtr &item) override;
36  bool OnInfo(const CGUIListItemPtr &item) override;
37  bool OnContextMenu(const CGUIListItemPtr &item) override;
38 
39 protected:
40  typedef size_t item_key_type;
41  static item_key_type GetItemKey(CGUIListItemPtr const &item);
42  std::vector<IListProviderPtr> m_providers;
43  std::map<item_key_type, IListProvider*> m_itemMap;
44  CCriticalSection m_section; // protects m_itemMap
45 };
An interface for providing lists to UI containers.
Definition: IListProvider.h:22
A listprovider that handles multiple individual providers.
Definition: MultiProvider.h:23
std::unique_ptr< IListProvider > Clone() override
Create an instance of the derived class. Allows for polymorphic copies.
Definition: MultiProvider.cpp:36
void Reset() override
Reset the current list of items. Derived classes may choose to ignore this.
Definition: MultiProvider.cpp:76
bool OnClick(const CGUIListItemPtr &item) override
Click event on an item.
Definition: MultiProvider.cpp:87
bool OnInfo(const CGUIListItemPtr &item) override
Open the info dialog for an item provided by this IListProvider.
Definition: MultiProvider.cpp:98
bool IsUpdating() const override
Check whether the list provider is updating content.
Definition: MultiProvider.cpp:68
bool OnContextMenu(const CGUIListItemPtr &item) override
Open the context menu for an item provided by this IListProvider.
Definition: MultiProvider.cpp:109
bool Update(bool forceRefresh) override
Update the list content.
Definition: MultiProvider.cpp:41
void Fetch(std::vector< CGUIListItemPtr > &items) override
Fetch the current list of items.
Definition: MultiProvider.cpp:49