kodi
GUIControlLookup.h
1 /*
2  * Copyright (C) 2017-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 "GUIControl.h"
12 
14 {
15 public:
16  CGUIControlLookup() = default;
17  CGUIControlLookup(int parentID, int controlID, float posX, float posY, float width, float height)
18  : CGUIControl(parentID, controlID, posX, posY, width, height) {}
19  explicit CGUIControlLookup(const CGUIControlLookup& from);
20  ~CGUIControlLookup(void) override = default;
21 
22  CGUIControl *GetControl(int id, std::vector<CGUIControl*> *idCollector = nullptr) override;
23 protected:
24  typedef std::multimap<int, CGUIControl *> LookupMap;
25 
33  bool IsValidControl(const CGUIControl *control) const;
34  std::pair<LookupMap::const_iterator, LookupMap::const_iterator> GetLookupControls(int controlId) const
35  {
36  return m_lookup.equal_range(controlId);
37  };
38 
39  // fast lookup by id
40  void AddLookup(CGUIControl *control);
41  void RemoveLookup(CGUIControl *control);
42  void RemoveLookup();
43  const LookupMap &GetLookup() const { return m_lookup; }
44  void ClearLookup() { m_lookup.clear(); }
45 private:
46  LookupMap m_lookup;
47 };
Definition: GUIControlLookup.h:13
bool IsValidControl(const CGUIControl *control) const
Check whether a given control is valid Runs through controls and returns whether this control is vali...
Definition: GUIControlLookup.cpp:40
Base class for controls.
Definition: GUIControl.h:83