A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
35
class
UniformRandomBitGenerator
36
{
37
public
:
38
UniformRandomBitGenerator
()
39
:
m_rv
(
CreateObject
<
UniformRandomVariable
>())
40
{
41
}
42
46
Ptr<UniformRandomVariable>
GetRv
()
const
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
{
67
return
std::numeric_limits<result_type>::max
();
68
}
69
73
result_type
operator()
()
74
{
75
return
m_rv
->
GetInteger
(
min
(),
max
());
76
}
77
78
private
:
79
Ptr<UniformRandomVariable>
m_rv
;
80
};
81
82
}
// namespace ns3
83
84
#endif
/* UNIFORM_RANDOM_BIT_GENERATOR_H */
max
#define max(a, b)
Definition:
80211b.c:42
ns3::Ptr< UniformRandomVariable >
ns3::UniformRandomBitGenerator
Wraps a UniformRandomVariable into a class that meets the requirements of a UniformRandomBitGenerator...
Definition:
uniform-random-bit-generator.h:36
ns3::UniformRandomBitGenerator::m_rv
Ptr< UniformRandomVariable > m_rv
ns-3 style uniform random variable
Definition:
uniform-random-bit-generator.h:79
ns3::UniformRandomBitGenerator::operator()
result_type operator()()
Definition:
uniform-random-bit-generator.h:73
ns3::UniformRandomBitGenerator::GetRv
Ptr< UniformRandomVariable > GetRv() const
Definition:
uniform-random-bit-generator.h:46
ns3::UniformRandomBitGenerator::result_type
uint32_t result_type
Typedef needed to meet requirements. Result type must be an unsigned integer type.
Definition:
uniform-random-bit-generator.h:52
ns3::UniformRandomBitGenerator::max
static constexpr result_type max()
Definition:
uniform-random-bit-generator.h:65
ns3::UniformRandomBitGenerator::UniformRandomBitGenerator
UniformRandomBitGenerator()
Definition:
uniform-random-bit-generator.h:38
ns3::UniformRandomBitGenerator::min
static constexpr result_type min()
Definition:
uniform-random-bit-generator.h:57
ns3::UniformRandomVariable
The uniform distribution Random Number Generator (RNG).
Definition:
random-variable-stream.h:235
ns3::UniformRandomVariable::GetInteger
uint32_t GetInteger(uint32_t min, uint32_t max)
Get the next random value drawn from the distribution.
Definition:
random-variable-stream.cc:208
ns3::CreateObject
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition:
object.h:579
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
random-variable-stream.h
ns3::RandomVariableStream declaration, and related classes.
src
core
model
uniform-random-bit-generator.h
Generated on Sun Mar 3 2024 17:10:56 for ns-3 by
1.9.1