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