Merge pull request #26302 from ksooo/pvr-fix-recordings-playback
[xbmc.git] / xbmc / windowing / WindowSystemFactory.cpp
blob9f6dc84ed08e0e054d3a5d6278e96a149a277728
1 /*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #include "WindowSystemFactory.h"
11 #include <algorithm>
13 using namespace KODI::WINDOWING;
15 std::list<std::pair<std::string, std::function<std::unique_ptr<CWinSystemBase>()>>>
16 CWindowSystemFactory::m_windowSystems;
18 std::list<std::string> CWindowSystemFactory::GetWindowSystems()
20 std::list<std::string> available;
21 for (const auto& windowSystem : m_windowSystems)
22 available.emplace_back(windowSystem.first);
24 return available;
27 std::unique_ptr<CWinSystemBase> CWindowSystemFactory::CreateWindowSystem(const std::string& name)
29 auto windowSystem =
30 std::find_if(m_windowSystems.begin(), m_windowSystems.end(),
31 [&name](auto& windowSystem) { return windowSystem.first == name; });
32 if (windowSystem != m_windowSystems.end())
33 return windowSystem->second();
35 return nullptr;
38 void CWindowSystemFactory::RegisterWindowSystem(
39 const std::function<std::unique_ptr<CWinSystemBase>()>& createFunction, const std::string& name)
41 m_windowSystems.emplace_back(name, createFunction);