Next: , Previous: , Up: Defining Instruction Meta-classes   [Contents][Index]


4.2.2.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_PARAM (model, instr_meta_class_name, paramp)

This macro registers an instruction meta-class instr_meta_class_name for a multinode model. The event handler function of this instruction meta-class will be receiving the parameter paramp in the argument qsmm_param_p on all events. The macro QSMM_INSTR_META_CLASS should previously define the instruction meta-class.

The macro QSMM_REG_INSTR_META_CLASS_PARAM expands to:

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

Below there is the description of a function called by the macro QSMM_REG_INSTR_META_CLASS_PARAM.

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 an instruction meta-class instr_meta_class_name for a multinode model. The function instr_meta_class_func is the event handler of this instruction meta-class. That event handler will be receiving the parameter paramp in the argument qsmm_param_p on all events.

A string instr_meta_class_name must begin with an English letter or an underscore 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 sends an event QSMM_EVT_ENT_INIT to the event handler, and it can perform the initialization of that instruction meta-class.

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

QSMM_ERR_INVAL

The string instr_meta_class_name has invalid format.

QSMM_ERR_EXIST

A program has already registered an instruction meta-class or instruction class set named instr_meta_class_name in the multinode model.

QSMM_ERR_UNTIMELY

The model instance already exists—cannot change model structure.

QSMM_ERR_NOMEM

There was not enough memory to perform the operation.

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

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 the parameters of the event handler of an instruction meta-class instr_meta_class_name registered for a multinode model. If instr_meta_class_func_p is not NULL, the function sets *instr_meta_class_func_p to a pointer to that event handler. If param_pp is not NULL, the function sets *param_pp to the value of qsmm_param_p argument of that event handler passed on all events.

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

QSMM_ERR_NOTFOUND

The instruction meta-class instr_meta_class_name 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: Defining Instruction Meta-classes   [Contents][Index]