25 #include "ns3/core-config.h" 112 NS_FATAL_ERROR (
"Attribute name="<<info.
name<<
" tid="<<tid.
GetName () <<
": initial value cannot be set using attributes");
129 char *envVar = getenv (
"NS_ATTRIBUTE_DEFAULT");
132 std::string env = std::string (envVar);
133 std::string::size_type cur = 0;
134 std::string::size_type next = 0;
135 while (next != std::string::npos)
137 next = env.find (
";", cur);
138 std::string tmp = std::string (env, cur, next-cur);
139 std::string::size_type equal = tmp.find (
"=");
140 if (equal != std::string::npos)
142 std::string name = tmp.substr (0, equal);
143 std::string envval = tmp.substr (equal+1, tmp.size () - equal - 1);
149 info.
name <<
"\" from env var");
162 info.
name <<
"\" from initial value.");
180 bool ok = accessor->Set (
this, *v);
190 if (!tid.LookupAttributeByName (name, &info))
192 NS_FATAL_ERROR (
"Attribute name="<<name<<
" does not exist for this object: tid="<<tid.GetName ());
197 NS_FATAL_ERROR (
"Attribute name="<<name<<
" is not settable for this object: tid="<<tid.GetName ());
201 NS_FATAL_ERROR (
"Attribute name="<<name<<
" could not be set for this object: tid="<<tid.GetName ());
210 if (!tid.LookupAttributeByName (name, &info))
228 if (!tid.LookupAttributeByName (name, &info))
230 NS_FATAL_ERROR (
"Attribute name="<<name<<
" does not exist for this object: tid="<<tid.GetName ());
235 NS_FATAL_ERROR (
"Attribute name="<<name<<
" is not gettable for this object: tid="<<tid.GetName ());
237 bool ok = info.
accessor->Get (
this, value);
245 NS_FATAL_ERROR (
"Attribute name="<<name<<
" tid="<<tid.GetName () <<
": input value is not a string");
251 NS_FATAL_ERROR (
"Attribute name="<<name<<
" tid="<<tid.GetName () <<
": could not get value");
253 str->
Set (v->SerializeToString (info.
checker));
263 if (!tid.LookupAttributeByName (name, &info))
272 bool ok = info.
accessor->Get (
this, value);
288 str->
Set (v->SerializeToString (info.
checker));
302 bool ok = accessor->ConnectWithoutContext (
this, cb);
315 bool ok = accessor->Connect (
this, context, cb);
328 bool ok = accessor->DisconnectWithoutContext (
this, cb);
341 bool ok = accessor->Disconnect (
this, context, cb);
std::string GetName(void) const
Get the name.
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 "...
Ptr< const TraceSourceAccessor > LookupTraceSourceByName(std::string name) const
Find a TraceSource by name.
#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.
ns3::StringValue 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.
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.
TypeId GetParent(void) const
Get the parent of this TypeId.
The attribute can be read.
ns3::AttributeConstructionList declaration.
ns3::ObjectBase declaration and NS_OBJECT_ENSURE_REGISTERED() madro definition.
static TypeId GetObjectIid(void)
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly...
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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::TraceSourceAccessor and ns3::MakeTraceSourceAccessor declarations.
The attribute can be written.
std::string GetAttributeFullName(std::size_t i) const
Get the Attribute name by index.
void ConstructSelf(const AttributeConstructionList &attributes)
Complete construction of ObjectBase; invoked by derived classes.
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...
std::size_t GetAttributeN(void) const
Get the number of attributes.
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.
struct TypeId::AttributeInformation GetAttribute(std::size_t i) const
Get Attribute information by index.
Ptr< AttributeValue > Find(Ptr< const AttributeChecker > checker) const
Find an Attribute in the list from its AttributeChecker.
bool TraceConnect(std::string name, std::string context, const CallbackBase &cb)
Connect a TraceSource to a Callback with a context.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
a unique identifier for an interface.
void GetAttribute(std::string name, AttributeValue &value) const
Get the value of an attribute, raising fatal errors if unsuccessful.
TypeId SetParent(TypeId tid)
Set the parent TypeId.