summaryrefslogtreecommitdiffstats
path: root/xbmc/games/addons/GameClientSubsystem.cpp
blob: 599125fef6e5d1be54a10cef4d4d7dabf62e8e50 (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
/*
 *  Copyright (C) 2017-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.
 */

#include "GameClientSubsystem.h"

#include "GameClient.h"
#include "GameClientProperties.h"
#include "addons/kodi-dev-kit/include/kodi/addon-instance/Game.h"
#include "games/addons/cheevos/GameClientCheevos.h"
#include "games/addons/input/GameClientInput.h"
#include "games/addons/streams/GameClientStreams.h"

using namespace KODI;
using namespace GAME;

CGameClientSubsystem::CGameClientSubsystem(CGameClient& gameClient,
                                           AddonInstance_Game& addonStruct,
                                           CCriticalSection& clientAccess)
  : m_gameClient(gameClient), m_struct(addonStruct), m_clientAccess(clientAccess)
{
}

CGameClientSubsystem::~CGameClientSubsystem() = default;

GameClientSubsystems CGameClientSubsystem::CreateSubsystems(CGameClient& gameClient,
                                                            AddonInstance_Game& gameStruct,
                                                            CCriticalSection& clientAccess)
{
  GameClientSubsystems subsystems = {};

  subsystems.Cheevos = std::make_unique<CGameClientCheevos>(gameClient, gameStruct);
  subsystems.Input.reset(new CGameClientInput(gameClient, gameStruct, clientAccess));
  subsystems.AddonProperties.reset(new CGameClientProperties(gameClient, *gameStruct.props));
  subsystems.Streams.reset(new CGameClientStreams(gameClient));

  return subsystems;
}

void CGameClientSubsystem::DestroySubsystems(GameClientSubsystems& subsystems)
{
  subsystems.Cheevos.reset();
  subsystems.Input.reset();
  subsystems.AddonProperties.reset();
  subsystems.Streams.reset();
}

CGameClientCheevos& CGameClientSubsystem::Cheevos() const
{
  return m_gameClient.Cheevos();
}

CGameClientInput& CGameClientSubsystem::Input() const
{
  return m_gameClient.Input();
}

CGameClientProperties& CGameClientSubsystem::AddonProperties() const
{
  return m_gameClient.AddonProperties();
}

CGameClientStreams& CGameClientSubsystem::Streams() const
{
  return m_gameClient.Streams();
}