Register an optional handler that is called if any remote proxy requests the current field value.

notice

Note: The registered handler must provide the current field value using asynchronous future/promise approach. In case no custom handler is registered, ara::com will internally handle the request and provide the last field value set by last Update() API call. This implicitly requires at least one call to Update() before a service instance gets offered.

Syntax

template <…>
auto amsr::socal::events::SkeletonField<…>::RegisterGetHandler(GetHandlerInterface get_handler) -> void

Parameters

in

get_handler

Handler function which is called with get() from the client.

The given handler must not be nullptr and must be valid as long as the service is offered.

Returns

void

notice

Note: Any exception thrown by the callback will lead to a termination through std::terminate().

Precondition

Thread-safety, Reentrance, Result Delivery

  • Threadsafe : FALSE for same class instance, TRUE for different instances
  • Reentrant : FALSE for same class instance, TRUE for different instances
  • Synchronous : TRUE

Example

ExampleApplicationField1.RegisterSetHandler([this](service1::skeleton::fields::ExampleApplicationField1::FieldType const& value) {
    ara::core::Promise<service1::skeleton::fields::ExampleApplicationField1::FieldType> promise;
    promise.set_value(field1_value_);
    return promise.get_future();
});