Next: , Previous: , Up: Code Integration Summary   [Contents]


3.6.3 Integrate every kind of event type in Dezyne with foreign code

This learning goal covers the bulk of the section, with many different examples on the various integration techniques. In Implementation of events on interfaces, the following table was provided as a reference of when to apply what action:

Port typeEvent typeUser action
Provides interface (on top of a component)InCall Dezyne function from handwritten code
OutAssign handwritten code to system function
Requires interface (on the bottom of a component)InAssign handwritten code to system function
OutCall Dezyne function from handwritten code

Calling a Dezyne function from handwritten code can be seen in the event loop where sensorTriggered and passwordEntered events were fired as well as the Timer implementation where a timeout event was fired into the System.

Assigning foreign implementations to System functions was done with lambda expressions for the Timer start and cancel. Wrapping implementations in lambda expressions is an easy way to create std::function objects which Dezyne-generated C++ uses to store event handlers.

An alternative, more cohesive way of providing foreign implementations is inheritance of skeleton components. This technique requires a bit more work to set up, but when set up properly it is both safer and it becomes easier to track the behavior of your application. Examples for this technique are the LED, Siren and PWManager components.

The idea is generally the same as in the provided table, where assigning foreign code is replaced by implementing pure virtual functions. For out-events on required ports and in-events on provided ports, the calling of a Dezyne function is performed on the respective port.


Next: , Previous: , Up: Code Integration Summary   [Contents]