Synopsis
PDX_MSGT mda_SetCallBack(long option, int model, int event, MDA_CALL_BACK *func)
Purpose
Sets a callback function for an event.
Description
Sets a function to be called whenever event occurs. The functions are chained so if mda_SetCallBack is called multiple times, the callback functions will be invoked in the order they set using this function. The callback function must be declared as:
.RS 3 PDX_MSGT func (int event, void *data) .RE
Where event is the event causing the callback and data defines the callback specific information about the event.
Input
option
Options (not used)
model
Model to set callback in
event
MDA_ENT_CREATED
Occurs when an entity is initially created. Function should cast data to MDA_PTR *, which is the database pointer of the entity which was created. If the entity was created with mda_AllocateEntity (or the 2 version), the callback function will be invoked the first time mda_UnlockEntity is called with no pending locks (i.e. no nested locks or the MDA_FORCE_UNLOCK option is used). If the entity was created with mda_CreateEntity, the callback function will be invoked before mda_CreateEntity returns. When this callback is invoked, the entity is still locked in memory. This allows the callback function to use mda_GetLockedAddr to gain access to the entity structure.
MDA_ENT_MODIFIED
Occurs when an entity is unlocked with the modify option set (i.e. mda_UnlockEnity with the MDA_MODIFIED option). Function should cast data to MDA_PTR *, which is the database pointer of the entity which was modified. Note that the callback function will only be invoked when the entity is unlocked (i.e. if the mda_MarkEntityModified function is used, the callback will not be invoked until the entity is unlocked). When this callback is invoked, the entity is still locked in memory. This allows the callback function to use mda_GetLockedAddr to gain access to the entity structure. The callback function usually should not call mda_LockEntity on the passed database pointer as this will result in the callback function being recursively invoked.
MDA_ENT_DELETED
Occurs when an entity is deleted. Function should cast data to MDA_PTR *, which is the database pointer of the entity which was deleted. Note that the callback function will not be invoked if the entity can not be deleted because of parent references (see mda_DeleteEntity). When this callback is invoked, the entity is still locked in memory. This allows the callback function to use mda_GetLockedAddr to gain access to the entity structure.
func
Function to be invoked when event occurs.
Return
MDA error code