A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ns3::GlobalValue Class Reference

hold a so-called 'global value'. More...

#include <global-value.h>

+ Collaboration diagram for ns3::GlobalValue:

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 AttributeCheckerGetChecker (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)
static bool GetValueByNameFailSafe (std::string name, AttributeValue &value)

Private Types

typedef std::vector
< GlobalValue * > 
Vector

Private Member Functions

void InitializeFromEnv (void)

Static Private Member Functions

static VectorGetVector (void)

Private Attributes

Ptr< const AttributeCheckerm_checker
Ptr< AttributeValuem_currentValue
std::string m_help
Ptr< AttributeValuem_initialValue
std::string m_name

Friends

class GlobalValueTestCase

Detailed Description

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 47 of file global-value.h.

Member Typedef Documentation

typedef Vector::const_iterator ns3::GlobalValue::Iterator

Definition at line 51 of file global-value.h.

typedef std::vector<GlobalValue *> ns3::GlobalValue::Vector
private

Definition at line 49 of file global-value.h.

Constructor & Destructor Documentation

ns3::GlobalValue::GlobalValue ( std::string  name,
std::string  help,
const AttributeValue initialValue,
Ptr< const AttributeChecker checker 
)
Parameters
namethe name of this global value.
helpsome help text which describes the purpose of this global value.
initialValuethe value to assign to this global value during construction.
checkera 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 33 of file global-value.cc.

References ns3::AttributeChecker::CreateValidValue(), GetVector(), InitializeFromEnv(), m_checker, m_currentValue, m_initialValue, and NS_FATAL_ERROR.

+ Here is the call graph for this function:

Member Function Documentation

GlobalValue::Iterator ns3::GlobalValue::Begin ( void  )
static
Returns
an iterator which represents a pointer to the first GlobalValue registered.

Definition at line 165 of file global-value.cc.

References GetVector().

Referenced by Bind(), BindFailSafe(), GetValueByNameFailSafe(), ns3::RawTextConfigSave::Global(), ns3::XmlConfigSave::Global(), main(), ns3::CommandLine::PrintGlobals(), and ns3::Config::Reset().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::GlobalValue::Bind ( std::string  name,
const AttributeValue value 
)
static
Parameters
namethe name of the global value
valuethe 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 137 of file global-value.cc.

References Begin(), End(), and NS_FATAL_ERROR.

Referenced by main(), ns3::Config::SetGlobal(), and test().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ns3::GlobalValue::BindFailSafe ( std::string  name,
const AttributeValue value 
)
static
Parameters
namethe name of the global value
valuethe value to set in the requested global value.
Returns
true if the value could be set successfully, false otherwise.

Iterate over the set of GlobalValues until a matching name is found and then set its value with GlobalValue::SetValue.

Definition at line 153 of file global-value.cc.

References Begin(), and End().

Referenced by ns3::Config::SetGlobalFailSafe().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

GlobalValue::Iterator ns3::GlobalValue::End ( void  )
static
Returns
an iterator which represents a pointer to the last GlobalValue registered.

Definition at line 170 of file global-value.cc.

References GetVector().

Referenced by Bind(), BindFailSafe(), GetValueByNameFailSafe(), ns3::RawTextConfigSave::Global(), ns3::XmlConfigSave::Global(), main(), 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 ( void  ) const
Returns
the checker associated to this GlobalValue.

Definition at line 119 of file global-value.cc.

References m_checker.

std::string ns3::GlobalValue::GetHelp ( void  ) const
Returns
the help text of this GlobalValue.

Definition at line 99 of file global-value.cc.

References m_help.

std::string ns3::GlobalValue::GetName ( void  ) const
Returns
the name of this GlobalValue.

Definition at line 94 of file global-value.cc.

References m_name.

void ns3::GlobalValue::GetValue ( AttributeValue value) const
void ns3::GlobalValue::GetValueByName ( std::string  name,
AttributeValue value 
)
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.

Parameters
namethe name of the GlobalValue to be found
valuewhere to store the value of the found GlobalValue

Definition at line 196 of file global-value.cc.

References GetValueByNameFailSafe(), and NS_FATAL_ERROR.

Referenced by main().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ns3::GlobalValue::GetValueByNameFailSafe ( std::string  name,
AttributeValue value 
)
static

finds the GlobalValue with the given name and returns its value

Parameters
namethe name of the GlobalValue to be found
valuewhere to store the value of the found GlobalValue
Returns
true if the GlobalValue was found, false otherwise

Definition at line 182 of file global-value.cc.

References Begin(), and End().

Referenced by GetValueByName().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

GlobalValue::Vector * ns3::GlobalValue::GetVector ( void  )
staticprivate

Definition at line 205 of file global-value.cc.

Referenced by Begin(), ns3::GlobalValueTestCase::DoRun(), End(), and GlobalValue().

+ Here is the caller graph for this function:

void ns3::GlobalValue::InitializeFromEnv ( void  )
private

Definition at line 57 of file global-value.cc.

References ns3::AttributeChecker::CreateValidValue(), m_checker, m_currentValue, m_initialValue, and m_name.

Referenced by GlobalValue().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::GlobalValue::ResetInitialValue ( void  )

Definition at line 176 of file global-value.cc.

References m_currentValue, and m_initialValue.

bool ns3::GlobalValue::SetValue ( const AttributeValue value)
Parameters
valuethe new value to set in this GlobalValue.

Definition at line 125 of file global-value.cc.

References ns3::AttributeChecker::CreateValidValue(), m_checker, and m_currentValue.

+ Here is the call graph for this function:

Friends And Related Function Documentation

friend class GlobalValueTestCase
friend

Definition at line 144 of file global-value.h.

Member Data Documentation

Ptr<const AttributeChecker> ns3::GlobalValue::m_checker
private

Definition at line 152 of file global-value.h.

Referenced by GetChecker(), GetValue(), GlobalValue(), InitializeFromEnv(), and SetValue().

Ptr<AttributeValue> ns3::GlobalValue::m_currentValue
private

Definition at line 151 of file global-value.h.

Referenced by GetValue(), GlobalValue(), InitializeFromEnv(), ResetInitialValue(), and SetValue().

std::string ns3::GlobalValue::m_help
private

Definition at line 149 of file global-value.h.

Referenced by GetHelp().

Ptr<AttributeValue> ns3::GlobalValue::m_initialValue
private

Definition at line 150 of file global-value.h.

Referenced by GlobalValue(), InitializeFromEnv(), and ResetInitialValue().

std::string ns3::GlobalValue::m_name
private

Definition at line 148 of file global-value.h.

Referenced by GetName(), GetValue(), and InitializeFromEnv().


The documentation for this class was generated from the following files: