A Discrete-Event Network Simulator
API
uniform-random-bit-generator.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023 Universita' degli Studi di Napoli Federico II
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Stefano Avallone <stavallo@unina.it>
18  */
19 #ifndef UNIFORM_RANDOM_BIT_GENERATOR_H
20 #define UNIFORM_RANDOM_BIT_GENERATOR_H
21 
22 #include "random-variable-stream.h"
23 
24 #include <limits>
25 
26 namespace ns3
27 {
28 
36 {
37  public:
40  {
41  }
42 
47  {
48  return m_rv;
49  }
50 
52  using result_type = uint32_t;
53 
57  static constexpr result_type min()
58  {
59  return 0;
60  }
61 
65  static constexpr result_type max()
66  {
68  }
69 
74  {
75  return m_rv->GetInteger(min(), max());
76  }
77 
78  private:
80 };
81 
82 } // namespace ns3
83 
84 #endif /* UNIFORM_RANDOM_BIT_GENERATOR_H */
#define max(a, b)
Definition: 80211b.c:42
Wraps a UniformRandomVariable into a class that meets the requirements of a UniformRandomBitGenerator...
Ptr< UniformRandomVariable > m_rv
ns-3 style uniform random variable
Ptr< UniformRandomVariable > GetRv() const
uint32_t result_type
Typedef needed to meet requirements. Result type must be an unsigned integer type.
static constexpr result_type max()
static constexpr result_type min()
The uniform distribution Random Number Generator (RNG).
uint32_t GetInteger(uint32_t min, uint32_t max)
Get the next random value drawn from the distribution.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition: object.h:579
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::RandomVariableStream declaration, and related classes.