27 #include "ns3/core-config.h" 60 NS_FATAL_ERROR (
"Value set by user on " << name <<
" is invalid.");
71 char *envVar = getenv (
"NS_GLOBAL_VALUE");
76 std::string env = std::string (envVar);
77 std::string::size_type cur = 0;
78 std::string::size_type next = 0;
79 while (next != std::string::npos)
81 next = env.find (
";", cur);
82 std::string tmp = std::string (env, cur, next-cur);
83 std::string::size_type equal = tmp.find (
"=");
84 if (equal != std::string::npos)
86 std::string name = tmp.substr (0, equal);
87 std::string value = tmp.substr (equal+1, tmp.size () - equal - 1);
161 if ((*i)->GetName () == name)
163 if (!(*i)->SetValue (value))
179 if ((*i)->GetName () == name)
181 return (*i)->SetValue (value);
213 if ((*gvit)->GetName () == name)
215 (*gvit)->GetValue (value);
228 NS_FATAL_ERROR (
"Could not find GlobalValue named \"" << name <<
"\"");
NS_FATAL_x macro definitions.
std::string GetName(void) const
Get the name.
void GetValue(AttributeValue &value) const
Get the value.
Smart pointer class similar to boost::intrusive_ptr.
std::string GetHelp(void) const
Get the help string.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Hold variables of type string.
void Set(const std::string &value)
Set the value.
std::string m_help
The help string.
ns3::StringValue attribute value declarations.
Hold a value for an Attribute.
ns3::UintegerValue attribute value declarations and template implementations.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Vector::const_iterator Iterator
Iterator type for the list of all global values.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Ptr< AttributeValue > m_initialValue
The initial value.
GlobalValue(std::string name, std::string help, const AttributeValue &initialValue, Ptr< const AttributeChecker > checker)
Constructor.
Ptr< const AttributeChecker > GetChecker(void) const
Get the AttributeChecker.
void ResetInitialValue(void)
Reset to the initial value.
static Vector * GetVector(void)
Get the static vector of all GlobalValues.
static Iterator Begin(void)
The Begin iterator.
ns3::AttributeValue, ns3::AttributeAccessor and ns3::AttributeChecker declarations.
Ptr< const AttributeChecker > m_checker
The AttributeChecker for this GlobalValue.
std::vector< GlobalValue * > Vector
Container type for holding all the GlobalValues.
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 Globa...
static bool GetValueByNameFailSafe(std::string name, AttributeValue &value)
Finds the GlobalValue with the given name and returns its value.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool SetValue(const AttributeValue &value)
Set the value of this GlobalValue.
ns3::GlobalValue declaration.
std::string m_name
The name of this GlobalValue.
Ptr< AttributeValue > m_currentValue
The current value.
static Iterator End(void)
The End iterator.
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 Globa...
static void GetValueByName(std::string name, AttributeValue &value)
Finds the GlobalValue with the given name and returns its value.
void InitializeFromEnv(void)
Initialize from the NS_GLOBAL_VALUE environment variable.