The Battle for Wesnoth  1.17.0-dev
syncmp_handler.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2021
3  by David White <dave@whitevine.net>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
18 #include<vector>
19 /*
20  Automatically registrates itself in the registry in the constructor.
21 */
23 {
24 public:
26  virtual void pull_remote_choice() = 0;
27  virtual void send_user_choice() = 0;
28  virtual ~syncmp_handler();
29 };
30 
32 {
33 public:
34  //called by get_user_choice while waiting for a remote user choice.
35  static void pull_remote_choice();
36  //called when get_user_choice was called and the client wants to send the choice to the other clients immideately
37  static void send_user_choice();
38 private:
39  friend class syncmp_handler;
40  typedef std::vector<syncmp_handler*> handler_list;
41  static void remove_handler(syncmp_handler* handler);
42  static void add_handler(syncmp_handler* handler);
43  static handler_list& handlers();
44 };
virtual void pull_remote_choice()=0
virtual ~syncmp_handler()
virtual void send_user_choice()=0
std::vector< syncmp_handler * > handler_list