Instance Management in C for RAD

The following are the RAD instance management functions in the C language:

rad_instance_t *rad_instance_create(rad_object_type *type, void *data, void (*)(void *)freef);

rad_instance_create uses the supplied parameters to create a new instance of an object of type. data is the user data to store with the instance and the freef function is a callback which will be called with the user data when the instance is removed. If the function fails, it returns NULL. Otherwise, a valid instance reference is returned.

void * rad_instance_getdata(rad_instance_t *instance);

rad_instance_getdata returns the user data (supplied in rad_instance_create) of the instance.

void rad_instance_notify (rad_instance_t *instance, const char *event, long sequence, adr_data_t *data);

rad_instance_notify generates an event on the supplied instance. The sequence is supplied in the event as the sequence number and the payload of the event is provided in data.