The Battle for Wesnoth  1.17.0-dev
random_synced.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 "random.hpp"
19 #include "mt_rng.hpp"
20 
21 #include <functional>
22 
23 /*
24 todo: use a boost::random based solution.
25 */
26 namespace randomness
27 {
28  class synced_rng : public randomness::rng
29  {
30  public:
31  synced_rng(std::function<std::string()> seed_generator);
32  virtual ~synced_rng();
33 
34  virtual bool is_networked() const;
35 
36  protected:
37  virtual uint32_t next_random_impl();
38  private:
39  void initialize();
41  std::function<std::string()> seed_generator_;
43  };
44 }
virtual bool is_networked() const
Is this random source networked? If it is it&#39;s very important we do actually use this random source t...
virtual uint32_t next_random_impl()
std::function< std::string()> seed_generator_
synced_rng(std::function< std::string()> seed_generator)
this class does not give synced random results derived classes might do.
Definition: random.hpp:28