A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
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
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Stefano Avallone <stavallo@unina.it>
7
*/
8
#ifndef UNIFORM_RANDOM_BIT_GENERATOR_H
9
#define UNIFORM_RANDOM_BIT_GENERATOR_H
10
11
#include "
random-variable-stream.h
"
12
13
#include <limits>
14
15
namespace
ns3
16
{
17
18
/**
19
* Wraps a UniformRandomVariable into a class that meets the requirements of a
20
* UniformRandomBitGenerator as specified by the C++11 standard, thus allowing
21
* the usage of ns-3 style UniformRandomVariables as generators in the functions
22
* of the standard random library.
23
*/
24
class
UniformRandomBitGenerator
25
{
26
public
:
27
UniformRandomBitGenerator
()
28
:
m_rv
(
CreateObject
<
UniformRandomVariable
>())
29
{
30
}
31
32
/**
33
* \return the ns-3 style uniform random variable
34
*/
35
Ptr<UniformRandomVariable>
GetRv
()
const
36
{
37
return
m_rv
;
38
}
39
40
/// Typedef needed to meet requirements. Result type must be an unsigned integer type.
41
using
result_type
=
uint32_t
;
42
43
/**
44
* \return the smallest value that operator() may return
45
*/
46
static
constexpr
result_type
min
()
47
{
48
return
0;
49
}
50
51
/**
52
* \return the largest value that operator() may return
53
*/
54
static
constexpr
result_type
max
()
55
{
56
return
std::numeric_limits<result_type>::max();
57
}
58
59
/**
60
* \return a value in the closed interval [min(), max()]
61
*/
62
result_type
operator()
()
63
{
64
return
m_rv
->GetInteger(
min
(),
max
());
65
}
66
67
private
:
68
Ptr<UniformRandomVariable>
m_rv
;
//!< ns-3 style uniform random variable
69
};
70
71
}
// namespace ns3
72
73
#endif
/* UNIFORM_RANDOM_BIT_GENERATOR_H */
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::UniformRandomBitGenerator
Wraps a UniformRandomVariable into a class that meets the requirements of a UniformRandomBitGenerator...
Definition
uniform-random-bit-generator.h:25
ns3::UniformRandomBitGenerator::m_rv
Ptr< UniformRandomVariable > m_rv
ns-3 style uniform random variable
Definition
uniform-random-bit-generator.h:68
ns3::UniformRandomBitGenerator::operator()
result_type operator()()
Definition
uniform-random-bit-generator.h:62
ns3::UniformRandomBitGenerator::max
static constexpr result_type max()
Definition
uniform-random-bit-generator.h:54
ns3::UniformRandomBitGenerator::UniformRandomBitGenerator
UniformRandomBitGenerator()
Definition
uniform-random-bit-generator.h:27
ns3::UniformRandomBitGenerator::min
static constexpr result_type min()
Definition
uniform-random-bit-generator.h:46
ns3::UniformRandomBitGenerator::GetRv
Ptr< UniformRandomVariable > GetRv() const
Definition
uniform-random-bit-generator.h:35
ns3::UniformRandomVariable
The uniform distribution Random Number Generator (RNG).
Definition
random-variable-stream.h:224
uint32_t
ns3::CreateObject
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition
object.h:619
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 Fri Nov 8 2024 13:58:59 for ns-3 by
1.11.0