Creating event classes

Subclassing using macros

yasmine provides a variety of macros that create a class inherited from specialized_event. It is possible to set the name, the event ID, and the event priority. It is also possible to define parameters for the events.

Macro

Syntax

Description

Y_EVENT_CREATE

Y_EVENT_CREATE( _class_name, _event_id [, _parameter_type1, _getter_name1, ...] )

The macro creates an event with the given name and the given ID. It can create up to 10 parameters within the event.

For each parameter, the type and the getter name must be specified.

Y_EVENT_WITH_PRIORITY_CREATE

Y_EVENT_WITH_PRIORITY_CREATE( _class_name, _event_id, _event_priority [, _parameter_type1, _getter_name1, ...] )

The macro creates an event with the given name, the given ID and the given priority. It can create up to 10 parameters within the event. For each parameter, the type and the getter name must be specified.

Macros form the next table are deprecated and are used just for backward compatibility.

Macro

Syntax

Description

Y_EVENT_WITH_ID

EVENT_WITH_ID( _class_name, _event_id )

The macro will create an event class having the given name and given event ID. The priority of the event will be the default priority.

Y_EVENT_WITH_ID_PRIORITY

EVENT_WITH_ID_PRIORITY( _class_name, _event_id, _event_priority )

The macro will create an event class having the given name, given event ID and given priority.

Y_EVENT_1PARAM_WITH_ID

Y_EVENT_1PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _event_id )

The macro will create an event class having the given name, given event ID and a given type parameter. The priority of the event will be the default priority.

Y_EVENT_1PARAM_WITH_ID_PRIORITY

Y_EVENT_1PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _event_id, _event_priority )

The macro will create an event class having the given name, given event ID, a parameter with given type and value, and given priority.

Y_EVENT_2PARAM_WITH_ID

Y_EVENT_2PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _event_id )

The macro will create an event class having the given name, given event ID and two given type parameters. The priority of the event will be the default priority.

Y_EVENT_2PARAM_WITH_ID_PRIORITY

Y_EVENT_2PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _event_id, _event_priority )

The macro will create an event class having the given name, given event ID, two parameters with given type and value, and given priority.

Y_EVENT_3PARAM_WITH_ID

Y_EVENT_3PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _event_id )

The macro will create an event class having the given name, given event ID and three given type parameters. The priority of the event will be the default priority.

Y_EVENT_3PARAM_WITH_ID_PRIORITY

Y_EVENT_3PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _event_id, _event_priority )

The macro will create an event class having the given name, given event ID, three parameters with given type and value, and given priority.

Y_EVENT_4PARAM_WITH_ID

Y_EVENT_4PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _event_id )

The macro will create an event class having the given name, given event ID and four given type parameters. The priority of the event will be the default priority.

Y_EVENT_4PARAM_WITH_ID_PRIORITY

Y_EVENT_4PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _event_id, _event_priority )

The macro will create an event class having the given name, given event ID, four parameters with given type and value, and given priority.

Y_EVENT_5PARAM_WITH_ID

Y_EVENT_5PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _event_id )

The macro will create an event class having the given name, given event ID and five given type parameters. The priority of the event will be the default priority.

Y_EVENT_5PARAM_WITH_ID_PRIORITY

Y_EVENT_5PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _event_id, _event_priority )

The macro will create an event class having the given name, given event ID, five parameters with given type and value, and given priority.

Y_EVENT_6PARAM_WITH_ID

Y_EVENT_6PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _event_id )

The macro will create an event class having the given name, given event ID and six given type parameters. The priority of the event will be the default priority.

Y_EVENT_6PARAM_WITH_ID_PRIORITY

Y_EVENT_6PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _event_id, _event_priority )

The macro will create an event class having the given name, given event ID, six parameters with given type and value, and given priority.

Y_EVENT_7PARAM_WITH_ID

Y_EVENT_7PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _event_id )

The macro will create an event class having the given name, given event ID and seven given type parameters. The priority of the event will be the default priority.

Y_EVENT_7PARAM_WITH_ID_PRIORITY

Y_EVENT_7PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _event_id, _event_priority )

The macro will create an event class having the given name, given event ID, seven parameters with given type and value, and given priority.

Y_EVENT_8PARAM_WITH_ID

Y_EVENT_8PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _event_id )

The macro will create an event class having the given name, given event ID and eight given type parameters. The priority of the event will be the default priority.

Y_EVENT_8PARAM_WITH_ID_PRIORITY

Y_EVENT_8PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _event_id, _event_priority )

The macro will create an event class having the given name, given event ID, eight parameters with given type and value, and given priority.

Y_EVENT_9PARAM_WITH_ID

Y_EVENT_9PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _event_id )

The macro will create an event class having the given name, given event ID and nine given type parameters. The priority of the event will be the default priority.

Y_EVENT_9PARAM_WITH_ID_PRIORITY

Y_EVENT_9PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _event_id, _event_priority )

The macro will create an event class having the given name, given event ID, nine parameters with given type and value, and given priority.

Y_EVENT_10PARAM_WITH_ID

Y_EVENT_10PARAM_WITH_ID( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _parameter_type10, _getter_name10, _event_id )

The macro will create an event class having the given name, given event ID and ten given type parameters. The priority of the event will be the default priority.

Y_EVENT_10PARAM_WITH_ID_PRIORITY

Y_EVENT_10PARAM_WITH_ID_PRIORITY( _class_name, _parameter_type1, _getter_name1, _parameter_type2, _getter_name2, _parameter_type3, _getter_name3, _parameter_type4, _getter_name4, _parameter_type5, _getter_name5, _parameter_type6, _getter_name6, _parameter_type7, _getter_name7, _parameter_type8, _getter_name8, _parameter_type9, _getter_name9, _parameter_type10, _getter_name10, _event_id, _event_priority )

The macro will create an event class having the given name, given event ID, ten parameters with given type and value, and given priority.

This is useful for creating typed event classes and allows for easy event creation (via the static create method of the generated class or via macros). It also makes it possible for all events with a certain ID to use the same priority.

Using the macros

For how to use the macro, please see 'Firing events' page on 'Using the macro' section.

Creating own event classes

You can also write your own event classes. To do this you just have to derive your class from the event interface.