25 #include "ns3/core-config.h"
112 NS_FATAL_ERROR (
"Attribute name="<<info.
name<<
" tid="<<tid.
GetName () <<
": initial value cannot be set using attributes");
131 char *envVar = getenv (
"NS_ATTRIBUTE_DEFAULT");
134 std::string env = std::string (envVar);
135 std::string::size_type cur = 0;
136 std::string::size_type next = 0;
137 while (next != std::string::npos)
139 next = env.find (
";", cur);
140 std::string tmp = std::string (env, cur, next-cur);
141 std::string::size_type equal = tmp.find (
"=");
142 if (equal != std::string::npos)
144 std::string name = tmp.substr (0, equal);
145 std::string value = tmp.substr (equal+1, tmp.size () - equal - 1);
151 info.
name <<
"\" from env var");
167 info.
name <<
"\" from initial value.");
186 bool ok = accessor->Set (
this, *v);
196 if (!tid.LookupAttributeByName (name, &info))
198 NS_FATAL_ERROR (
"Attribute name="<<name<<
" does not exist for this object: tid="<<tid.GetName ());
203 NS_FATAL_ERROR (
"Attribute name="<<name<<
" is not settable for this object: tid="<<tid.GetName ());
207 NS_FATAL_ERROR (
"Attribute name="<<name<<
" could not be set for this object: tid="<<tid.GetName ());
216 if (!tid.LookupAttributeByName (name, &info))
234 if (!tid.LookupAttributeByName (name, &info))
236 NS_FATAL_ERROR (
"Attribute name="<<name<<
" does not exist for this object: tid="<<tid.GetName ());
241 NS_FATAL_ERROR (
"Attribute name="<<name<<
" is not gettable for this object: tid="<<tid.GetName ());
243 bool ok = info.
accessor->Get (
this, value);
251 NS_FATAL_ERROR (
"Attribute name="<<name<<
" tid="<<tid.GetName () <<
": input value is not a string");
257 NS_FATAL_ERROR (
"Attribute name="<<name<<
" tid="<<tid.GetName () <<
": could not get value");
259 str->
Set (v->SerializeToString (info.
checker));
269 if (!tid.LookupAttributeByName (name, &info))
278 bool ok = info.
accessor->Get (
this, value);
294 str->
Set (v->SerializeToString (info.
checker));
308 bool ok = accessor->ConnectWithoutContext (
this, cb);
321 bool ok = accessor->Connect (
this, context, cb);
334 bool ok = accessor->DisconnectWithoutContext (
this, cb);
347 bool ok = accessor->Disconnect (
this, context, cb);
uint32_t GetAttributeN(void) const
Get the number of attributes.
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
Get the parent of this TypeId.
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)
Report a fatal error with a message and terminate.
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
Find a TraceSource by name.
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.
TypeId SetGroupName(std::string groupName)
Set the group name.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
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
Get the name.
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
Get the Attribute name by index.
struct TypeId::AttributeInformation GetAttribute(uint32_t i) const
Get Attribute information by index.
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)
Set the parent TypeId.