digiKam
randomnumbergenerator.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2010-11-03
7  * Description : Generating random numbers
8  *
9  * Copyright (C) 2010-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10  *
11  * This program is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation;
14  * either version 2, or (at your option)
15  * any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * ============================================================ */
23 
24 #ifndef DIGIKAM_RANDOM_NUMBER_GENERATOR_H
25 #define DIGIKAM_RANDOM_NUMBER_GENERATOR_H
26 
27 // Qt includes
28 
29 #include <QByteArray>
30 
31 // Local includes
32 
33 #include "digikam_export.h"
34 
35 namespace Digikam
36 {
37 
38 class DIGIKAM_EXPORT NonDeterministicRandomData : public QByteArray
39 {
40 public:
41 
49  explicit NonDeterministicRandomData(int size);
50 };
51 
52 // --------------------------------------------------------------------
53 
63 class DIGIKAM_EXPORT RandomNumberGenerator
64 {
65 public:
66 
72  explicit RandomNumberGenerator();
74 
81  quint32 seedNonDeterministic();
82 
88  quint32 seedByTime();
89 
93  static quint32 nonDeterministicSeed();
94 
99  static quint32 timeSeed();
100 
108  void seed(quint32 seed);
109 
116  void reseed();
117 
122  quint32 currentSeed() const;
123 
129  int number(int min, int max);
130 
136  double number(double min, double max);
137 
143  bool yesOrNo(double p);
144 
145 private:
146 
147  // Disable
149  RandomNumberGenerator& operator=(const RandomNumberGenerator&) = delete;
150 
151 private:
152 
153  class Private;
154  Private* const d;
155 };
156 
157 } // namespace Digikam
158 
159 #endif // DIGIKAM_RANDOM_NUMBER_GENERATOR_H
Definition: randomnumbergenerator.h:39
Definition: randomnumbergenerator.h:64
Definition: datefolderview.cpp:43