Hold a so-called 'global value'. More...
#include "global-value.h"
Collaboration diagram for ns3::GlobalValue:Public Types | |
| typedef Vector::const_iterator | Iterator |
| Iterator type for the list of all global values. | |
Public Member Functions | |
| GlobalValue (std::string name, std::string help, const AttributeValue &initialValue, Ptr< const AttributeChecker > checker) | |
| Constructor. | |
| Ptr< const AttributeChecker > | GetChecker () const |
| Get the AttributeChecker. | |
| std::string | GetHelp () const |
| Get the help string. | |
| std::string | GetName () const |
| Get the name. | |
| void | GetValue (AttributeValue &value) const |
| Get the value. | |
| void | ResetInitialValue () |
| Reset to the initial value. | |
| bool | SetValue (const AttributeValue &value) |
| Set the value of this GlobalValue. | |
Static Public Member Functions | |
| static Iterator | Begin () |
| The Begin iterator. | |
| static void | Bind (std::string name, const AttributeValue &value) |
| Iterate over the set of GlobalValues until a matching name is found and then set its value with GlobalValue::SetValue. | |
| static bool | BindFailSafe (std::string name, const AttributeValue &value) |
| Iterate over the set of GlobalValues until a matching name is found and then set its value with GlobalValue::SetValue. | |
| static Iterator | End () |
| The End iterator. | |
| static void | GetValueByName (std::string name, AttributeValue &value) |
| Finds the GlobalValue with the given name and returns its value. | |
| static bool | GetValueByNameFailSafe (std::string name, AttributeValue &value) |
| Finds the GlobalValue with the given name and returns its value. | |
Private Types | |
| typedef std::vector< GlobalValue * > | Vector |
| Container type for holding all the GlobalValues. | |
Private Member Functions | |
| void | InitializeFromEnv () |
Initialize from the NS_GLOBAL_VALUE environment variable. | |
Static Private Member Functions | |
| static Vector * | GetVector () |
| Get the static vector of all GlobalValues. | |
Private Attributes | |
| Ptr< const AttributeChecker > | m_checker |
| The AttributeChecker for this GlobalValue. | |
| Ptr< AttributeValue > | m_currentValue |
| The current value. | |
| std::string | m_help |
| The help string. | |
| Ptr< AttributeValue > | m_initialValue |
| The initial value. | |
| std::string | m_name |
| The name of this GlobalValue. | |
Friends | |
| class | tests::GlobalValueTestCase |
| Test case needs direct access to GetVector() | |
Hold a so-called 'global value'.
A GlobalValue will get its value from (in order):
NS_GLOBAL_VALUE environment variable,Instances of this class are expected to be allocated as static global variables and should be used to store configurable global state. For example:
GlobalValues can be set directly by calling 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 CommandLine class also get the ability to set global values through command line arguments to their program: --Name=Value will set global value Name to Value.
Definition at line 75 of file global-value.h.
| typedef Vector::const_iterator ns3::GlobalValue::Iterator |
Iterator type for the list of all global values.
Definition at line 82 of file global-value.h.
|
private |
Container type for holding all the GlobalValues.
Definition at line 78 of file global-value.h.
| ns3::GlobalValue::GlobalValue | ( | std::string | name, |
| std::string | help, | ||
| const AttributeValue & | initialValue, | ||
| Ptr< const AttributeChecker > | checker | ||
| ) |
Constructor.
| [in] | name | the name of this global value. |
| [in] | help | some help text which describes the purpose of this global value. |
| [in] | initialValue | the value to assign to this global value during construction. |
| [in] | 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 41 of file global-value.cc.
References GetVector(), InitializeFromEnv(), m_checker, m_currentValue, m_initialValue, NS_FATAL_ERROR, and NS_LOG_FUNCTION.
Here is the call graph for this function:
|
static |
The Begin iterator.
Definition at line 171 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().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Iterate over the set of GlobalValues until a matching name is found and then set its value with GlobalValue::SetValue.
| [in] | name | the name of the global value |
| [in] | value | the value to set in the requested global value. |
This method cannot fail. It will crash if the input is not valid.
Definition at line 137 of file global-value.cc.
References Begin(), End(), NS_FATAL_ERROR, and NS_LOG_FUNCTION.
Referenced by ns3::Config::SetGlobal(), and ns3::MpiInterface::SetParallelSimulatorImpl().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Iterate over the set of GlobalValues until a matching name is found and then set its value with GlobalValue::SetValue.
| [in] | name | the name of the global value |
| [in] | value | the value to set in the requested global value. |
true if the value could be set successfully, false otherwise. Definition at line 156 of file global-value.cc.
References Begin(), End(), and NS_LOG_FUNCTION.
Referenced by ns3::Config::SetGlobalFailSafe().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
The End iterator.
Definition at line 179 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().
Here is the call graph for this function:
Here is the caller graph for this function:| Ptr< const AttributeChecker > ns3::GlobalValue::GetChecker | ( | ) | const |
Get the AttributeChecker.
Definition at line 115 of file global-value.cc.
References m_checker, and NS_LOG_FUNCTION.
| std::string ns3::GlobalValue::GetHelp | ( | ) | const |
Get the help string.
Definition at line 91 of file global-value.cc.
References m_help, and NS_LOG_FUNCTION_NOARGS.
| std::string ns3::GlobalValue::GetName | ( | ) | const |
Get the name.
Definition at line 84 of file global-value.cc.
References m_name, and NS_LOG_FUNCTION_NOARGS.
| void ns3::GlobalValue::GetValue | ( | AttributeValue & | value | ) | const |
Get the value.
| [out] | value | The AttributeValue to set to the value of this GlobalValue |
Definition at line 98 of file global-value.cc.
References m_checker, m_currentValue, m_name, NS_FATAL_ERROR, and NS_LOG_FUNCTION.
Referenced by ns3::Node::ChecksumEnabled(), ns3::tests::GlobalValueTestCase::DoRun(), ns3::GetImpl(), ns3::RngSeedManager::GetRun(), ns3::RngSeedManager::GetSeed(), and ns3::Simulator::SetImplementation().
Here is the caller graph for this function:
|
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.
| [in] | name | the name of the GlobalValue to be found |
| [out] | value | where to store the value of the found GlobalValue |
Definition at line 208 of file global-value.cc.
References GetValueByNameFailSafe(), NS_FATAL_ERROR, and NS_LOG_FUNCTION.
Referenced by NotifyViaProbe(), and NotifyViaTraceSource().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Finds the GlobalValue with the given name and returns its value.
| [in] | name | the name of the GlobalValue to be found |
| [out] | value | where to store the value of the found GlobalValue |
true if the GlobalValue was found, false otherwise Definition at line 193 of file global-value.cc.
References Begin(), End(), and NS_LOG_FUNCTION.
Referenced by GetValueByName(), and ns3::MpiInterface::SetParallelSimulatorImpl().
Here is the call graph for this function:
Here is the caller graph for this function:
|
staticprivate |
Get the static vector of all GlobalValues.
Definition at line 218 of file global-value.cc.
References NS_LOG_FUNCTION_NOARGS.
Referenced by GlobalValue(), Begin(), ns3::tests::GlobalValueTestCase::DoRun(), and End().
Here is the caller graph for this function:
|
private |
Initialize from the NS_GLOBAL_VALUE environment variable.
Definition at line 67 of file global-value.cc.
References ns3::EnvironmentVariable::Get(), m_checker, m_currentValue, m_initialValue, m_name, and NS_LOG_FUNCTION.
Referenced by GlobalValue().
Here is the call graph for this function:
Here is the caller graph for this function:| void ns3::GlobalValue::ResetInitialValue | ( | ) |
Reset to the initial value.
Definition at line 186 of file global-value.cc.
References m_currentValue, m_initialValue, and NS_LOG_FUNCTION.
| bool ns3::GlobalValue::SetValue | ( | const AttributeValue & | value | ) |
Set the value of this GlobalValue.
| [in] | value | the new value to set in this GlobalValue. |
true if the Global Value was set successfully. Definition at line 123 of file global-value.cc.
References m_checker, m_currentValue, and NS_LOG_FUNCTION.
|
friend |
Test case needs direct access to GetVector()
Definition at line 188 of file global-value.h.
|
private |
The AttributeChecker for this GlobalValue.
Definition at line 208 of file global-value.h.
Referenced by GlobalValue(), GetChecker(), GetValue(), InitializeFromEnv(), and SetValue().
|
private |
The current value.
Definition at line 206 of file global-value.h.
Referenced by GlobalValue(), GetValue(), InitializeFromEnv(), ResetInitialValue(), and SetValue().
|
private |
|
private |
The initial value.
Definition at line 204 of file global-value.h.
Referenced by GlobalValue(), InitializeFromEnv(), and ResetInitialValue().
|
private |
The name of this GlobalValue.
Definition at line 200 of file global-value.h.
Referenced by GetName(), GetValue(), and InitializeFromEnv().