Next: , Previous: , Up: Instruction Meta-class Definition   [Contents][Index]


4.3.3 Registering the Function

Use the following macro to register the event handler function of an instruction meta-class.

Macro: QSMM_REG_INSTR_META_CLASS (model, instr_meta_class_name, paramp)

This macro registers instruction meta-class instr_meta_class_name for a multinode model specified by handle model. That instruction meta-class represented by its event handler function should be previously defined by the macro QSMM_INSTR_META_CLASS. Parameter paramp will be passed as the value of argument qsmm_param_p of this event handler function on all types of events.

This macro is expanded to:

qsmm_reg_instr_meta_class((model), #instr_meta_class_name,
                          &instr_meta_class_name, (paramp))

Below is the description of a function called by the macro QSMM_REG_INSTR_META_CLASS.

Function: int qsmm_reg_instr_meta_class (qsmm_t model, const char *instr_meta_class_name, qsmm_instr_meta_class_func_t instr_meta_class_func, void *paramp)

This function registers instruction meta-class instr_meta_class_name for a multinode model specified by handle model. Function instr_meta_class_func will be used as the event handler function of this instruction meta-class. Parameter paramp will be passed as the value of argument qsmm_param_p of that event handler function on all types of events.

A string addressed by instr_meta_class_name must begin with an English letter or an underscore and must be followed by zero or more characters, where each character is an English letter, a decimal digit, or an underscore.

After registering the instruction meta-class, the function qsmm_reg_instr_meta_class sends event QSMM_EVT_ENT_INIT to the event handler function of that instruction meta-class. At this point, the latter function can perform initialization of that instruction meta-class.

The function returns a non-negative value on success or a negative error code on failure. Currently, the following error codes can be returned.

QSMM_ERR_UNTIMELY

The model instance already exists, so changing model structure is not allowed.

QSMM_ERR_INVAL

A string addressed by instr_meta_class_name has invalid format.

QSMM_ERR_EXIST

An instruction meta-class or instruction class set named instr_meta_class_name is already registered.

QSMM_ERR_NOMEM

There was not enough memory to perform the operation.

Use the following function to get a pointer to the event handler function of an instruction meta-class and the user parameter of that function.

Function: int qsmm_get_instr_meta_class_handler (qsmm_t model, const char *instr_meta_class_name, qsmm_instr_meta_class_func_t *instr_meta_class_func_p, void **param_pp)

This function retrieves parameters associated with the event handler function of instruction meta-class instr_meta_class_name registered for a multinode model specified by handle model. If instr_meta_class_func_p is not NULL, then *instr_meta_class_func_p will be set to a pointer to this event handler function. If param_pp is not NULL, then *param_pp will be set to the value of argument qsmm_param_p of this event handler function passed on all types of events.

The function returns a non-negative value on success or a negative error code on failure. Currently, the following error codes can be returned.

QSMM_ERR_NOTFOUND

Instruction meta-class instr_meta_class_name is not found.

QSMM_ERR_TYPE

An entity named instr_meta_class_name is not an instruction meta-class. The entity is an instruction class set.

QSMM_ERR_NOMEM

There was not enough memory to perform the operation.


Next: , Previous: , Up: Instruction Meta-class Definition   [Contents][Index]