A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
Object

Base classes which provide memory management and object aggregation. More...

+ Collaboration diagram for Object:

Files

file  attribute-construction-list.cc
 ns3::AttributeConstructionList implementation.
 
file  attribute-construction-list.h
 ns3::AttributeConstructionList declaration.
 
file  object-base.cc
 ns3::ObjectBase class implementation.
 
file  object-base.h
 ns3::ObjectBase declaration and NS_OBJECT_ENSURE_REGISTERED() macro definition.
 
file  object-factory.cc
 ns3::ObjectFactory class implementation.
 
file  object-factory.h
 ns3::ObjectFactory class declaration.
 
file  object-test-suite.cc
 Object test suite.
 
file  object.cc
 ns3::Object class implementation.
 
file  object.h
 ns3::Object class declaration, which is the root of the Object hierarchy and Aggregation.
 
file  type-id.cc
 ns3::TypeId and ns3::IidManager implementations.
 
file  type-id.h
 ns3::TypeId declaration; inline and template implementations.
 
file  type-traits-test-suite.cc
 TypeTraits test suite.
 
file  type-traits.h
 ns3::TypeTraits introspection declaration and template implementation.
 

Classes

class  ns3::AttributeConstructionList
 List of Attribute name, value and checker triples used to construct Objects. More...
 
struct  ns3::internal::GetStoredIe< T >
 
class  ns3::IidManager
 TypeId information manager. More...
 
class  ns3::Object
 A base class which provides memory management and object aggregation. More...
 
class  ns3::ObjectBase
 Anchor the ns-3 type and attribute system. More...
 
struct  ns3::ObjectDeleter
 Standard Object deleter, used by SimpleRefCount to delete an Object when the reference count drops to zero. More...
 
class  ns3::ObjectFactory
 Instantiate subclasses of ns3::Object. More...
 
class  ns3::TypeId
 a unique identifier for an interface. More...
 
struct  ns3::TypeTraits< T >
 Inspect a type to deduce its features. More...
 

Macros

#define IID   "IidManager"
 
#define IIDL   IID << ": "
 
#define NS_OBJECT_ENSURE_REGISTERED(type)
 Register an Object subclass with the TypeId system.
 
#define NS_OBJECT_TEMPLATE_CLASS_DEFINE(type, param)
 Explicitly instantiate a template class with one template parameter and register the resulting instance with the TypeId system.
 
#define NS_OBJECT_TEMPLATE_CLASS_TWO_DEFINE(type, param1, param2)
 Explicitly instantiate a template class with two template parameters and register the resulting instance with the TypeId system.
 

Functions

template<typename T , typename... Args>
Ptr< T > ns3::CreateObjectWithAttributes (Args... args)
 Allocate an Object on the heap and initialize with a set of attributes.
 
template<typename T , typename... Args>
Ptr< T > ns3::CreateObject (Args &&... args)
 Create an object by type, with varying number of constructor parameters.
 

Detailed Description

Base classes which provide memory management and object aggregation.

Macro Definition Documentation

◆ IID

#define IID   "IidManager"
Internal:
IidManager shorthand for use in NS_LOG

Definition at line 373 of file type-id.cc.

◆ IIDL

#define IIDL   IID << ": "
Internal:
IidManager shorthand for use in NS_LOG

Definition at line 379 of file type-id.cc.

◆ NS_OBJECT_ENSURE_REGISTERED

#define NS_OBJECT_ENSURE_REGISTERED (   type)
Value:
static struct Object##type##RegistrationClass \
{ \
Object##type##RegistrationClass() \
{ \
ns3::TypeId tid = type::GetTypeId(); \
tid.SetSize(sizeof(type)); \
tid.GetParent(); \
} \
} Object##type##RegistrationVariable
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetSize(std::size_t size)
Set the size of this type.
Definition: type-id.cc:952
TypeId GetParent() const
Get the parent of this TypeId.
Definition: type-id.cc:960
#define NS_WARNING_POP
Pops the diagnostic warning list from the stack, restoring it to the previous state.
Definition: warnings.h:78
#define NS_WARNING_PUSH_DEPRECATED
Save the current warning list and disables the ones about deprecated functions and classes.
Definition: warnings.h:82

Register an Object subclass with the TypeId system.

This macro should be invoked once for every class which defines a new GetTypeId method.

If the class is in a namespace, then the macro call should also be in the namespace.

Definition at line 46 of file object-base.h.

◆ NS_OBJECT_TEMPLATE_CLASS_DEFINE

#define NS_OBJECT_TEMPLATE_CLASS_DEFINE (   type,
  param 
)
Value:
template class type<param>; \
template <> \
std::string DoGetTemplateClassName<type<param>>() \
{ \
return std::string("ns3::") + std::string(#type) + std::string("<") + \
std::string(#param) + std::string(">"); \
} \
static struct Object##type##param##RegistrationClass \
{ \
Object##type##param##RegistrationClass() \
{ \
ns3::TypeId tid = type<param>::GetTypeId(); \
tid.SetSize(sizeof(type<param>)); \
tid.GetParent(); \
} \
} Object##type##param##RegistrationVariable

Explicitly instantiate a template class with one template parameter and register the resulting instance with the TypeId system.

This macro should be invoked once for every required instance of a template class with one template parameter which derives from the Object class and defines a new GetTypeId method.

If the template class is in a namespace, then the macro call should also be in the namespace.

Note
The type names used as arguments for this macro, being used to form a class name and a variable name, CANNOT contain the scope resolution operator (::)
Template Parameters
typethe template class
paramthe first template parameter

Definition at line 78 of file object-base.h.

◆ NS_OBJECT_TEMPLATE_CLASS_TWO_DEFINE

#define NS_OBJECT_TEMPLATE_CLASS_TWO_DEFINE (   type,
  param1,
  param2 
)
Value:
template class type<param1, param2>; \
template <> \
std::string DoGetTemplateClassName<type<param1, param2>>() \
{ \
return std::string("ns3::") + std::string(#type) + std::string("<") + \
std::string(#param1) + std::string(",") + std::string(#param2) + std::string(">"); \
} \
static struct Object##type##param1##param2##RegistrationClass \
{ \
Object##type##param1##param2##RegistrationClass() \
{ \
ns3::TypeId tid = type<param1, param2>::GetTypeId(); \
tid.SetSize(sizeof(type<param1, param2>)); \
tid.GetParent(); \
} \
} Object##type##param1##param2##RegistrationVariable

Explicitly instantiate a template class with two template parameters and register the resulting instance with the TypeId system.

This macro should be invoked once for every required instance of a template class with two template parameters which derives from the Object class and defines a new GetTypeId method.

If the template class is in a namespace, then the macro call should also be in the namespace.

Note
The type names used as arguments for this macro, being used to form a class name and a variable name, CANNOT contain the scope resolution operator (::)
Template Parameters
typethe template class
param1the first template parameter
param2the second template parameter

Definition at line 116 of file object-base.h.

Function Documentation

◆ CreateObject()

template<typename T , typename... Args>
Ptr< T > ns3::CreateObject ( Args &&...  args)

Create an object by type, with varying number of constructor parameters.

Template Parameters
T[explicit] The type of the derived object to construct.
Parameters
[in]argsArguments to pass to the constructor.
Returns
The derived object.

Definition at line 579 of file object.h.

References ns3::CompleteConstruct().

Referenced by ns3::Ipv4L3Protocol::AddInterface(), ns3::Ipv6L3Protocol::AddInterface(), TestChildQueueDisc::CheckConfig(), Ipv4L3ProtocolTestCase::DoRun(), Ipv6L3ProtocolTestCase::DoRun(), PointToPointTest::DoRun(), ns3::Ipv4L3Protocol::SetupLoopback(), and ns3::Ipv6L3Protocol::SetupLoopback().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CreateObjectWithAttributes()

template<typename T , typename... Args>
Ptr< T > ns3::CreateObjectWithAttributes ( Args...  args)

Allocate an Object on the heap and initialize with a set of attributes.

Template Parameters
T[explicit] The requested Object type.
Args[deduced] The type of the sequence of name-value pairs.
Parameters
[in]argsA sequence of name-value pairs of the attributes to set.
Returns
A pointer to a newly allocated object.

The args sequence can be made of any number of pairs, each consisting of a name (of std::string type) followed by a value (of const AttributeValue & type).

Definition at line 228 of file object-factory.h.

References ns3::ObjectFactory::Create(), ns3::ObjectFactory::Set(), and ns3::ObjectFactory::SetTypeId().

Referenced by ns3::CobaltQueueDisc::CheckConfig(), ns3::CoDelQueueDisc::CheckConfig(), ns3::FifoQueueDisc::CheckConfig(), ns3::PieQueueDisc::CheckConfig(), and ns3::RedQueueDisc::CheckConfig().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: