ns-3
|
hold a so-called 'global value'. More...
#include <global-value.h>
Public Types | |
typedef Vector::const_iterator | Iterator |
Public Member Functions | |
GlobalValue (std::string name, std::string help, const AttributeValue &initialValue, Ptr< const AttributeChecker > checker) | |
std::string | GetName (void) const |
std::string | GetHelp (void) const |
void | GetValue (AttributeValue &value) const |
Ptr< const AttributeChecker > | GetChecker (void) const |
bool | SetValue (const AttributeValue &value) |
void | ResetInitialValue (void) |
Static Public Member Functions | |
static void | Bind (std::string name, const AttributeValue &value) |
static bool | BindFailSafe (std::string name, const AttributeValue &value) |
static Iterator | Begin (void) |
static Iterator | End (void) |
static bool | GetValueByNameFailSafe (std::string name, AttributeValue &value) |
static void | GetValueByName (std::string name, AttributeValue &value) |
Friends | |
class | GlobalValueTestCase |
hold a so-called 'global value'.
Instances of this class are expected to be allocated as static global variables and should be used to store configurable global state. GlobalValues can be set directly by calling ns3::GlobalValue::SetValue but they can also be set through the NS_GLOBAL_VALUE environment variable. For example, NS_GLOBAL_VALUE='Name=Value;OtherName=OtherValue;' would set global values Name and OtherName to Value and OtherValue respectively.
Users of the ns3::CommandLine class also get the ability to set global values through commandline arguments to their program: –Name=Value will set global value Name to Value.
ns3::GlobalValue::GlobalValue | ( | std::string | name, |
std::string | help, | ||
const AttributeValue & | initialValue, | ||
Ptr< const AttributeChecker > | checker | ||
) |
name | the name of this global value. |
help | some help text which describes the purpose of this global value. |
initialValue | the value to assign to this global value during construction. |
checker | a pointer to an AttributeChecker which can verify that any user-supplied value to override the initial value matches the requested type constraints. |
References NS_FATAL_ERROR.
|
static |
Referenced by Bind(), BindFailSafe(), GetValueByNameFailSafe(), and ns3::Config::Reset().
|
static |
name | the name of the global value |
value | the value to set in the requested global value. |
Iterate over the set of GlobalValues until a matching name is found and then set its value with GlobalValue::SetValue.
This method cannot fail. It will crash if the input is not valid.
References Begin(), End(), and NS_FATAL_ERROR.
Referenced by ns3::Config::SetGlobal().
|
static |
name | the name of the global value |
value | the value to set in the requested global value. |
Iterate over the set of GlobalValues until a matching name is found and then set its value with GlobalValue::SetValue.
References Begin(), and End().
Referenced by ns3::Config::SetGlobalFailSafe().
|
static |
Referenced by Bind(), BindFailSafe(), GetValueByNameFailSafe(), and ns3::Config::Reset().
Ptr< const AttributeChecker > ns3::GlobalValue::GetChecker | ( | void | ) | const |
std::string ns3::GlobalValue::GetHelp | ( | void | ) | const |
std::string ns3::GlobalValue::GetName | ( | void | ) | const |
void ns3::GlobalValue::GetValue | ( | AttributeValue & | value | ) | const |
References NS_FATAL_ERROR, and ns3::AttributeValue::SerializeToString().
Referenced by ns3::Node::ChecksumEnabled(), and ns3::Simulator::SetImplementation().
|
static |
finds the GlobalValue with the given name and returns its value. This method cannot fail, i.e., it will trigger a NS_FATAL_ERROR if the requested GlobalValue is not found.
name | the name of the GlobalValue to be found |
value | where to store the value of the found GlobalValue |
References GetValueByNameFailSafe(), and NS_FATAL_ERROR.
|
static |
finds the GlobalValue with the given name and returns its value
name | the name of the GlobalValue to be found |
value | where to store the value of the found GlobalValue |
References Begin(), and End().
Referenced by GetValueByName().
bool ns3::GlobalValue::SetValue | ( | const AttributeValue & | value | ) |
value | the new value to set in this GlobalValue. |