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 Federico Guerra
4 * and regents of the SIGNET lab, University of Padova
5 *
6 * Author: Federico Guerra - federico@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
22/*
23 * This software has been developed by Federico Guerra and SIGNET lab,
24 * University of Padova, in collaboration with the NATO Centre for
25 * Maritime Research and Experimentation (http://www.cmre.nato.int ;
26 * E-mail: pao@cmre.nato.int), whose support is gratefully acknowledged.
27 */
28
29
40#ifndef RANDOM_GENERATOR_DEFINITIONS_H
41#define RANDOM_GENERATOR_DEFINITIONS_H
42
43
44#include <cstdlib>
45#include <cassert>
46
47
48namespace woss {
49
50
57
58
59 public:
60
61
66 RandomGenerator( int s = 0 ) : seed(s), initialized(false) { }
67
71 virtual ~RandomGenerator() { }
72
73
79 virtual RandomGenerator* create( double seed ) { return new RandomGenerator(seed); }
80
85 virtual RandomGenerator* clone() const { return new RandomGenerator(*this); }
86
87
92 virtual bool isValid() const { return initialized; }
93
94
99 virtual void setSeed( int s ) { seed = s; }
100
105 virtual int getSeed() const { return seed; }
106
107
111 virtual void initialize();
112
113
118 virtual double getRand() const;
119
124 virtual int getRandInt() const;
125
126 protected:
127
128
132 int seed;
133
134
139
140
141 };
142
143
144}
145
146
147#endif /* RANDOM_GENERATOR_DEFINITIONS_H */
148
woss::RandomGenerator class
Definition random-generator-definitions.h:56
virtual void initialize()
Definition random-generator-definitions.cpp:47
bool initialized
Definition random-generator-definitions.h:138
virtual void setSeed(int s)
Definition random-generator-definitions.h:99
virtual bool isValid() const
Definition random-generator-definitions.h:92
virtual int getRandInt() const
Definition random-generator-definitions.cpp:65
virtual double getRand() const
Definition random-generator-definitions.cpp:55
virtual int getSeed() const
Definition random-generator-definitions.h:105
int seed
Definition random-generator-definitions.h:132
virtual ~RandomGenerator()
Definition random-generator-definitions.h:71
RandomGenerator(int s=0)
Definition random-generator-definitions.h:66
virtual RandomGenerator * create(double seed)
Definition random-generator-definitions.h:79
virtual RandomGenerator * clone() const
Definition random-generator-definitions.h:85