Skip to content

Commit

Permalink
iox-#2327 Remove macros ENUM and CLASS
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebentley15 committed Aug 21, 2024
1 parent c5c7fe6 commit 4523cb2
Show file tree
Hide file tree
Showing 17 changed files with 227 additions and 257 deletions.
25 changes: 12 additions & 13 deletions iceoryx_binding_c/include/iceoryx_binding_c/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "iceoryx_binding_c/types.h"

/// @brief client handle
typedef IOX_CLASS UntypedClient* iox_client_t;
typedef struct UntypedClient* iox_client_t;

/// @brief options to be set for a client
typedef struct
Expand All @@ -38,10 +38,10 @@ typedef struct
bool connectOnCreate;

/// @brief Sets whether the server blocks when the client response queue is full
IOX_ENUM iox_QueueFullPolicy responseQueueFullPolicy;
enum iox_QueueFullPolicy responseQueueFullPolicy;

/// @brief Sets whether the client blocks when the server request queue is full
IOX_ENUM iox_ConsumerTooSlowPolicy serverTooSlowPolicy;
enum iox_ConsumerTooSlowPolicy serverTooSlowPolicy;

/// @brief this value will be set exclusively by 'iox_client_options_init' and is not supposed to be modified
/// otherwise
Expand Down Expand Up @@ -87,9 +87,8 @@ void iox_client_deinit(iox_client_t const self);
/// describes the error
/// @note for the user-payload alignment 'IOX_C_CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT' is used
/// for a custom user-payload alignment please use 'iox_client_loan_aligned_request'
IOX_ENUM iox_AllocationResult iox_client_loan_request(iox_client_t const self,
void** const payload,
const uint64_t payloadSize);
enum iox_AllocationResult
iox_client_loan_request(iox_client_t const self, void** const payload, const uint64_t payloadSize);

/// @brief allocates a request in the shared memory with a custom alignment for the user-payload
/// @param[in] self handle of the client
Expand All @@ -98,10 +97,10 @@ IOX_ENUM iox_AllocationResult iox_client_loan_request(iox_client_t const self,
/// @param[in] payloadAlignment user-payload alignment of the allocated request
/// @return on success it returns AllocationResult_SUCCESS otherwise a value which
/// describes the error
IOX_ENUM iox_AllocationResult iox_client_loan_aligned_request(iox_client_t const self,
void** const payload,
const uint64_t payloadSize,
const uint32_t payloadAlignment);
enum iox_AllocationResult iox_client_loan_aligned_request(iox_client_t const self,
void** const payload,
const uint64_t payloadSize,
const uint32_t payloadAlignment);


/// @brief releases ownership of a previously allocated loaned request without sending it
Expand All @@ -114,7 +113,7 @@ void iox_client_release_request(iox_client_t const self, void* const payload);
/// @param[in] payload pointer to the user-payload of the request which should be send
/// @return on success it returns ClientSendResult_SUCCESS otherwise a value which
/// describes the error
IOX_ENUM iox_ClientSendResult iox_client_send(iox_client_t const self, void* const payload);
enum iox_ClientSendResult iox_client_send(iox_client_t const self, void* const payload);

/// @brief connects to the service
/// @param[in] self handle to the client
Expand All @@ -128,14 +127,14 @@ void iox_client_disconnect(iox_client_t const self);
/// @param[in] self handle to the client
/// @return ConnectionState_CONNECTED when successfully connected otherwise an enum which
/// describes the current state
IOX_ENUM iox_ConnectionState iox_client_get_connection_state(iox_client_t const self);
enum iox_ConnectionState iox_client_get_connection_state(iox_client_t const self);

/// @brief retrieve a received respone
/// @param[in] self handle to the client
/// @param[in] payload pointer in which the pointer to the user-payload of the response is stored
/// @return if a chunk could be received it returns ChunkReceiveResult_SUCCESS otherwise
/// an enum which describes the error
IOX_ENUM iox_ChunkReceiveResult iox_client_take_response(iox_client_t const self, const void** const payload);
enum iox_ChunkReceiveResult iox_client_take_response(iox_client_t const self, const void** const payload);

/// @brief release a previously acquired response (via iox_client_take_response)
/// @param[in] self handle to the client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,11 @@

#include <cstdint>

#define IOX_CLASS class
#define IOX_ENUM

#else

#include <stdbool.h>
#include <stdint.h>

#define IOX_CLASS struct
#define IOX_ENUM enum

#endif

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

namespace c2cpp
{
iox::popo::ConsumerTooSlowPolicy consumerTooSlowPolicy(const IOX_ENUM iox_ConsumerTooSlowPolicy policy) noexcept;
iox::popo::QueueFullPolicy queueFullPolicy(const IOX_ENUM iox_QueueFullPolicy policy) noexcept;
iox::popo::ConsumerTooSlowPolicy consumerTooSlowPolicy(const enum iox_ConsumerTooSlowPolicy policy) noexcept;
iox::popo::QueueFullPolicy queueFullPolicy(const enum iox_QueueFullPolicy policy) noexcept;
iox::popo::SubscriberEvent subscriberEvent(const iox_SubscriberEvent value) noexcept;
iox::popo::SubscriberState subscriberState(const iox_SubscriberState value) noexcept;

Expand Down
84 changes: 41 additions & 43 deletions iceoryx_binding_c/include/iceoryx_binding_c/listener.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "iceoryx_binding_c/types.h"
#include "iceoryx_binding_c/user_trigger.h"

typedef IOX_CLASS Listener* iox_listener_t;
typedef struct Listener* iox_listener_t;


/// @brief initializes a listener struct from a storage struct pointer
Expand All @@ -44,10 +44,10 @@ void iox_listener_deinit(iox_listener_t const self);
/// @param[in] subscriberEvent the event which should trigger the listener
/// @param[in] 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
IOX_ENUM iox_ListenerResult iox_listener_attach_subscriber_event(iox_listener_t const self,
iox_sub_t const subscriber,
const IOX_ENUM iox_SubscriberEvent subscriberEvent,
void (*callback)(iox_sub_t));
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));

/// @brief Attaches a subscriber event to the listener. The callback has an additional contextData argument to provide
/// access to user defined data.
Expand All @@ -57,10 +57,10 @@ IOX_ENUM iox_ListenerResult iox_listener_attach_subscriber_event(iox_listener_t
/// @param[in] callback the callback which is called when an event triggers the listener
/// @param[in] 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
IOX_ENUM iox_ListenerResult
enum iox_ListenerResult
iox_listener_attach_subscriber_event_with_context_data(iox_listener_t const self,
iox_sub_t const subscriber,
const IOX_ENUM iox_SubscriberEvent subscriberEvent,
const enum iox_SubscriberEvent subscriberEvent,
void (*callback)(iox_sub_t, void*),
void* const contextData);

Expand All @@ -69,9 +69,9 @@ iox_listener_attach_subscriber_event_with_context_data(iox_listener_t const self
/// @param[in] userTrigger user trigger which emits the event
/// @param[in] 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
IOX_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(iox_listener_t const self,
iox_user_trigger_t const userTrigger,
void (*callback)(iox_user_trigger_t));

/// @brief Attaches a user trigger to the listener. The callback has an additional contextData argument to provide
/// access to user defined data.
Expand All @@ -80,19 +80,19 @@ IOX_ENUM iox_ListenerResult iox_listener_attach_user_trigger_event(iox_listener_
/// @param[in] callback the callback which is called when the user trigger triggers the listener
/// @param[in] 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
IOX_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);
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);

/// @brief Detaches a subscriber event from the listener
/// @param[in] self listener from which the event should be detached
/// @param[in] subscriber the subscriber which emits the event
/// @param[in] subscriberEvent the subscriber event which is registered at the listener
void iox_listener_detach_subscriber_event(iox_listener_t const self,
iox_sub_t const subscriber,
const IOX_ENUM iox_SubscriberEvent subscriberEvent);
const enum iox_SubscriberEvent subscriberEvent);

/// @brief Detaches a user trigger from the listener
/// @param[in] self listener from which the event should be detached
Expand All @@ -116,10 +116,10 @@ uint64_t iox_listener_capacity(iox_listener_t const self);
/// @param[in] clientEvent the event which should trigger the listener
/// @param[in] 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
IOX_ENUM iox_ListenerResult iox_listener_attach_client_event(iox_listener_t const self,
iox_client_t const client,
const IOX_ENUM iox_ClientEvent clientEvent,
void (*callback)(iox_client_t));
enum iox_ListenerResult iox_listener_attach_client_event(iox_listener_t const self,
iox_client_t const client,
const enum iox_ClientEvent clientEvent,
void (*callback)(iox_client_t));

/// @brief Attaches a client event to the listener. The callback has an additional contextData argument to provide
/// access to user defined data.
Expand All @@ -129,31 +129,30 @@ IOX_ENUM iox_ListenerResult iox_listener_attach_client_event(iox_listener_t cons
/// @param[in] callback the callback which is called when an event triggers the listener
/// @param[in] 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
IOX_ENUM iox_ListenerResult
iox_listener_attach_client_event_with_context_data(iox_listener_t const self,
iox_client_t const client,
const IOX_ENUM iox_ClientEvent clientEvent,
void (*callback)(iox_client_t, void*),
void* const contextData);
enum iox_ListenerResult iox_listener_attach_client_event_with_context_data(iox_listener_t const self,
iox_client_t const client,
const enum iox_ClientEvent clientEvent,
void (*callback)(iox_client_t, void*),
void* const contextData);

/// @brief Detaches a client from the listener
/// @param[in] self listener from which the event should be detached
/// @param[in] client the client which emits the event
/// @param[in] clientEvent the event which should be removed from the listener
void iox_listener_detach_client_event(iox_listener_t const self,
iox_client_t const client,
const IOX_ENUM iox_ClientEvent clientEvent);
const enum iox_ClientEvent clientEvent);

/// @brief Attaches a server event to the listener
/// @param[in] self listener to which the event should be attached to
/// @param[in] server the server which emits the event
/// @param[in] serverEvent the event which should trigger the listener
/// @param[in] 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
IOX_ENUM iox_ListenerResult iox_listener_attach_server_event(iox_listener_t const self,
iox_server_t const server,
const IOX_ENUM iox_ServerEvent serverEvent,
void (*callback)(iox_server_t));
enum iox_ListenerResult iox_listener_attach_server_event(iox_listener_t const self,
iox_server_t const server,
const enum iox_ServerEvent serverEvent,
void (*callback)(iox_server_t));

/// @brief Attaches a server event to the listener. The callback has an additional contextData argument to provide
/// access to user defined data.
Expand All @@ -163,31 +162,30 @@ IOX_ENUM iox_ListenerResult iox_listener_attach_server_event(iox_listener_t cons
/// @param[in] callback the callback which is called when an event triggers the listener
/// @param[in] 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
IOX_ENUM iox_ListenerResult
iox_listener_attach_server_event_with_context_data(iox_listener_t const self,
iox_server_t const server,
const IOX_ENUM iox_ServerEvent serverEvent,
void (*callback)(iox_server_t, void*),
void* const contextData);
enum iox_ListenerResult iox_listener_attach_server_event_with_context_data(iox_listener_t const self,
iox_server_t const server,
const enum iox_ServerEvent serverEvent,
void (*callback)(iox_server_t, void*),
void* const contextData);

/// @brief Detaches a server from the listener
/// @param[in] self listener from which the event should be detached
/// @param[in] server the server which emits the event
/// @param[in] serverEvent the event which should be removed from the listener
void iox_listener_detach_server_event(iox_listener_t const self,
iox_server_t const server,
const IOX_ENUM iox_ServerEvent serverEvent);
const enum iox_ServerEvent serverEvent);

/// @brief Attaches a service discovery event to the listener
/// @param[in] self listener to which the event should be attached to
/// @param[in] serviceDiscovery service discovery which emits the event
/// @param[in] serviceDiscoveryEvent the event which should trigger the listener
/// @param[in] 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
IOX_ENUM iox_ListenerResult
enum iox_ListenerResult
iox_listener_attach_service_discovery_event(iox_listener_t const self,
iox_service_discovery_t const serviceDiscovery,
const IOX_ENUM iox_ServiceDiscoveryEvent serviceDiscoveryEvent,
const enum iox_ServiceDiscoveryEvent serviceDiscoveryEvent,
void (*callback)(iox_service_discovery_t));

/// @brief Attaches a service discovery event to the listener. The callback has an additional contextData argument to
Expand All @@ -198,10 +196,10 @@ iox_listener_attach_service_discovery_event(iox_listener_t const self,
/// @param[in] callback the callback which is called when an event triggers the listener
/// @param[in] 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
IOX_ENUM iox_ListenerResult iox_listener_attach_service_discovery_event_with_context_data(
enum iox_ListenerResult iox_listener_attach_service_discovery_event_with_context_data(
iox_listener_t const self,
iox_service_discovery_t const serviceDiscovery,
const IOX_ENUM iox_ServiceDiscoveryEvent serviceDiscoveryEvent,
const enum iox_ServiceDiscoveryEvent serviceDiscoveryEvent,
void (*callback)(iox_service_discovery_t, void*),
void* const contextData);

Expand All @@ -211,6 +209,6 @@ IOX_ENUM iox_ListenerResult iox_listener_attach_service_discovery_event_with_con
/// @param[in] serviceDiscoveryEvent the service discovery event which should be removed from the listener
void iox_listener_detach_service_discovery_event(iox_listener_t const self,
iox_service_discovery_t const serviceDiscovery,
const IOX_ENUM iox_ServiceDiscoveryEvent serviceDiscoveryEvent);
const enum iox_ServiceDiscoveryEvent serviceDiscoveryEvent);

#endif
Loading

0 comments on commit 4523cb2

Please sign in to comment.