author | Tom Henderson <tomh@tomh.org> |
Tue, 18 Jun 2013 09:46:32 -0700 | |
changeset 9838 | a8eaa0a01106 |
parent 9260 | src/core/model/random-variable-stream-helper.cc@9d47dca16cb3 |
child 10968 | 2d29fee2b7b8 |
permissions | -rw-r--r-- |
8877
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
2 |
/* |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
3 |
* Copyright (c) 2012 University of Washington |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
4 |
* |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
8 |
* |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
13 |
* |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
17 |
* |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
18 |
*/ |
9838
a8eaa0a01106
make core/helper directory; move random-stream helper code there
Tom Henderson <tomh@tomh.org>
parents:
9260
diff
changeset
|
19 |
#include "ns3/random-variable-stream.h" |
a8eaa0a01106
make core/helper directory; move random-stream helper code there
Tom Henderson <tomh@tomh.org>
parents:
9260
diff
changeset
|
20 |
#include "ns3/config.h" |
a8eaa0a01106
make core/helper directory; move random-stream helper code there
Tom Henderson <tomh@tomh.org>
parents:
9260
diff
changeset
|
21 |
#include "ns3/pointer.h" |
a8eaa0a01106
make core/helper directory; move random-stream helper code there
Tom Henderson <tomh@tomh.org>
parents:
9260
diff
changeset
|
22 |
#include "ns3/log.h" |
a8eaa0a01106
make core/helper directory; move random-stream helper code there
Tom Henderson <tomh@tomh.org>
parents:
9260
diff
changeset
|
23 |
#include "ns3/assert.h" |
8877
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
24 |
#include "random-variable-stream-helper.h" |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
25 |
|
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
26 |
NS_LOG_COMPONENT_DEFINE ("RandomVariableStreamHelper"); |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
27 |
|
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
28 |
namespace ns3 { |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
29 |
|
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
30 |
int64_t RandomVariableStreamHelper::AssignStreams (std::string path, int64_t stream) |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
31 |
{ |
9260
9d47dca16cb3
bug 1603: fix logging in static function
Tom Henderson <tomh@tomh.org>
parents:
9134
diff
changeset
|
32 |
NS_LOG_FUNCTION_NOARGS (); |
8877
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
33 |
NS_ASSERT (stream >= 0); |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
34 |
Config::MatchContainer mc = Config::LookupMatches (path); |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
35 |
int64_t i = 0; |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
36 |
for (Config::MatchContainer::Iterator mci = mc.Begin (); mci != mc.End (); ++mci, ++i) |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
37 |
{ |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
38 |
PointerValue ptr = mc.Get (i); |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
39 |
Ptr<RandomVariableStream> rvs = ptr.Get<RandomVariableStream> (); |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
40 |
NS_LOG_DEBUG ("RandomVariableStream found: " << rvs << "; setting stream to " << (stream + i)); |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
41 |
rvs->SetStream (stream + i); |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
42 |
} |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
43 |
return i; |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
44 |
} |
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
45 |
|
e322283a44dc
helper to use config paths to assign streams
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
46 |
} // namespace ns3 |