Generating events with arguments

Use the GEN command.

About this task

If the event has arguments, the GEN command is as follows:

instance->GEN(event(parameter[, parameter]*))

In this command:

When the event is generated, the actual argument names and their values appear in the call stack in the following format:

instance->event(argument = parameter[,
   argument = parameter]*))

If an event has arguments, provide the GEN command with the correct number of parameters and the correct types. For example, if event X is defined as X(int, B*, char*) where B is a class defined in IBM® Rational® Rhapsody®, to generate an event you can enter either of the following commands:

A[1]->GEN(X(3,B[5],"now"))
A[1]->GEN(X(1,NULL,"later"))

Event arguments must be either pointers to classes defined in Rational Rhapsody, or of a type that can be read from a string, such as int or char*. If you want to generate an event of a user-defined type that you have defined either inside or outside of Rational Rhapsody, you must either overload its I/O stream operator>>(istream&), or instantiate the template string2X(T& t) so that the product can interpret the characters entered.

The command A[1]->GEN(Y(1)) works because the >> operator automatically converts the character "1" to the integer 1. Otherwise, the command A[1]‑>GEN(Y(one)) would not work because the >> operator cannot convert the characters "one" to an integer.

Note: If you pass complex parameters (such as structs) and use animation, you must override the >> operator. Otherwise, Rational Rhapsody generates compilation errors.

Feedback