Difference between revisions of "GlobalValues"
From Nsnam
(Initial page collecting tidbits on working w/ GlobalValue objects) |
m |
||
Line 1: | Line 1: | ||
− | + | === Doubles === | |
+ | |||
+ | To declare a double valued global parameter, do something like the following: | ||
+ | |||
+ | <code> | ||
+ | #include "ns3/global-value.h" | ||
+ | #include "ns3/double.h" | ||
+ | |||
+ | GlobalValue g_sampleInterval("SampleInterval", | ||
+ | "How frequently samples are made.", | ||
+ | Double(2.0), | ||
+ | MakeDoubleChecker<double>(0.0)); | ||
+ | </code> | ||
+ | |||
+ | To fetch the value, do something like: | ||
+ | |||
+ | <code> | ||
+ | Simulator::Schedule(Seconds(((Double)(g_sampleInterval | ||
+ | .GetValue())).Get()), | ||
+ | Example::Sample); | ||
+ | </code> |
Revision as of 19:30, 25 March 2008
Doubles
To declare a double valued global parameter, do something like the following:
- include "ns3/global-value.h"
- include "ns3/double.h"
GlobalValue g_sampleInterval("SampleInterval", "How frequently samples are made.", Double(2.0), MakeDoubleChecker<double>(0.0));
To fetch the value, do something like:
Simulator::Schedule(Seconds(((Double)(g_sampleInterval
.GetValue())).Get()), Example::Sample);