The Battle for Wesnoth
1.17.12+dev
syncmp_handler.hpp
Go to the documentation of this file.
1
/*
2
Copyright (C) 2014 - 2022
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
*/
22
class
syncmp_handler
23
{
24
public
:
25
syncmp_handler
();
26
virtual
void
pull_remote_choice
() = 0;
27
virtual
void
send_user_choice
() = 0;
28
virtual
~syncmp_handler
();
29
};
30
31
class
syncmp_registry
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
};
syncmp_handler
Definition:
syncmp_handler.hpp:22
syncmp_handler::syncmp_handler
syncmp_handler()
Definition:
syncmp_handler.cpp:21
syncmp_handler::pull_remote_choice
virtual void pull_remote_choice()=0
syncmp_handler::~syncmp_handler
virtual ~syncmp_handler()
Definition:
syncmp_handler.cpp:26
syncmp_handler::send_user_choice
virtual void send_user_choice()=0
syncmp_registry
Definition:
syncmp_handler.hpp:31
syncmp_registry::handler_list
std::vector< syncmp_handler * > handler_list
Definition:
syncmp_handler.hpp:40
Generated by
1.8.13