在 NS3 中遇到以下代码行。需要帮助理解它

Came across the following lines of code in NS3. Need help understanding it

节点对象声明为

class Node : public Object
{
public:
  static TypeId GetTypeId (void);

它的定义是

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;
}

我的问题是:

static TypeId tid = TypeId ("ns3::Node")
    .SetParent<Object> ()

一旦我们声明 tid 是什么,就没有行尾 ; 符号,接下来的几行以点 . 运算符开始。

    .SetParent<Object> ()
    .SetGroupName ("Network")
    .AddConstructor<Node> ()

在开始研究 NS3 之前,我对 OOP 进行了基础研究,但之前没有遇到过这种语法。

这是声明 class Node 的 methods/attributes' 的另一种方法吗?

空格(包括换行符)在 C++ 中没有意义。 TypeId ("ns3::Node") 创建一个临时对象。 .SetParent<Object> () 是在对象上调用的方法。显然,它 returns 是对对象的引用,在该对象上调用 .SetGroupName(),依此类推。

每个方法都会在临时对象上设置一些属性。完全配置后,用于初始化 static TypeId tid.