kodi
GameClientTopology.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 "games/GameTypes.h"
12 #include "games/controllers/types/ControllerTree.h"
13 
14 #include <memory>
15 
16 namespace KODI
17 {
18 namespace GAME
19 {
20 
25 {
26 public:
27  CGameClientTopology() = default;
28  CGameClientTopology(GameClientPortVec ports, int playerLimit);
29 
30  void Clear();
31 
32  int GetPlayerLimit() const { return m_playerLimit; }
33 
34  const CControllerTree& GetControllerTree() const { return m_controllers; }
35  CControllerTree& GetControllerTree() { return m_controllers; }
36 
37  // Utility functions
38  static std::string MakeAddress(const std::string& baseAddress, const std::string& nodeId);
39  static std::pair<std::string, std::string> SplitAddress(const std::string& nodeAddress);
40 
41 private:
42  static CControllerTree GetControllerTree(const GameClientPortVec& ports);
43  static CPortNode GetPortNode(const GameClientPortPtr& port, const std::string& controllerAddress);
44  static CControllerNode GetControllerNode(const GameClientDevicePtr& device,
45  const std::string& portAddress);
46 
47  // Game API parameters
48  GameClientPortVec m_ports;
49  int m_playerLimit = -1;
50 
51  // Controller parameters
52  CControllerTree m_controllers;
53 };
54 
55 } // namespace GAME
56 } // namespace KODI
std::unique_ptr< CGameClientPort > GameClientPortPtr
Smart pointer to an input port for a game client (CGameClientPort)
Definition: GameTypes.h:43
Definition: GameClientTopology.h:24
Node in the controller tree.
Definition: ControllerNode.h:31
std::unique_ptr< CGameClientDevice > GameClientDevicePtr
Smart pointer to an input device for a game client (CGameClientDevice)
Definition: GameTypes.h:57
Collection of nodes that can be connected to this port.
Definition: PortNode.h:28
Definition: AudioDecoder.h:18
std::vector< GameClientPortPtr > GameClientPortVec
Vector of smart pointers to input ports for a game client (CGameClientPort)
Definition: GameTypes.h:50
A branch in the controller tree.
Definition: ControllerHub.h:25