25 #include "ns3/core-config.h"
111 NS_FATAL_ERROR (
"Attribute name="<<info.
name<<
" tid="<<tid.
GetName () <<
": initial value cannot be set using attributes");
130 char *envVar = getenv (
"NS_ATTRIBUTE_DEFAULT");
133 std::string env = std::string (envVar);
134 std::string::size_type cur = 0;
135 std::string::size_type next = 0;
136 while (next != std::string::npos)
138 next = env.find (
";", cur);
139 std::string tmp = std::string (env, cur, next-cur);
140 std::string::size_type equal = tmp.find (
"=");
141 if (equal != std::string::npos)
143 std::string name = tmp.substr (0, equal);
144 std::string value = tmp.substr (equal+1, tmp.size () - equal - 1);
150 info.
name <<
"\" from env var");
166 info.
name <<
"\" from initial value.");
185 bool ok = accessor->Set (
this, *v);
195 if (!tid.LookupAttributeByName (name, &info))
197 NS_FATAL_ERROR (
"Attribute name="<<name<<
" does not exist for this object: tid="<<tid.GetName ());
202 NS_FATAL_ERROR (
"Attribute name="<<name<<
" is not settable for this object: tid="<<tid.GetName ());
206 NS_FATAL_ERROR (
"Attribute name="<<name<<
" could not be set for this object: tid="<<tid.GetName ());
215 if (!tid.LookupAttributeByName (name, &info))
233 if (!tid.LookupAttributeByName (name, &info))
235 NS_FATAL_ERROR (
"Attribute name="<<name<<
" does not exist for this object: tid="<<tid.GetName ());
240 NS_FATAL_ERROR (
"Attribute name="<<name<<
" is not gettable for this object: tid="<<tid.GetName ());
242 bool ok = info.
accessor->Get (
this, value);
250 NS_FATAL_ERROR (
"Attribute name="<<name<<
" tid="<<tid.GetName () <<
": input value is not a string");
256 NS_FATAL_ERROR (
"Attribute name="<<name<<
" tid="<<tid.GetName () <<
": could not get value");
258 str->
Set (v->SerializeToString (info.
checker));
268 if (!tid.LookupAttributeByName (name, &info))
277 bool ok = info.
accessor->Get (
this, value);
293 str->
Set (v->SerializeToString (info.
checker));
307 bool ok = accessor->ConnectWithoutContext (
this, cb);
320 bool ok = accessor->Connect (
this, context, cb);
333 bool ok = accessor->DisconnectWithoutContext (
this, cb);
346 bool ok = accessor->Disconnect (
this, context, cb);
uint32_t GetAttributeN(void) const
Smart pointer class similar to boost::intrusive_ptr.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
virtual ~ObjectBase()
Virtual destructor.
Hold variables of type string.
void Set(const std::string &value)
Set the value.
String attribute value declarations.
Hold a value for an Attribute.
U * PeekPointer(const Ptr< U > &p)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
TypeId GetParent(void) const
Base class for Callback class.
bool SetAttributeFailSafe(std::string name, const AttributeValue &value)
Set a single attribute without raising errors.
#define NS_FATAL_ERROR(msg)
Fatal error handling.
static TypeId GetTypeId(void)
Get the type ID.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
The attribute can be written at construction-time.
bool GetAttributeFailSafe(std::string name, AttributeValue &value) const
Get the value of an attribute without raising erros.
The attribute can be read.
Ptr< AttributeValue > Find(Ptr< const AttributeChecker > checker) const
Find an Attribute in the list from its AttributeChecker.
ns3::AttributeConstructionList declaration.
ns3::ObjectBase class declaration and NS_OBJECT_ENSURE_REGISTERED() definition.
static TypeId GetObjectIid(void)
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly...
Ptr< const TraceSourceAccessor > LookupTraceSourceByName(std::string name) const
bool TraceDisconnect(std::string name, std::string context, const CallbackBase &cb)
Disconnect from a TraceSource a Callback previously connected with a context.
List of Attribute name, value and checker triples used to construct Objects.
virtual void NotifyConstructionCompleted(void)
Notifier called once the ObjectBase is fully constructed.
bool TraceDisconnectWithoutContext(std::string name, const CallbackBase &cb)
Disconnect from a TraceSource a Callback previously connected without a context.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::TraceSourceAccessor and ns3::MakeTraceSourceAccessor declarations.
The attribute can be written.
void ConstructSelf(const AttributeConstructionList &attributes)
Complete construction of ObjectBase; invoked by derived classes.
std::string GetName(void) const
void GetAttribute(std::string name, AttributeValue &value) const
Get the value of an attribute, raising fatal errors if unsuccessful.
bool DoSet(Ptr< const AttributeAccessor > spec, Ptr< const AttributeChecker > checker, const AttributeValue &value)
Attempt to set the value referenced by the accessor spec to a valid value according to the checker...
virtual TypeId GetInstanceTypeId(void) const =0
Get the most derived TypeId for this Object.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
bool TraceConnect(std::string name, std::string context, const CallbackBase &cb)
Connect a TraceSource to a Callback with a context.
std::string GetAttributeFullName(uint32_t i) const
struct TypeId::AttributeInformation GetAttribute(uint32_t i) const
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)