25 #include "ns3/core-config.h"
97 NS_FATAL_ERROR (
"Attribute name="<<info.
name<<
" tid="<<tid.
GetName () <<
": initial value cannot be set using attributes");
116 char *envVar = getenv (
"NS_ATTRIBUTE_DEFAULT");
119 std::string env = std::string (envVar);
120 std::string::size_type cur = 0;
121 std::string::size_type next = 0;
122 while (next != std::string::npos)
124 next = env.find (
";", cur);
125 std::string tmp = std::string (env, cur, next-cur);
126 std::string::size_type equal = tmp.find (
"=");
127 if (equal != std::string::npos)
129 std::string name = tmp.substr (0, equal);
130 std::string value = tmp.substr (equal+1, tmp.size () - equal - 1);
136 info.
name <<
"\" from env var");
152 info.
name <<
"\" from initial value.");
171 bool ok = accessor->Set (
this, *v);
181 if (!tid.LookupAttributeByName (name, &info))
183 NS_FATAL_ERROR (
"Attribute name="<<name<<
" does not exist for this object: tid="<<tid.GetName ());
188 NS_FATAL_ERROR (
"Attribute name="<<name<<
" is not settable for this object: tid="<<tid.GetName ());
192 NS_FATAL_ERROR (
"Attribute name="<<name<<
" could not be set for this object: tid="<<tid.GetName ());
201 if (!tid.LookupAttributeByName (name, &info))
219 if (!tid.LookupAttributeByName (name, &info))
221 NS_FATAL_ERROR (
"Attribute name="<<name<<
" does not exist for this object: tid="<<tid.GetName ());
226 NS_FATAL_ERROR (
"Attribute name="<<name<<
" is not gettable for this object: tid="<<tid.GetName ());
228 bool ok = info.
accessor->Get (
this, value);
236 NS_FATAL_ERROR (
"Attribute name="<<name<<
" tid="<<tid.GetName () <<
": input value is not a string");
242 NS_FATAL_ERROR (
"Attribute name="<<name<<
" tid="<<tid.GetName () <<
": could not get value");
244 str->
Set (v->SerializeToString (info.
checker));
254 if (!tid.LookupAttributeByName (name, &info))
263 bool ok = info.
accessor->Get (
this, value);
279 str->
Set (v->SerializeToString (info.
checker));
293 bool ok = accessor->ConnectWithoutContext (
this, cb);
306 bool ok = accessor->Connect (
this, context, cb);
319 bool ok = accessor->DisconnectWithoutContext (
this, cb);
332 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 the class in the ns-3 factory.
virtual ~ObjectBase()
Virtual destructor.
hold variables of type string
void Set(const std::string &value)
Hold a value for an Attribute.
#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)
#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.
The attribute can be read.
Ptr< AttributeValue > Find(Ptr< const AttributeChecker > checker) const
Ptr< const TraceSourceAccessor > LookupTraceSourceByName(std::string name) const
bool TraceDisconnect(std::string name, std::string context, const CallbackBase &cb)
T * PeekPointer(const Ptr< T > &p)
virtual void NotifyConstructionCompleted(void)
This method is invoked once all member attributes have been initialized.
static TypeId GetObjectIid(void)
bool TraceDisconnectWithoutContext(std::string name, const CallbackBase &cb)
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
The attribute can be written.
void ConstructSelf(const AttributeConstructionList &attributes)
std::string GetName(void) const
void GetAttribute(std::string name, AttributeValue &value) const
bool DoSet(Ptr< const AttributeAccessor > spec, Ptr< const AttributeChecker > checker, const AttributeValue &value)
virtual TypeId GetInstanceTypeId(void) const =0
#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)
std::string GetAttributeFullName(uint32_t i) const
bool GetAttributeFailSafe(std::string name, AttributeValue &attribute) const
struct TypeId::AttributeInformation GetAttribute(uint32_t i) const
void SetAttribute(std::string name, const AttributeValue &value)
a unique identifier for an interface.
TypeId SetParent(TypeId tid)