diff -r 632d1467a4ae -r 5bdc2c399117 samples/main-object.cc --- a/samples/main-object.cc Fri May 25 21:43:23 2007 +0200 +++ b/samples/main-object.cc Fri May 25 21:47:59 2007 +0200 @@ -52,11 +52,40 @@ +class YetAnotherObject : public Object +{ +public: + static const InterfaceId iid; + YetAnotherObject (int a); +private: + virtual void DoDispose (void); +}; + +const InterfaceId YetAnotherObject::iid = MakeInterfaceId ("YetAnotherObject", Object::iid); + +YetAnotherObject::YetAnotherObject (int a) +{ + // enable our interface + SetInterfaceId (YetAnotherObject::iid); + // aggregated directly to another object. + AddInterface (MakeNewObject ()); +} +void +YetAnotherObject::DoDispose (void) +{ + // Do your work here. + // chain up + Object::DoDispose (); +} + + + int main (int argc, char *argv[]) { Ptr p; Ptr anObject; Ptr anotherObject; + Ptr yetAnotherObject; p = MakeNewObject (); // p gives you access to AnObject's interface @@ -81,5 +110,12 @@ NS_ASSERT (anotherObject != 0); + yetAnotherObject = MakeNewObject (2); + // gives you acess to AnObject interface too. + anObject = yetAnotherObject->QueryInterface (AnObject::iid); + NS_ASSERT (anObject != 0); + + return 0; } +