World Ocean Simulation System (WOSS) library
random-generator-definitions.h
Go to the documentation of this file.
1/* WOSS - World Ocean Simulation System -
2 *
3 * Copyright (C) 2009 2025 Federico Guerra
4 * and regents of the SIGNET lab, University of Padova
5 *
6 * Author: Federico Guerra - WOSS@guerra-tlc.com
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation;
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
32#ifndef RANDOM_GENERATOR_DEFINITIONS_H
33#define RANDOM_GENERATOR_DEFINITIONS_H
34
35
36#include <memory>
37
38namespace woss {
39
46
47 public:
48
53 RandomGenerator( int s = 0 ) : seed(s), initialized(false) { }
54
55 virtual ~RandomGenerator() = default;
56
57 RandomGenerator(const RandomGenerator& copy) = default;
58
60
61 RandomGenerator& operator=(const RandomGenerator& copy) = default;
62
64
70 virtual std::unique_ptr<RandomGenerator> create( int seed ) const { return std::make_unique<RandomGenerator>(seed); }
71
76 virtual std::unique_ptr<RandomGenerator> clone() const { return std::make_unique<RandomGenerator>(*this); }
77
82 virtual bool isValid() const { return initialized; }
83
88 virtual void setSeed( int s ) { seed = s; }
89
94 virtual int getSeed() const { return seed; }
95
99 virtual void initialize();
100
105 virtual double getRand() const;
106
111 virtual int getRandInt() const;
112
113 protected:
114
118 int seed = 0;
122 bool initialized = false;
123
124 };
125
126}
127
128#endif /* RANDOM_GENERATOR_DEFINITIONS_H */
woss::RandomGenerator class
Definition random-generator-definitions.h:45
RandomGenerator(RandomGenerator &&tmp)=default
virtual void initialize()
Definition random-generator-definitions.cpp:41
bool initialized
Definition random-generator-definitions.h:122
RandomGenerator & operator=(RandomGenerator &&tmp)=default
virtual std::unique_ptr< RandomGenerator > create(int seed) const
Definition random-generator-definitions.h:70
virtual void setSeed(int s)
Definition random-generator-definitions.h:88
virtual bool isValid() const
Definition random-generator-definitions.h:82
virtual std::unique_ptr< RandomGenerator > clone() const
Definition random-generator-definitions.h:76
virtual int getRandInt() const
Definition random-generator-definitions.cpp:59
virtual double getRand() const
Definition random-generator-definitions.cpp:49
virtual int getSeed() const
Definition random-generator-definitions.h:94
int seed
Definition random-generator-definitions.h:118
RandomGenerator & operator=(const RandomGenerator &copy)=default
virtual ~RandomGenerator()=default
RandomGenerator(const RandomGenerator &copy)=default
RandomGenerator(int s=0)
Definition random-generator-definitions.h:53
Definition ac-toolbox-arr-asc-reader.h:44