Reputation: 467
The Node object is declared as
class Node : public Object
{
public:
static TypeId GetTypeId (void);
and it's definition is
TypeId
Node::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::Node")
.SetParent<Object> ()
.SetGroupName ("Network")
.AddConstructor<Node> ()
.AddAttribute ("DeviceList",
"The list of devices associated to this Node.",
ObjectVectorValue (),
MakeObjectVectorAccessor (&Node::m_devices),
MakeObjectVectorChecker<NetDevice> ())
.AddAttribute ("ApplicationList",
"The list of applications associated to this Node.",
ObjectVectorValue (),
MakeObjectVectorAccessor (&Node::m_applications),
MakeObjectVectorChecker<Application> ())
.AddAttribute ("Id",
"The id (unique integer) of this Node.",
TypeId::ATTR_GET, // allow only getting it.
UintegerValue (0),
MakeUintegerAccessor (&Node::m_id),
MakeUintegerChecker<uint32_t> ())
;
return tid;
}
My question is regarding this:
static TypeId tid = TypeId ("ns3::Node")
.SetParent<Object> ()
Once we declare what tid
is, there is no end of line ;
symbol and the next few lines start with the dot .
operator.
.SetParent<Object> ()
.SetGroupName ("Network")
.AddConstructor<Node> ()
I did a basic study of OOP before starting to work on NS3 but didn't come across this kind of syntax before.
Is it an alternate way of declaring the methods/attributes' of the class Node
?
Upvotes: 0
Views: 230
Reputation: 7598
Whitespace, including line breaks, is not meaningful in C++.
TypeId ("ns3::Node")
creates a temporary object. .SetParent<Object> ()
is a method called on the object. Apparently, it returns a reference to the object, on which .SetGroupName()
is called, and so on.
Each method sets some attribute on the temporary object. Once it is fully configured, it is used to initialize static TypeId tid
.
Upvotes: 1