class MyObject : public Object // here they are extending the Object class
{
public:
static TypeId GetTypeId (void) // here they are creating a function that returns an object of type TypeId
{
static TypeId tid = TypeId ("MyObject") // they lost me from this point downward !
.SetParent (Object::GetTypeId ())
.AddConstructor<MyObject> ()
.AddTraceSource ("MyInteger",
"An integer value to trace.",
MakeTraceSourceAccessor (&MyObject::m_myInt))
;
return tid;
}
MyObject () {}
TracedValue<int32_t> m_myInt;
};
I'm assuming that TypeId("MyObject") returns an object with a function called SetParent
which returns an object with a function called AddConstructor which returns an object of type
TypeId to be assigned to tid. In other words, they just put this conglomerate all on separate
lines for readability:
1 2
static TypeId tid = TypeId("MyObject").SetParent(Object::GetTypeId ()).AddConstructor<MyObject>().AddTraceSource("MyInteger", "An integer value to trace.", MakeTraceSourceAccessor(&MyObject::m_myInt));
return tid;
TracedValue<int32_t> m_myInt; // what is this ?
};
int
main (int argc, char *argv[])
{
Ptr<MyObject> myObject = CreateObject<MyObject> (); // what is this ?
};
myObject->TraceConnectWithoutContext ("MyInteger", MakeCallback(&IntTrace)); // what is this ?
};
myObject->m_myInt = 1234; // what is this ?
};
}
I'm assuming that MakeTraceSourceAccessor takes a pointer-to-member, because &MyObject::m_myInt gives a member pointer to the m_myInt member. Note that MyObject is a class, and the double colon :: is the scope resolution operator ;)