3D PLM Enterprise Architecture |
Middleware Abstraction |
Callback versus Send/ReceiveHow to create and use a notification depending on the mechanism |
Technical Article |
AbstractThe goal of this article is explained how to create and use a notification in Callback and Send/Receive mechanisms. You will learn how to create a class deriving from the CATNotification class, and how to manage the life cycle of an instance. |
To send a notification by the Callback or the Send/Receive mechanism, you can create a class which Object Modeler and C++ derives from the CATNotification component. The only one difference between the two mechanism is the argument of the class constructor:
... CATNotification(int iAutomaticDelete=CATNotificationDeleteOff); ... |
For iAutomaticDelete
there are two possible values:
CATNotificationDeleteOff
:
The notification is
not automatically deleted by the system. After the instantiation of the
notification, and the sent, you must yourself delete the instance. It is for
the Callback mechanism which is synchronous. CATNotificationDeleteOn
: The notification is automatically
deleted. After the instantiation of the notification, and the sent,
you must not delete the instance. It is for the Send/Receive
mechanism which is asynchronous. The CAASysRingNotification class is a class created in the "The Callback Mechanism" use case [1].
Here the header class:
#include "CATNotification.h" class CAASysRingNotification : public CATNotification { CATDeclareClass; public: CAASysRingNotification(); virtual ~CAASysRingNotification(); private: CAASysRingNotification(const CAASysRingNotification &iObjectToCopy); CAASysRingNotification& operator = (const CAASysRingNotification &iObjectToCopy); }; |
Here the source file:
#include "CAASysRingNotification.h" CATImplementClass(CAASysRingNotification, Implementation, CATBaseUnknown, CATNull); CAASysRingNotification::CAASysRingNotification() {} CAASysRingNotification::~CAASysRingNotification() {} |
The CATImplementClass
macro declares that CAASysRingNotification
is an Implementation
, that is, a component main class, that
OM-derives from CATBaseUnknown. The last argument must always be set
to CATNull
if the second one is set to Implementation
.
The CAASysRingNotification class constructor use the default
constructor of the CATNotification class. ( iAutomaticDelete =
CATNotificationDeleteOff).
It means that the notification will
be not deleted by the system.
There are two ways:
... CAASysRingNotification * pMyNotif = new CATMyNotification (); DispatchCallback(,pMyNotif); pMyNotif ->Release(); pMyNotif = NULL ; ... |
or simpler:
... CAASysRingNotification MyNotif ; DispatchCallback(,MyNotif); ... |
[Top]
The CAADlgAddNotification class is a class created in the "The Send/Receive Mechanism" use case [2].
Here the header class:
#include "CATNotification.h" class CAADlgAddNotification : public CATNotification { CATDeclareClass; public: CAADlgAddNotification(); virtual CAADlgAddNotification(); private: CAADlgAddNotification(const CAADlgAddNotification&iObjectToCopy); CAADlgAddNotification& operator = (const CAADlgAddNotification&iObjectToCopy); }; |
Here the source file:
#include "CAADlgAddNotification.h" CATImplementClass(CAADlgAddNotification, Implementation, CATBaseUnknown, CATNull); CAADlgAddNotification::CAADlgAddNotification():CATNotification(CATNotificationDeleteOn) {} CAADlgAddNotification::CAADlgAddNotification() {} |
The CATImplementClass
macro declares that CAADlgAddNotification
is an Implementation
, that is, a component main class, that
OM-derives from CATBaseUnknown. The last argument must always be set
to CATNull
if the second one is set to Implementation
.
The CAADlgAddNotification class constructor use CATNotificationDeleteOn
as argument for the CATNotification class constructor.
It
means that the notification will be automatically deleted by the
system.
... CAADlgAddNotification* pMyNotif = new CAADlgAddNotification(); SendNotification(...,pMyNotif); pMyNotif = NULL ; ... |
[Top]
CATNotificationDeleteOff,
and delete each instance of notification classCATNotificationDeleteOn,
and do not delete instances of notification class[Top]
[1] | The Callback Mechanism |
[2] | The Send/Receive Mechanism |
[Top] |
Version: 1 [Fev 2004] | Document created |
[Top] |
Copyright © 2004, Dassault Systèmes. All rights reserved.