Skip to content

Commit

Permalink
Merge pull request eclipse-iceoryx#397 from ApexAI/iox-#341-waitset-n…
Browse files Browse the repository at this point in the history
…ext-gen

Iox eclipse-iceoryx#341 waitset next gen
  • Loading branch information
elfenpiff authored Dec 9, 2020
2 parents 8d1bd34 + c5118f9 commit 1574dca
Show file tree
Hide file tree
Showing 111 changed files with 7,234 additions and 2,095 deletions.
7 changes: 4 additions & 3 deletions iceoryx_binding_c/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
# Copyright (c) 2020 by Robert Bosch GmbH, 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.
Expand Down Expand Up @@ -48,14 +48,15 @@ set(${PROJECT_NAME}_DIR ${CMAKE_CURRENT_LIST_DIR}/cmake
#
add_library(${PROJECT_NAME}
STATIC
source/c_condition.cpp
source/c_guard_condition.cpp
source/c_user_trigger.cpp
source/c_publisher.cpp
source/c_node.cpp
source/c_runtime.cpp
source/c_subscriber.cpp
source/c_trigger_info.cpp
source/c_wait_set.cpp
source/cpp2c_enum_translation.cpp
source/cpp2c_publisher.cpp
source/cpp2c_subscriber.cpp
)
add_library(${PROJECT_NAMESPACE}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
Expand Down
33 changes: 0 additions & 33 deletions iceoryx_binding_c/include/iceoryx_binding_c/condition.h

This file was deleted.

13 changes: 9 additions & 4 deletions iceoryx_binding_c/include/iceoryx_binding_c/enums.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2020 by Robert Bosch GmbH, 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.
Expand All @@ -15,6 +15,12 @@
#ifndef IOX_BINDING_C_ENUMS_H
#define IOX_BINDING_C_ENUMS_H

/// @brief describes events which can be triggered by a subscriber
enum iox_SubscriberEvent
{
SubscriberEvent_HAS_NEW_SAMPLES,
};

/// @brief describes the current state of a subscriber
enum iox_SubscribeState
{
Expand Down Expand Up @@ -46,9 +52,8 @@ enum iox_AllocationResult

enum iox_WaitSetResult
{
WaitSetResult_CONDITION_VECTOR_OVERFLOW,
WaitSetResult_CONDITION_VARIABLE_ALREADY_SET,
WaitSetResult_CONDITION_VARIABLE_ATTACH_FAILED,
WaitSetResult_TRIGGER_VECTOR_OVERFLOW,
WaitSetResult_TRIGGER_ALREADY_ACQUIRED,
WaitSetResult_UNDEFINED_ERROR,
WaitSetResult_SUCCESS
};
Expand Down
48 changes: 0 additions & 48 deletions iceoryx_binding_c/include/iceoryx_binding_c/guard_condition.h

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2020 by Robert Bosch GmbH, 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.
Expand All @@ -19,6 +19,14 @@

struct cpp2c_Publisher
{
cpp2c_Publisher() = default;
cpp2c_Publisher(const cpp2c_Publisher&) = delete;
cpp2c_Publisher(cpp2c_Publisher&& rhs) noexcept;
~cpp2c_Publisher();

cpp2c_Publisher& operator=(const cpp2c_Publisher&) = delete;
cpp2c_Publisher& operator=(cpp2c_Publisher&& rhs) noexcept;

iox::popo::PublisherPortData* m_portData{nullptr};
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2020 by Robert Bosch GmbH, 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.
Expand All @@ -15,15 +15,33 @@
#ifndef IOX_BINDING_C_CPP2C_SUBSCRIBER_H
#define IOX_BINDING_C_CPP2C_SUBSCRIBER_H

#include "iceoryx_binding_c/enums.h"
#include "iceoryx_posh/internal/popo/ports/subscriber_port_user.hpp"
#include "iceoryx_posh/popo/condition.hpp"
#include "iceoryx_posh/popo/wait_set.hpp"

struct cpp2c_Subscriber : public iox::popo::Condition
struct cpp2c_Subscriber
{
void setConditionVariable(iox::popo::ConditionVariableData* const conditionVariableDataPtr) noexcept override;
bool hasTriggered() const noexcept override;
void unsetConditionVariable() noexcept override;
cpp2c_Subscriber() = default;
cpp2c_Subscriber(const cpp2c_Subscriber&) = delete;
cpp2c_Subscriber(cpp2c_Subscriber&& rhs) = delete;
~cpp2c_Subscriber();

cpp2c_Subscriber& operator=(const cpp2c_Subscriber&) = delete;
cpp2c_Subscriber& operator=(cpp2c_Subscriber&& rhs) = delete;

iox_WaitSetResult attachTo(iox::popo::WaitSet& waitset,
const iox_SubscriberEvent event,
const uint64_t triggerId,
const iox::popo::Trigger::Callback<cpp2c_Subscriber> callback = nullptr) noexcept;

void detachEvent(const iox_SubscriberEvent event) noexcept;

void invalidateTrigger(const uint64_t uniqueTriggerId) noexcept;

bool hasNewSamples() const noexcept;


iox::popo::SubscriberPortData* m_portData{nullptr};
iox::popo::TriggerHandle m_trigger;
};
#endif
4 changes: 2 additions & 2 deletions iceoryx_binding_c/include/iceoryx_binding_c/runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

#include "internal/c2cpp_binding.h"

/// @brief registers a new posh runtime with a given name
/// @brief initializes a new posh runtime with a given name
/// @param[in] name name of the posh runtime
void iox_runtime_register(const char* const name);
void iox_runtime_init(const char* const name);

/// @brief retrieves the instance-name of the current posh runtime instance
/// @param[in] name char pointer to preallocated memory
Expand Down
24 changes: 23 additions & 1 deletion iceoryx_binding_c/include/iceoryx_binding_c/subscriber.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2020 by Robert Bosch GmbH, 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.
Expand All @@ -21,6 +21,7 @@

/// @brief Subscriber handle
typedef struct cpp2c_Subscriber* iox_sub_t;
typedef CLASS WaitSet* iox_ws_t;

/// @brief initialize subscriber handle in the default runtime node
/// @param[in] self pointer to preallocated memory of size = sizeof(iox_sub_storage_t)
Expand Down Expand Up @@ -80,4 +81,25 @@ bool iox_sub_has_new_chunks(iox_sub_t const self);
/// @return true if there are lost chunks otherwise false
bool iox_sub_has_lost_chunks(iox_sub_t const self);

/// @brief attaches the subscriber to a waitset
/// @param[in] self handle to the subscriber
/// @param[in] waitset handle to the waitset
/// @param[in] event the type of the event which should be attached to the waitset
/// @param[in] triggerId the user defined trigger id
/// @param[in] callback a callback which is attached to the trigger, NULL if no
/// callback should be set
/// @return if it was attached successfully it returns WaitSetResult_SUCCESS
/// otherwise an enum which is describing the error
ENUM iox_WaitSetResult iox_sub_attach_to_waitset(iox_sub_t const self,
iox_ws_t const waitset,
const ENUM iox_SubscriberEvent event,
const uint64_t triggerId,
void (*callback)(iox_sub_t));

/// @brief detaches the subscriber from a waitset
/// @param[in] self handle to the subscriber
/// @param[in] event the type of the event which should be detached
void iox_sub_detach_event(iox_sub_t const self, const ENUM iox_SubscriberEvent event);


#endif
57 changes: 57 additions & 0 deletions iceoryx_binding_c/include/iceoryx_binding_c/trigger_info.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright (c) 2020 by 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.

#ifndef IOX_BINDING_C_TRIGGER_INFO_H
#define IOX_BINDING_C_TRIGGER_INFO_H

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

/// @brief trigger state handle
typedef CLASS TriggerInfo* iox_trigger_info_t;

/// @brief returns the id of the trigger
/// @param[in] self handle to trigger state
/// @return triggerId
uint64_t iox_trigger_info_get_trigger_id(iox_trigger_info_t const self);

/// @brief does the trigger originate from a certain subscriber
/// @param[in] self handle to trigger state
/// @param[in] subscriber handle to the subscriber in question
/// @return true if the trigger originates from the subscriber, otherwise false
bool iox_trigger_info_does_originate_from_subscriber(iox_trigger_info_t const self, iox_sub_t const subscriber);

/// @brief does the trigger originate from a certain user trigger
/// @param[in] self handle to trigger state
/// @param[in] user_trigger handle to the user trigger in question
/// @return true if the trigger originates from the user trigger, otherwise false
bool iox_trigger_info_does_originate_from_user_trigger(iox_trigger_info_t const self,
iox_user_trigger_t const user_trigger);

/// @brief acquires the handle of the subscriber origin
/// @param[in] self handle to trigger state
/// @return the handle to the subscriber if the trigger originated from a subscriber, otherwise NULL
iox_sub_t iox_trigger_info_get_subscriber_origin(iox_trigger_info_t const self);

/// @brief acquires the handle of the user trigger origin
/// @param[in] self handle to trigger state
/// @return the handle to the user trigger if the trigger originated from a user trigger, otherwise NULL
iox_user_trigger_t iox_trigger_info_get_user_trigger_origin(iox_trigger_info_t const self);

/// @brief calls the callback of the trigger
/// @param[in] self handle to trigger state
void iox_trigger_info_call(iox_trigger_info_t const self);

#endif
28 changes: 20 additions & 8 deletions iceoryx_binding_c/include/iceoryx_binding_c/types.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2020 by Robert Bosch GmbH, 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.
Expand Down Expand Up @@ -28,27 +28,31 @@ struct iox_ws_storage_t_
{
// the value of the array size is the result of the following formula:
// sizeof(WaitSet) / 8
uint64_t do_not_touch_me[133];
uint64_t do_not_touch_me[2308];
};
typedef struct iox_ws_storage_t_ iox_ws_storage_t;

struct iox_guard_cond_storage_t_
struct iox_user_trigger_storage_t_
{
// the value of the array size is the result of the following formula:
// sizeof(GuardCondition) / 8
// sizeof(UserTrigger) / 8
#if defined(__APPLE__)
uint64_t do_not_touch_me[12];
uint64_t do_not_touch_me[16];
#else
uint64_t do_not_touch_me[9];
uint64_t do_not_touch_me[13];
#endif
};
typedef struct iox_guard_cond_storage_t_ iox_guard_cond_storage_t;
typedef struct iox_user_trigger_storage_t_ iox_user_trigger_storage_t;

struct iox_sub_storage_t_
{
// the value of the array size is the result of the following formula:
// sizeof(cpp2c_Subscriber) / 8
uint64_t do_not_touch_me[3];
#if defined(__APPLE__)
uint64_t do_not_touch_me[16];
#else
uint64_t do_not_touch_me[13];
#endif
};
typedef struct iox_sub_storage_t_ iox_sub_storage_t;

Expand All @@ -60,5 +64,13 @@ struct iox_pub_storage_t_
};
typedef struct iox_pub_storage_t_ iox_pub_storage_t;

struct iox_trigger_info_storage_t_
{
// the value of the array size is the result of the following formula:
// sizeof(cpp2c_Publisher) / 8
uint64_t do_not_touch_me[7];
};
typedef struct iox_trigger_info_storage_t_ iox_trigger_info_storage_t;


#endif
Loading

0 comments on commit 1574dca

Please sign in to comment.