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) | |
Ptr< const AttributeChecker > | GetChecker (void) const |
std::string | GetHelp (void) const |
std::string | GetName (void) const |
void | GetValue (AttributeValue &value) const |
void | ResetInitialValue (void) |
bool | SetValue (const AttributeValue &value) |
Static Public Member Functions | |
static Iterator | Begin (void) |
static void | Bind (std::string name, const AttributeValue &value) |
static bool | BindFailSafe (std::string name, const AttributeValue &value) |
static Iterator | End (void) |
static void | GetValueByName (std::string name, AttributeValue &value) |
finds the GlobalValue with the given name and returns its value. More... | |
static bool | GetValueByNameFailSafe (std::string name, AttributeValue &value) |
finds the GlobalValue with the given name and returns its value More... | |
Private Types | |
typedef std::vector< GlobalValue * > | Vector |
Private Member Functions | |
void | InitializeFromEnv (void) |
Static Private Member Functions | |
static Vector * | GetVector (void) |
Private Attributes | |
Ptr< const AttributeChecker > | m_checker |
Ptr< AttributeValue > | m_currentValue |
std::string | m_help |
Ptr< AttributeValue > | m_initialValue |
std::string | m_name |
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.
Definition at line 48 of file global-value.h.
typedef Vector::const_iterator ns3::GlobalValue::Iterator |
Definition at line 52 of file global-value.h.
|
private |
Definition at line 50 of file global-value.h.
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. |
Definition at line 36 of file global-value.cc.
References GetVector(), InitializeFromEnv(), m_checker, m_currentValue, m_initialValue, NS_FATAL_ERROR, and NS_LOG_FUNCTION.
|
static |
Definition at line 181 of file global-value.cc.
References GetVector(), and NS_LOG_FUNCTION_NOARGS.
Referenced by Bind(), BindFailSafe(), GetValueByNameFailSafe(), ns3::RawTextConfigSave::Global(), ns3::XmlConfigSave::Global(), PrintAllGlobals(), ns3::CommandLine::PrintGlobals(), 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.
Definition at line 149 of file global-value.cc.
References Begin(), End(), NS_FATAL_ERROR, and NS_LOG_FUNCTION.
Referenced by ns3::MpiInterface::Enable(), ns3::Config::SetGlobal(), and test().
|
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.
Definition at line 167 of file global-value.cc.
References Begin(), End(), and NS_LOG_FUNCTION.
Referenced by ns3::Config::SetGlobalFailSafe().
|
static |
Definition at line 188 of file global-value.cc.
References GetVector(), and NS_LOG_FUNCTION_NOARGS.
Referenced by Bind(), BindFailSafe(), GetValueByNameFailSafe(), ns3::RawTextConfigSave::Global(), ns3::XmlConfigSave::Global(), PrintAllGlobals(), ns3::CommandLine::PrintGlobals(), and ns3::Config::Reset().
Ptr< const AttributeChecker > ns3::GlobalValue::GetChecker | ( | void | ) | const |
Definition at line 127 of file global-value.cc.
References m_checker, and NS_LOG_FUNCTION.
std::string ns3::GlobalValue::GetHelp | ( | void | ) | const |
Definition at line 105 of file global-value.cc.
References m_help, and NS_LOG_FUNCTION_NOARGS.
std::string ns3::GlobalValue::GetName | ( | void | ) | const |
Definition at line 99 of file global-value.cc.
References m_name, and NS_LOG_FUNCTION_NOARGS.
void ns3::GlobalValue::GetValue | ( | AttributeValue & | value | ) | const |
Definition at line 111 of file global-value.cc.
References m_checker, m_currentValue, m_name, NS_FATAL_ERROR, NS_LOG_FUNCTION, and ns3::StringValue::Set().
Referenced by ns3::Node::ChecksumEnabled(), GlobalValueTestCase::DoRun(), ns3::GetImpl(), ns3::RngSeedManager::GetRun(), ns3::RngSeedManager::GetSeed(), 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 |
Definition at line 217 of file global-value.cc.
References GetValueByNameFailSafe(), NS_FATAL_ERROR, and NS_LOG_FUNCTION.
|
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 |
Definition at line 202 of file global-value.cc.
References Begin(), End(), and NS_LOG_FUNCTION.
Referenced by ns3::MpiInterface::Enable(), and GetValueByName().
|
staticprivate |
Definition at line 227 of file global-value.cc.
References NS_LOG_FUNCTION_NOARGS.
Referenced by Begin(), End(), and GlobalValue().
|
private |
Definition at line 61 of file global-value.cc.
References m_checker, m_currentValue, m_initialValue, m_name, and NS_LOG_FUNCTION.
Referenced by GlobalValue().
void ns3::GlobalValue::ResetInitialValue | ( | void | ) |
Definition at line 195 of file global-value.cc.
References m_currentValue, m_initialValue, and NS_LOG_FUNCTION.
bool ns3::GlobalValue::SetValue | ( | const AttributeValue & | value | ) |
value | the new value to set in this GlobalValue. |
Definition at line 135 of file global-value.cc.
References m_checker, m_currentValue, and NS_LOG_FUNCTION.
Referenced by VanetRoutingExperiment::SetGlobalsFromConfig().
|
friend |
Definition at line 145 of file global-value.h.
|
private |
Definition at line 153 of file global-value.h.
Referenced by GetChecker(), GetValue(), GlobalValue(), InitializeFromEnv(), and SetValue().
|
private |
Definition at line 152 of file global-value.h.
Referenced by GetValue(), GlobalValue(), InitializeFromEnv(), ResetInitialValue(), and SetValue().
|
private |
Definition at line 150 of file global-value.h.
Referenced by GetHelp().
|
private |
Definition at line 151 of file global-value.h.
Referenced by GlobalValue(), InitializeFromEnv(), and ResetInitialValue().
|
private |
Definition at line 149 of file global-value.h.
Referenced by GetName(), GetValue(), and InitializeFromEnv().