Skip to content

Commit

Permalink
Merge pull request #931 from ApexAI/iox-#930-add-c-binding-for-posh-s…
Browse files Browse the repository at this point in the history
…ettings

Iox #930 add c binding for posh settings
  • Loading branch information
elfenpiff authored Sep 29, 2021
2 parents 72a5cf7 + 86920f7 commit 9075a87
Show file tree
Hide file tree
Showing 6 changed files with 279 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

**Features:**

- C binding for posh configuration [\#930](https://github.com/eclipse-iceoryx/iceoryx/issues/930)
- Enhance MacOS performance with timed{send,receive} functionality in unix domain socket[\#903](https://github.com/eclipse-iceoryx/iceoryx/issues/903)
- Multi-Publisher support for DDS gateway and generic gateway class [\#900](https://github.com/eclipse-iceoryx/iceoryx/issues/900)
- Replace `iox-gw-iceoryx2dds` and `iox-gw-dds2iceoryx` gateways with `iox-dds-gateway` [\#900](https://github.com/eclipse-iceoryx/iceoryx/issues/900)
Expand Down
1 change: 1 addition & 0 deletions iceoryx_binding_c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ set(${PROJECT_NAME}_DIR ${CMAKE_CURRENT_LIST_DIR}/cmake
########## build building-block library ##########
#
add_library(${PROJECT_NAME}
source/c_config.cpp
source/c_notification_info.cpp
source/c_listener.cpp
source/c_node.cpp
Expand Down
94 changes: 94 additions & 0 deletions iceoryx_binding_c/include/iceoryx_binding_c/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// Copyright (c) 2021 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.
//
// SPDX-License-Identifier: Apache-2.0

#ifndef IOX_BINDING_C_CONFIG_H
#define IOX_BINDING_C_CONFIG_H

#include <stdint.h>

/// @brief returns maximum supported amount of publishers
uint32_t iox_cfg_max_publishers();

/// @brief returns maximum amount of subscribers which can be subscribed to one publisher
uint32_t iox_cfg_max_subscribers_per_publisher();

/// @brief returns maximum amount of samples a publisher can acquire at the same time with loan
uint32_t iox_cfg_max_chunks_allocated_per_publisher_simultaneously();

/// @brief returns maximum history size for a publisher (e.g. samples which are hold back so
// that new subscribers can acquire past data)
uint64_t iox_cfg_max_publisher_history();

/// @brief returns maximum supported amount of subscribers
uint32_t iox_cfg_max_subscribers();

/// @brief returns the maximum amount of samples which a subscriber can hold without releasing them
uint32_t iox_cfg_max_chunks_held_per_subscriber_simultaneously();

/// @brief returns the maximum subscriber queue capacity which is used when the publisher delivers samples to the
/// subscriber if the queue capacity is reached new samples will discard old samples
uint32_t iox_cfg_max_subscriber_queue_capacity();

/// @brief returns the maximum supported amount of condition variables. this determines how many listeners and waitsets
/// can be used in one iceoryx system
uint32_t iox_cfg_max_number_of_condition_variables();

/// @brief returns the maximum supported amount of notifiers per condition variable. this determines how many
/// attachments a listener or waitset can have
uint32_t iox_cfg_max_number_of_notifiers_per_condition_variable();

/// @brief returns the maximum amount of attachments per waitset
/// @note is less or equal to iox_cfg_max_number_of_notifiers_per_condition_variable
uint32_t iox_cfg_max_number_of_attachments_per_waitset();

/// @brief returns the maximum amount of evens per listener
/// @note is less or equal to iox_cfg_max_number_of_notifiers_per_condition_variable
uint32_t iox_cfg_max_number_of_events_per_listener();

/// @brief returns the maximum amount of mempools for roudi. restricts also the number of mempools in the roudi config
/// file
uint32_t iox_cfg_max_number_of_mempools();

/// @brief returns the maximum number of shared memory segments. restricts also the number of configurable segments in
/// the roudi config file
uint32_t iox_cfg_max_shm_segments();

/// @brief returns the maximum supported amount of shared memory providers
uint32_t iox_cfg_max_number_of_memory_provider();

/// @brief returns the maximum supported amount of memory blocks per shared memory provider
uint32_t iox_cfg_max_number_of_memory_blocks_per_memory_provider();

/// @brief returns the alignment of the user payload when it is not set explicitly
uint32_t iox_cfg_chunk_default_user_payload_alignment();

/// @brief returns the size of the user header when no user header is requested by the user
uint32_t iox_cfg_no_user_header_size();

/// @brief returns the alignment of the user header when no user header is requested by the user
uint32_t iox_cfg_no_user_header_alignment();

/// @brief returns the maximum supported amount of processes which can register at roudi by initializing the posh
/// runtime
uint32_t iox_cfg_max_process_number();

/// @brief returns the maximum supported amount of services
uint32_t iox_cfg_max_number_of_services();

/// @brief returns the maximum runtime name length
uint32_t iox_cfg_max_runtime_name_length();

#endif // IOX_BINDING_C_CONFIG_H
126 changes: 126 additions & 0 deletions iceoryx_binding_c/source/c_config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
// Copyright (c) 2021 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.
//
// SPDX-License-Identifier: Apache-2.0

#include "iceoryx_posh/iceoryx_posh_types.hpp"

extern "C" {
#include "iceoryx_binding_c/config.h"
}

uint32_t iox_cfg_max_publishers()
{
return iox::MAX_PUBLISHERS;
}

uint32_t iox_cfg_max_subscribers_per_publisher()
{
return iox::MAX_SUBSCRIBERS_PER_PUBLISHER;
}

uint32_t iox_cfg_max_chunks_allocated_per_publisher_simultaneously()
{
return iox::MAX_CHUNKS_ALLOCATED_PER_PUBLISHER_SIMULTANEOUSLY;
}

uint64_t iox_cfg_max_publisher_history()
{
return iox::MAX_PUBLISHER_HISTORY;
}

uint32_t iox_cfg_max_subscribers()
{
return iox::MAX_SUBSCRIBERS;
}

uint32_t iox_cfg_max_chunks_held_per_subscriber_simultaneously()
{
return iox::MAX_CHUNKS_HELD_PER_SUBSCRIBER_SIMULTANEOUSLY;
}

uint32_t iox_cfg_max_subscriber_queue_capacity()
{
return iox::MAX_SUBSCRIBER_QUEUE_CAPACITY;
}

uint32_t iox_cfg_max_number_of_condition_variables()
{
return iox::MAX_NUMBER_OF_CONDITION_VARIABLES;
}

uint32_t iox_cfg_max_number_of_notifiers_per_condition_variable()
{
return iox::MAX_NUMBER_OF_NOTIFIERS_PER_CONDITION_VARIABLE;
}

uint32_t iox_cfg_max_number_of_attachments_per_waitset()
{
return iox::MAX_NUMBER_OF_ATTACHMENTS_PER_WAITSET;
}

uint32_t iox_cfg_max_number_of_events_per_listener()
{
return iox::MAX_NUMBER_OF_EVENTS_PER_LISTENER;
}

uint32_t iox_cfg_max_number_of_mempools()
{
return iox::MAX_NUMBER_OF_MEMPOOLS;
}

uint32_t iox_cfg_max_shm_segments()
{
return iox::MAX_SHM_SEGMENTS;
}

uint32_t iox_cfg_max_number_of_memory_provider()
{
return iox::MAX_NUMBER_OF_MEMORY_PROVIDER;
}

uint32_t iox_cfg_max_number_of_memory_blocks_per_memory_provider()
{
return iox::MAX_NUMBER_OF_MEMORY_BLOCKS_PER_MEMORY_PROVIDER;
}

uint32_t iox_cfg_chunk_default_user_payload_alignment()
{
return iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT;
}

uint32_t iox_cfg_no_user_header_size()
{
return iox::CHUNK_NO_USER_HEADER_SIZE;
}

uint32_t iox_cfg_no_user_header_alignment()
{
return iox::CHUNK_NO_USER_HEADER_ALIGNMENT;
}

uint32_t iox_cfg_max_process_number()
{
return iox::MAX_PROCESS_NUMBER;
}

uint32_t iox_cfg_max_number_of_services()
{
return iox::MAX_NUMBER_OF_SERVICES;
}

uint32_t iox_cfg_max_runtime_name_length()
{
return iox::MAX_RUNTIME_NAME_LENGTH;
}
57 changes: 57 additions & 0 deletions iceoryx_binding_c/test/moduletests/test_config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright (c) 2021 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.
//
// SPDX-License-Identifier: Apache-2.0

extern "C" {
#include "iceoryx_binding_c/config.h"
}

#include "iceoryx_posh/iceoryx_posh_types.hpp"

#include "test.hpp"

namespace
{
using namespace iox;

TEST(iox_cfg, valuesAreCorrectlyConnected)
{
EXPECT_EQ(iox_cfg_max_publishers(), iox::MAX_PUBLISHERS);
EXPECT_EQ(iox_cfg_max_subscribers_per_publisher(), iox::MAX_SUBSCRIBERS_PER_PUBLISHER);
EXPECT_EQ(iox_cfg_max_chunks_allocated_per_publisher_simultaneously(),
iox::MAX_CHUNKS_ALLOCATED_PER_PUBLISHER_SIMULTANEOUSLY);
EXPECT_EQ(iox_cfg_max_publisher_history(), iox::MAX_PUBLISHER_HISTORY);
EXPECT_EQ(iox_cfg_max_subscribers(), iox::MAX_SUBSCRIBERS);
EXPECT_EQ(iox_cfg_max_chunks_held_per_subscriber_simultaneously(),
iox::MAX_CHUNKS_HELD_PER_SUBSCRIBER_SIMULTANEOUSLY);
EXPECT_EQ(iox_cfg_max_subscriber_queue_capacity(), iox::MAX_SUBSCRIBER_QUEUE_CAPACITY);
EXPECT_EQ(iox_cfg_max_number_of_condition_variables(), iox::MAX_NUMBER_OF_CONDITION_VARIABLES);
EXPECT_EQ(iox_cfg_max_number_of_notifiers_per_condition_variable(),
iox::MAX_NUMBER_OF_NOTIFIERS_PER_CONDITION_VARIABLE);
EXPECT_EQ(iox_cfg_max_number_of_attachments_per_waitset(), iox::MAX_NUMBER_OF_ATTACHMENTS_PER_WAITSET);
EXPECT_EQ(iox_cfg_max_number_of_events_per_listener(), iox::MAX_NUMBER_OF_EVENTS_PER_LISTENER);
EXPECT_EQ(iox_cfg_max_number_of_mempools(), iox::MAX_NUMBER_OF_MEMPOOLS);
EXPECT_EQ(iox_cfg_max_shm_segments(), iox::MAX_SHM_SEGMENTS);
EXPECT_EQ(iox_cfg_max_number_of_memory_provider(), iox::MAX_NUMBER_OF_MEMORY_PROVIDER);
EXPECT_EQ(iox_cfg_max_number_of_memory_blocks_per_memory_provider(),
iox::MAX_NUMBER_OF_MEMORY_BLOCKS_PER_MEMORY_PROVIDER);
EXPECT_EQ(iox_cfg_chunk_default_user_payload_alignment(), iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT);
EXPECT_EQ(iox_cfg_no_user_header_size(), iox::CHUNK_NO_USER_HEADER_SIZE);
EXPECT_EQ(iox_cfg_no_user_header_alignment(), iox::CHUNK_NO_USER_HEADER_ALIGNMENT);
EXPECT_EQ(iox_cfg_max_process_number(), iox::MAX_PROCESS_NUMBER);
EXPECT_EQ(iox_cfg_max_number_of_services(), iox::MAX_NUMBER_OF_SERVICES);
EXPECT_EQ(iox_cfg_max_runtime_name_length(), iox::MAX_RUNTIME_NAME_LENGTH);
}
} // namespace
4 changes: 0 additions & 4 deletions iceoryx_posh/include/iceoryx_posh/iceoryx_posh_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ using UniquePortId = popo::TypedUniqueId<popo::BasePortData>;

using SubscriberPortType = iox::build::CommunicationPolicy;

/// @todo remove MAX_RECEIVERS_PER_SENDERPORT when the new port building blocks are used
constexpr uint32_t MAX_RECEIVERS_PER_SENDERPORT = build::IOX_MAX_SUBSCRIBERS_PER_PUBLISHER;

//--------- Communication Resources Start---------------------
// Publisher
constexpr uint32_t MAX_PUBLISHERS = build::IOX_MAX_PUBLISHERS;
Expand Down Expand Up @@ -107,7 +104,6 @@ constexpr uint32_t MAX_NUMBER_OF_ATTACHMENTS_PER_WAITSET = 128U;
static_assert(MAX_NUMBER_OF_ATTACHMENTS_PER_WAITSET <= MAX_NUMBER_OF_NOTIFIERS_PER_CONDITION_VARIABLE,
"The WaitSet capacity is restricted by the maximum amount of notifiers per condition variable.");
// Listener
constexpr uint8_t MAX_NUMBER_OF_EVENT_VARIABLES = 128U;
constexpr uint8_t MAX_NUMBER_OF_EVENTS_PER_LISTENER = 128U;
static_assert(MAX_NUMBER_OF_EVENTS_PER_LISTENER <= MAX_NUMBER_OF_NOTIFIERS_PER_CONDITION_VARIABLE,
"The Listener capacity is restricted by the maximum amount of notifiers per condition variable.");
Expand Down

0 comments on commit 9075a87

Please sign in to comment.