【发布时间】:2019-09-12 01:47:09
【问题描述】:
Node 对象声明为
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 进行了基础研究,但之前没有遇到过这种语法。
它是声明类Node的方法/属性'的另一种方式吗?
【问题讨论】:
标签: c++ object-oriented-analysis ns-3