Skip to content

iceoryx_binding_c/listener.h🔗

Types🔗

Name
typedef CLASS Listener * iox_listener_t

Functions🔗

Name
iox_listener_t iox_listener_init(iox_listener_storage_t * self)
initializes a listener struct from a storage struct pointer
void iox_listener_deinit(iox_listener_t const self)
after using an iox_listener_t it must be cleaned up with this function
ENUM iox_ListenerResult iox_listener_attach_subscriber_event(iox_listener_t const self, iox_sub_t const subscriber, const ENUM iox_SubscriberEvent subscriberEvent, void(*)(iox_sub_t) callback)
Attaches a subscriber event to the listener.
ENUM iox_ListenerResult iox_listener_attach_subscriber_event_with_context_data(iox_listener_t const self, iox_sub_t const subscriber, const ENUM iox_SubscriberEvent subscriberEvent, void()(iox_sub_t, void ) callback, void *const contextData)
Attaches a subscriber event to the listener. The callback has an additional contextData argument to provide access to user defined data.
ENUM iox_ListenerResult iox_listener_attach_user_trigger_event(iox_listener_t const self, iox_user_trigger_t const userTrigger, void(*)(iox_user_trigger_t) callback)
Attaches a user trigger to the listener.
ENUM iox_ListenerResult iox_listener_attach_user_trigger_event_with_context_data(iox_listener_t const self, iox_user_trigger_t const userTrigger, void()(iox_user_trigger_t, void ) callback, void *const contextData)
Attaches a user trigger to the listener. The callback has an additional contextData argument to provide access to user defined data.
void iox_listener_detach_subscriber_event(iox_listener_t const self, iox_sub_t const subscriber, const ENUM iox_SubscriberEvent subscriberEvent)
Detaches a subscriber event from the listener.
void iox_listener_detach_user_trigger_event(iox_listener_t const self, iox_user_trigger_t const userTrigger)
Detaches a user trigger from the listener.
uint64_t iox_listener_size(iox_listener_t const self)
Returns the size, the number of attached events of a listener.
uint64_t iox_listener_capacity(iox_listener_t const self)
Returns the capacity of a listener (how many events can be attached).

Types Documentation🔗

typedef iox_listener_t🔗

typedef CLASS Listener* iox_listener_t;

Functions Documentation🔗

function iox_listener_init🔗

iox_listener_t iox_listener_init(
    iox_listener_storage_t * self
)

initializes a listener struct from a storage struct pointer

Parameters:

  • self pointer to raw memory which can hold a listener

Return: an initialized iox_listener_t

function iox_listener_deinit🔗

void iox_listener_deinit(
    iox_listener_t const self
)

after using an iox_listener_t it must be cleaned up with this function

Parameters:

  • self the listener which should be deinitialized

function iox_listener_attach_subscriber_event🔗

ENUM iox_ListenerResult iox_listener_attach_subscriber_event(
    iox_listener_t const self,
    iox_sub_t const subscriber,
    const ENUM iox_SubscriberEvent subscriberEvent,
    void(*)(iox_sub_t) callback
)

Attaches a subscriber event to the listener.

Parameters:

  • self listener to which the event should be attached to
  • subscriber subscriber which emits the event
  • subscriberEvent the event which should trigger the listener
  • callback the callback which is called when an event triggers the listener

Return: when successful iox_ListenerResult::ListenerResult_SUCCESS otherwise an enum which describes the error

function iox_listener_attach_subscriber_event_with_context_data🔗

ENUM iox_ListenerResult iox_listener_attach_subscriber_event_with_context_data(
    iox_listener_t const self,
    iox_sub_t const subscriber,
    const ENUM iox_SubscriberEvent subscriberEvent,
    void(*)(iox_sub_t, void *) callback,
    void *const contextData
)

Attaches a subscriber event to the listener. The callback has an additional contextData argument to provide access to user defined data.

Parameters:

  • self listener to which the event should be attached to
  • subscriber subscriber which emits the event
  • subscriberEvent the event which should trigger the listener
  • callback the callback which is called when an event triggers the listener
  • contextData a void pointer which is provided as second argument to the callback

Return: when successful iox_ListenerResult::ListenerResult_SUCCESS otherwise an enum which describes the error

function iox_listener_attach_user_trigger_event🔗

ENUM iox_ListenerResult iox_listener_attach_user_trigger_event(
    iox_listener_t const self,
    iox_user_trigger_t const userTrigger,
    void(*)(iox_user_trigger_t) callback
)

Attaches a user trigger to the listener.

Parameters:

  • self listener to which the event should be attached to
  • userTrigger user trigger which emits the event
  • callback the callback which is called when the user trigger triggers the listener

Return: when successful iox_ListenerResult::ListenerResult_SUCCESS otherwise an enum which describes the error

function iox_listener_attach_user_trigger_event_with_context_data🔗

ENUM iox_ListenerResult iox_listener_attach_user_trigger_event_with_context_data(
    iox_listener_t const self,
    iox_user_trigger_t const userTrigger,
    void(*)(iox_user_trigger_t, void *) callback,
    void *const contextData
)

Attaches a user trigger to the listener. The callback has an additional contextData argument to provide access to user defined data.

Parameters:

  • self listener to which the event should be attached to
  • userTrigger user trigger which emits the event
  • callback the callback which is called when the user trigger triggers the listener
  • contextData a void pointer which is provided as second argument to the callback

Return: when successful iox_ListenerResult::ListenerResult_SUCCESS otherwise an enum which describes the error

function iox_listener_detach_subscriber_event🔗

void iox_listener_detach_subscriber_event(
    iox_listener_t const self,
    iox_sub_t const subscriber,
    const ENUM iox_SubscriberEvent subscriberEvent
)

Detaches a subscriber event from the listener.

Parameters:

  • self listener from which the event should be detached
  • subscriber the subscriber which emits the event
  • subscriberEvent the subscriber event which is registered at the listener

function iox_listener_detach_user_trigger_event🔗

void iox_listener_detach_user_trigger_event(
    iox_listener_t const self,
    iox_user_trigger_t const userTrigger
)

Detaches a user trigger from the listener.

Parameters:

  • self listener from which the event should be detached
  • userTrigger the user trigger which emits the event

function iox_listener_size🔗

uint64_t iox_listener_size(
    iox_listener_t const self
)

Returns the size, the number of attached events of a listener.

Parameters:

  • self listener where the size should be acquired

Return: the size of the listener

function iox_listener_capacity🔗

uint64_t iox_listener_capacity(
    iox_listener_t const self
)

Returns the capacity of a listener (how many events can be attached).

Parameters:

  • self listener where the capacity should be acquired

Return: the capacity of the listener

Source code🔗

// Copyright (c) 2021 Apex.AI Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0

#ifndef IOX_BINDING_C_LISTENER_H
#define IOX_BINDING_C_LISTENER_H

#include "iceoryx_binding_c/enums.h"
#include "iceoryx_binding_c/internal/c2cpp_binding.h"
#include "iceoryx_binding_c/subscriber.h"
#include "iceoryx_binding_c/types.h"
#include "iceoryx_binding_c/user_trigger.h"

typedef CLASS Listener* iox_listener_t;


iox_listener_t iox_listener_init(iox_listener_storage_t* self);

void iox_listener_deinit(iox_listener_t const self);

ENUM iox_ListenerResult iox_listener_attach_subscriber_event(iox_listener_t const self,
                                                             iox_sub_t const subscriber,
                                                             const ENUM iox_SubscriberEvent subscriberEvent,
                                                             void (*callback)(iox_sub_t));

ENUM iox_ListenerResult
iox_listener_attach_subscriber_event_with_context_data(iox_listener_t const self,
                                                       iox_sub_t const subscriber,
                                                       const ENUM iox_SubscriberEvent subscriberEvent,
                                                       void (*callback)(iox_sub_t, void*),
                                                       void* const contextData);

ENUM iox_ListenerResult iox_listener_attach_user_trigger_event(iox_listener_t const self,
                                                               iox_user_trigger_t const userTrigger,
                                                               void (*callback)(iox_user_trigger_t));

ENUM iox_ListenerResult iox_listener_attach_user_trigger_event_with_context_data(iox_listener_t const self,
                                                                                 iox_user_trigger_t const userTrigger,
                                                                                 void (*callback)(iox_user_trigger_t,
                                                                                                  void*),
                                                                                 void* const contextData);

void iox_listener_detach_subscriber_event(iox_listener_t const self,
                                          iox_sub_t const subscriber,
                                          const ENUM iox_SubscriberEvent subscriberEvent);

void iox_listener_detach_user_trigger_event(iox_listener_t const self, iox_user_trigger_t const userTrigger);


uint64_t iox_listener_size(iox_listener_t const self);

uint64_t iox_listener_capacity(iox_listener_t const self);

#endif

Updated on 17 June 2021 at 11:15:28 CEST