ACAPI_​Notify_​RegisterEventHandler

Register an event handler in your add-on.

    GSErrCode  ACAPI_Notify_RegisterEventHandler (
        GS::Owner<API_IEventHandler>&				eventHandler,
        API_Guid&  						id
    );

 

Parameters

eventHandler
[in] The event handler to be registered.
id
[out] The identifier of the successfully registered event handler.

 

Return Values

NoError
The requested operation finished successfully.
APIERR_BADPARS
The requested operation failed due to a nullptr in-parameter.

For other common API errors see the API Errors document.

 

Remarks

In case you register an event handler your add-on will automatically be kept loaded in memory.

The id out-parameter can be used to manually unregister the event handler by calling ACAPI_Notify_UnregisterEventHandler.

 

Example


// -----------------------------------------------------------------------------
// Called after the Add-On has been loaded into memory
// -----------------------------------------------------------------------------
GSErrCode    __ACENV_CALL    Initialize (void)
{
    class ClassificationSystemEventHandler : public API_IClassificationSystemEventHandler {
    public:
        virtual void OnCreated (const GS::HashSet& ids) const override
        {
            ACAPI_WriteReport ("The following Classification Systems were created:\n", false);

            for (const auto& id : ids) {
                ACAPI_WriteReport ("  - " + APIGuidToString (id) + "\n", false);
            }
        }
    };

    return ACAPI_Notify_RegisterEventHandler (GS::NewOwned<ClassificationSystemEventHandler> (), myEventHandlerId);
}

 

Requirements

Version: API 26 or later
Header: ACAPinc.h

 

See Also

Notification Manager,
API Functions