Platform Package reference: Function EwGetExistingAutoObject()

Description of the function EwGetExistingAutoObject() available in all Platform Packages for C compatible target systems starting with version 15 of Embedded Wizard. This function is intended to be used when integrating the Embedded Wizard created GUI application with the underlying graphics subsystem, graphics hardware or other external GUI applications coexisting on the same system. Unlike EwGetAutoObject(), this function does not instantiate the autoobject if it does not already exist.

Declaration

XObject EwGetExistingAutoObject( const XVariant* aAutoObject, XClass aClass )

Parameters

aAutoObject

Pointer to a data structure representing the autoobject to access. This data structure and all associated contents are generated by Embedded Wizard.

aClass

Pointer to data structure representing the class of the autoobject to access. The specified class has to match with the class defined originally in the autoobject member.

Discussion

The function EwGetExistingAutoObject() returns an autoobject identified by aAutoObject if it is currently instantiated, or returns NULL if no instance exists. The function verifies whether the required object is already instantiated and if it's true, the existing instance is returned immediately. If no instance of the desired autoobject could be found, EwGetExistingAutoObject() returns NULL without creating a new object. For example:

ApplicationDeviceClass device = EwGetExistingAutoObject( &ApplicationDeviceObject, ApplicationDeviceClass ); if ( device != NULL ) { /* The autoobject exists - feed event to it */ /* ... */ }

This function is particularly useful for middleware implementations where middleware events or data should only be fed to the UI when the UI maintains the corresponding autoobject alive. By checking for the existence of the autoobject without triggering its instantiation, middleware can avoid unnecessarily creating objects and can respond appropriately when the UI component is not active.

If you need to ensure the autoobject is instantiated, use EwGetAutoObject() instead, which will create the object if it does not already exist.