supertux
integration.hpp
1 // SuperTux
2 // Copyright (C) 2020 A. Semphris <semphris@protonmail.com>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef HEADER_SUPERTUX_SDK_INTEGRATION_HPP
18 #define HEADER_SUPERTUX_SDK_INTEGRATION_HPP
19 
20 #include "config.h"
21 
22 #include <memory>
23 #include <string>
24 #include <vector>
25 
27 {
28 public:
30  m_details(),
31  m_party_count(0),
32  m_party_max(0),
33  m_timestamp(0)
34  {
35  }
36 
37  bool operator !=(const IntegrationStatus& is) const { return !operator==(is); }
38  bool operator ==(const IntegrationStatus& is) const {
39  if (m_details.size() != is.m_details.size())
40  return false;
41 
42  if (m_party_count != is.m_party_count ||
43  m_party_max != is.m_party_max ||
45  return false;
46 
47  for (int i = 0; i < static_cast<int>(m_details.size()); i++)
48  if (*(m_details.begin() + i) != *(is.m_details.begin() + i))
49  return false;
50 
51  return true;
52  }
53 
87  std::vector<std::string> m_details;
88 
91 
94 
101  long int m_timestamp;
102 };
103 
105 {
106 public:
107  Integration() {}
108  virtual ~Integration() {}
109 
110  static void setup();
111  static void init_all();
112  static void update_all();
113  static void close_all();
114 
115  static void update_status_all(IntegrationStatus status);
116 
117 public:
118  virtual void init() = 0;
119  virtual void update() = 0;
120  virtual void close() = 0;
121  virtual void update_status(IntegrationStatus status) = 0;
122 
123 private:
124  static std::vector<Integration*> sdks;
125  static IntegrationStatus current_status;
126 
127 private:
128  Integration(const Integration&) = delete;
129  Integration & operator=(const Integration&) = delete;
130 };
131 
132 #endif
133 
134 /* EOF */
long int m_timestamp
Any timestamp relative to the game.
Definition: integration.hpp:101
Definition: integration.hpp:104
int m_party_count
The amount of people in the group (0 = no party)
Definition: integration.hpp:90
std::vector< std::string > m_details
A list of lines describing what the player is doing.
Definition: integration.hpp:87
Definition: integration.hpp:26
int m_party_max
The maximum amount of people in the group (0 = no limit)
Definition: integration.hpp:93