The Battle for Wesnoth  1.15.1+dev
random_synced.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 "random.hpp"
18 #include "mt_rng.hpp"
19 
20 #include "utils/functional.hpp"
21 
22 /*
23 todo: use a boost::random based solution.
24 */
25 namespace randomness
26 {
27  class synced_rng : public randomness::rng
28  {
29  public:
30  synced_rng(std::function<std::string()> seed_generator);
31  virtual ~synced_rng();
32 
33  virtual bool is_networked() const;
34 
35  protected:
36  virtual uint32_t next_random_impl();
37  private:
38  void initialize();
40  std::function<std::string()> seed_generator_;
42  };
43 }
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:27