|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
25 #include "ns3/core-config.h"
113 NS_FATAL_ERROR (
"Attribute name=" << info.
name <<
" tid=" << tid.
GetName () <<
": initial value cannot be set using attributes");
129 const char *envVar = getenv (
"NS_ATTRIBUTE_DEFAULT");
130 if (envVar != 0 && std::strlen (envVar) > 0)
132 std::string env = 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");
161 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);
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
@ ATTR_CONSTRUCT
The attribute can be written at construction-time.
ns3::AttributeConstructionList declaration.
TypeId SetGroupName(std::string groupName)
Set the group name.
static TypeId GetObjectIid(void)
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool SetAttributeFailSafe(std::string name, const AttributeValue &value)
Set a single attribute without raising errors.
ns3::StringValue attribute value declarations.
bool TraceDisconnectWithoutContext(std::string name, const CallbackBase &cb)
Disconnect from a TraceSource a Callback previously connected without a context.
Ptr< const TraceSourceAccessor > LookupTraceSourceByName(std::string name) const
Find a TraceSource by name.
@ ATTR_SET
The attribute can be written.
Hold a value for an Attribute.
std::string GetAttributeFullName(std::size_t i) const
Get the Attribute name by index.
virtual TypeId GetInstanceTypeId(void) const =0
Get the most derived TypeId for this Object.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Ptr< AttributeValue > Find(Ptr< const AttributeChecker > checker) const
Find an Attribute in the list from its AttributeChecker.
@ ATTR_GET
The attribute can be read.
void ConstructSelf(const AttributeConstructionList &attributes)
Complete construction of ObjectBase; invoked by derived classes.
U * PeekPointer(const Ptr< U > &p)
TypeId SetParent(TypeId tid)
Set the parent TypeId.
void Set(const std::string &value)
Set the value.
bool GetAttributeFailSafe(std::string name, AttributeValue &value) const
Get the value of an attribute without raising erros.
std::size_t GetAttributeN(void) const
Get the number of attributes.
Smart pointer class similar to boost::intrusive_ptr.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
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,...
ns3::ObjectBase declaration and NS_OBJECT_ENSURE_REGISTERED() madro definition.
void GetAttribute(std::string name, AttributeValue &value) const
Get the value of an attribute, raising fatal errors if unsuccessful.
virtual ~ObjectBase()
Virtual destructor.
Hold variables of type string.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
std::string GetName(void) const
Get the name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
bool TraceDisconnect(std::string name, std::string context, const CallbackBase &cb)
Disconnect from a TraceSource a Callback previously connected with a context.
bool TraceConnect(std::string name, std::string context, const CallbackBase &cb)
Connect a TraceSource to a Callback with a context.
Base class for Callback class.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
TypeId GetParent(void) const
Get the parent of this TypeId.
static TypeId GetTypeId(void)
Get the type ID.
ns3::TraceSourceAccessor and ns3::MakeTraceSourceAccessor declarations.
List of Attribute name, value and checker triples used to construct Objects.
struct TypeId::AttributeInformation GetAttribute(std::size_t i) const
Get Attribute information by index.
virtual void NotifyConstructionCompleted(void)
Notifier called once the ObjectBase is fully constructed.