This function registers a synchronous event handler for an add, delete or checkpoint event.
MCO_RET mco_register_eventname_handler( /*IN*/ mco_trans_h trans,
/*IN*/ mco_eventname_handler,
/*IN*/ void *param);
trans
mco_trans_start().mco_eventname_handler
param
This function registers a call-back function that the runtime will invoke
whenever the event eventname occurs. Events are defined in the
database schema by specifying the event type (new, delete, update or
checkpoint) and the name of the handler function to be called. Multiple
handlers for a given eventname can be registered. The void param can be used
to pass any user-defined data structure between the application and the event
handler.
MCO_S_OK
MCO_E_ACCESS
MCO_READ_WRITE.Schema snippet: declare database evdb; class MyClass { uint4 u4; event <new> newEvent; list; }; evdb.h snippet: /* class MyClass methods */ MCO_RET MyClass_new ( mco_trans_h t, /*OUT*/ MyClass *handle ); ... typedef MCO_RET (*mco_newEvent_handler)( mco_trans_h t, MyClass * obj, MCO_EVENT_TYPE et, /*INOUT*/ void *param); MCO_RET mco_register_newEvent_handler ( mco_trans_h t, mco_newEvent_handler handler, void * param ); MCO_RET mco_unregister_newEvent_handler ( mco_trans_h t, mco_newEvent_handler handler); Application snippet: MCO_RET new_handler(mco_trans_h t, MyClass* obj, MCO_EVENT_TYPE et, /*INOUT */void* param) { autoid_t id; MyClass_autoid_get(obj, &id); printf("\tEvent \"Object New\" : object (%d) created\n", autoid2int(id)); return MCO_S_OK; } int register_events(mco_db_h db) { MCO_RET rc; mco_trans_h t; mco_trans_start(db, MCO_READ_WRITE, MCO_TRANS_FOREGROUND, &t); rc = mco_register_newEvent_handler( t, &new_handler, (void*)0 ); ... }