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
random-variable-stream-helper.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2012 University of Washington
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
*/
7
#include "
random-variable-stream-helper.h
"
8
9
#include "ns3/assert.h"
10
#include "ns3/config.h"
11
#include "ns3/log.h"
12
#include "ns3/pointer.h"
13
#include "ns3/random-variable-stream.h"
14
15
/**
16
* @file
17
* @ingroup core-helpers
18
* @ingroup randomvariable
19
* ns3::RandomVariableStreamHelper implementation.
20
*/
21
22
namespace
ns3
23
{
24
25
NS_LOG_COMPONENT_DEFINE
(
"RandomVariableStreamHelper"
);
26
27
int64_t
28
RandomVariableStreamHelper::AssignStreams
(std::string path, int64_t stream)
29
{
30
NS_LOG_FUNCTION_NOARGS
();
31
NS_ASSERT
(stream >= 0);
32
Config::MatchContainer
mc
=
Config::LookupMatches
(path);
33
34
std::size_t
i
= 0;
35
for
(;
i
<
mc
.GetN(); ++
i
)
36
{
37
PointerValue
ptr =
mc
.
Get
(
i
);
38
Ptr<RandomVariableStream>
rvs
= ptr.
Get
<
RandomVariableStream
>();
39
NS_LOG_DEBUG
(
"RandomVariableStream found: "
<<
rvs
<<
"; setting stream to "
40
<< (stream +
i
));
41
rvs
->SetStream(stream +
i
);
42
}
43
return
i
;
44
}
45
46
}
// namespace ns3
ns3::Config::MatchContainer
hold a set of objects which match a specific search string.
Definition
config.h:184
ns3::PointerValue
AttributeValue implementation for Pointer.
Definition
pointer.h:37
ns3::PointerValue::Get
Ptr< T > Get() const
Definition
pointer.h:223
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
ptr.h:66
ns3::RandomVariableStreamHelper::AssignStreams
static int64_t AssignStreams(std::string path, int64_t stream)
This helper method can be used to configure the stream number for one or more RNG streams.
Definition
random-variable-stream-helper.cc:28
ns3::RandomVariableStream
The basic uniform Random Number Generator (RNG).
Definition
random-variable-stream.h:90
NS_ASSERT
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition
assert.h:55
ns3::Config::LookupMatches
MatchContainer LookupMatches(std::string path)
Definition
config.cc:991
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition
log.h:257
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition
log-macros-enabled.h:195
ns3::Create
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition
ptr.h:436
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
random-variable-stream-helper.h
ns3::RandomVariableStreamHelper declaration.
src
core
helper
random-variable-stream-helper.cc
Generated on Mon Dec 15 2025 15:21:50 for ns-3 by
1.9.8