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

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 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 Vector * GetVector (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.

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 36 of file global-value.cc.

References NS_FATAL_ERROR, and NS_LOG_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 181 of file global-value.cc.

References NS_LOG_FUNCTION_NOARGS.

Referenced by Bind(), BindFailSafe(), GetValueByNameFailSafe(), and ns3::Config::Reset().

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 149 of file global-value.cc.

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

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

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 167 of file global-value.cc.

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

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

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

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

References NS_LOG_FUNCTION_NOARGS.

Referenced by Bind(), BindFailSafe(), GetValueByNameFailSafe(), and ns3::Config::Reset().

Ptr< const AttributeChecker > ns3::GlobalValue::GetChecker ( void  ) const
Returns
the checker associated to this GlobalValue.

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

References NS_LOG_FUNCTION.

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

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

References NS_LOG_FUNCTION_NOARGS.

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

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

References NS_LOG_FUNCTION_NOARGS.

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 217 of file global-value.cc.

References GetValueByNameFailSafe(), NS_FATAL_ERROR, and NS_LOG_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 202 of file global-value.cc.

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

Referenced by GetValueByName().

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

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

References NS_LOG_FUNCTION.


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