Receivers create interests for these events occurring to an instance of TShapelist by calling its GetAddedShapeInterest and GetRemovedShapeInterest member functions.
Because there is no documentation on the classes of notifications sent for these events, receivers assume they are TNotifications.
TShapeList inherits from TNotifier, which provides a notifier implementation that performs synchronous notification.
class TShapeList : public TNotifier { public: MCollectibleDeclarationsMacro(TShapeList); TShapeList(); TShapeList(const TShapeList&); virtual ~TShapeList(); virtual void AdoptShape(MGraphic*); virtual MGraphic* OrphanShape(const MGraphic&); virtual TIteratorOver<MGraphic>* CreateShapeIterator() const; TInterest GetAddedShapeInterest(); TInterest GetRemovedShapeInterest(); private: TDequeOf<MGraphic> fShapes; enum { kOriginalVersion }; };
GetAddedShapeInterest returns a standard TInterest, initialized with the notifier (this instance) and a token that names the interest. GetRemovedShapeInterest is exactly parallel, so code for it is omitted.
TInterest TShapeList::GetAddedShapeInterest() { static const TToken kAddedShape("AddedShape"); return TInterest(this, kAddedShape); }
void TShapeList::AdoptShape(MGraphic* shape) { fShapes.Add(shape); Notify(TNotification(GetAddedShapeInterest())); } MGraphic* TShapeList::OrphanShape(const MGraphic& shape) { MGraphic* removedShape = fShapes.Remove(shape); if (removedShape) { Notify(TNotification(GetRemovedShapeInterest())); } return removedShape; }