| 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 <memory> |
| 12 |
|
| 13 |
struct AddonInstance_Game; |
| 14 |
class CCriticalSection; |
| 15 |
|
| 16 |
namespace KODI |
| 17 |
{ |
| 18 |
namespace GAME |
| 19 |
{ |
| 20 |
class CGameClient; |
| 21 |
class CGameClientCheevos; |
| 22 |
class CGameClientInput; |
| 23 |
class CGameClientProperties; |
| 24 |
class CGameClientStreams; |
| 25 |
|
| 26 |
struct GameClientSubsystems |
| 27 |
{ |
| 28 |
std::unique_ptr<CGameClientCheevos> Cheevos; |
| 29 |
std::unique_ptr<CGameClientInput> Input; |
| 30 |
std::unique_ptr<CGameClientProperties> AddonProperties; |
| 31 |
std::unique_ptr<CGameClientStreams> Streams; |
| 32 |
}; |
| 33 |
|
| 34 |
/*! |
| 35 |
* \ingroup games |
| 36 |
* |
| 37 |
* \brief Base class for game client subsystems |
| 38 |
*/ |
| 39 |
class CGameClientSubsystem |
| 40 |
{ |
| 41 |
protected: |
| 42 |
CGameClientSubsystem(CGameClient& gameClient, |
| 43 |
AddonInstance_Game& addonStruct, |
| 44 |
CCriticalSection& clientAccess); |
| 45 |
|
| 46 |
virtual ~CGameClientSubsystem(); |
| 47 |
|
| 48 |
public: |
| 49 |
/*! |
| 50 |
* \brief Create a struct with the allocated subsystems |
| 51 |
* |
| 52 |
* \param gameClient The owner of the subsystems |
| 53 |
* \param gameStruct The game client's add-on function table |
| 54 |
* \param clientAccess Mutex guarding client function access |
| 55 |
* |
| 56 |
* \return A fully-allocated GameClientSubsystems struct |
| 57 |
*/ |
| 58 |
static GameClientSubsystems CreateSubsystems(CGameClient& gameClient, |
| 59 |
AddonInstance_Game& gameStruct, |
| 60 |
CCriticalSection& clientAccess); |
| 61 |
|
| 62 |
/*! |
| 63 |
* \brief Deallocate subsystems |
| 64 |
* |
| 65 |
* \param subsystems The subsystems created by CreateSubsystems() |
| 66 |
*/ |
| 67 |
static void DestroySubsystems(GameClientSubsystems& subsystems); |
| 68 |
|
| 69 |
protected: |
| 70 |
// Subsystems |
| 71 |
CGameClientCheevos& Cheevos() const; |
| 72 |
CGameClientInput& Input() const; |
| 73 |
CGameClientProperties& AddonProperties() const; |
| 74 |
CGameClientStreams& Streams() const; |
| 75 |
|
| 76 |
// Construction parameters |
| 77 |
CGameClient& m_gameClient; |
| 78 |
AddonInstance_Game& m_struct; |
| 79 |
CCriticalSection& m_clientAccess; |
| 80 |
}; |
| 81 |
|
| 82 |
} // namespace GAME |
| 83 |
} // namespace KODI |