Overview
Features
Download
Documentation
Community
Add-Ons & Services

POCO event mechanism

A general discussion forum.

POCO event mechanism

Postby luisao » 05 Jul 2012, 11:26

Dear all,

I am new using POCO. I couldn´t find many good examples about the notification center using POCO.

Do anybody has experience with it?

Currently I am trying to notify several threads the same notification. But I found the problem: who is the responsable for deleting the notification object?

thanks guys,
luisao
luisao
 
Posts: 1
Joined: 05 Jul 2012, 11:21

Re: POCO event mechanism

Postby alex » 05 Jul 2012, 18:40

Let's see what does documentation say:
NotificationCenter documentation wrote:The handler method gets co-ownership of the Notification object and must release it when done. This is best done with an AutoPtr:
Code: Select all
 void MyClass::handleNotification(MyNotification* pNf)
 {
   AutoPtr<MyNotification> nf(pNf);
   ///         ...
 }

Alternatively, the NObserver class template can be used to register a callback method. In this case, the callback method receives the Notification in an AutoPtr and thus does not have to deal with object ownership issues:
Code: Select all
 void MyClass::handleNotification(const AutoPtr<MyNotification>& pNf)
 {
           ...
 }
alex
 
Posts: 1132
Joined: 11 Jul 2006, 16:27
Location: United_States


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron