Skip to content

Commit

Permalink
iox-eclipse-iceoryx#252 icedelivery on c skeleton created
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Eltzschig <christian.eltzschig2@de.bosch.com>
  • Loading branch information
elfenpiff committed Aug 19, 2020
1 parent 4ce1297 commit c9109ae
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 18 deletions.
11 changes: 10 additions & 1 deletion iceoryx_binding_c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,19 @@ include(IceoryxPlatformDetection)
#
setup_package_name_and_create_files(
NAME ${PROJECT_NAME}
NAMESPACE iceoryx_dds
NAMESPACE iceoryx_binding_c
PROJECT_PREFIX ${PREFIX}
)

#
########## find_package in source tree ##########
#
set(${PROJECT_NAME}_DIR ${CMAKE_CURRENT_LIST_DIR}/cmake
CACHE FILEPATH
"${PROJECT_NAME}Config.cmake to make find_package(${PROJECT_NAME}) work in source tree!"
FORCE
)

#
########## build building-block library ##########
#
Expand Down
27 changes: 17 additions & 10 deletions iceoryx_binding_c/include/iceoryx_binding_c/subscriber.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,23 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <stdint.h>

#ifndef IOX_BINDING_C_SUBSCRIBER_H_
#define IOX_BINDING_C_SUBSCRIBER_H_


#ifdef __cplusplus
#include <cstdint>

#define CLASS
#define ENUM
#else
#include <stdbool.h>
#include <stdint.h>

#define CLASS struct
#define ENUM enum
#endif

enum subscriber_SubscriptionState
{
NOT_SUBSCRIBED = 0,
Expand All @@ -34,18 +46,13 @@ enum subscriber_AllocateError
INTERNAL_ERROR,
};

#ifdef __cplusplus
#define CLASS
#else
#define CLASS struct
#endif

CLASS SubscriberPortData* subscriber_new();
void subscriber_delete(CLASS SubscriberPortData* const self);
void subscriber_subscribe(CLASS SubscriberPortData* const self, const uint64_t queueCapacity);
void subscriber_unsubscribe(CLASS SubscriberPortData* const self);
subscriber_SubscriptionState subscriber_getSubscriptionState(CLASS SubscriberPortData* const self);
subscriber_AllocateError subscriber_getChunk(CLASS SubscriberPortData* const self, const CLASS ChunkHeader** const);
ENUM subscriber_SubscriptionState subscriber_getSubscriptionState(CLASS SubscriberPortData* const self);
ENUM subscriber_AllocateError subscriber_getChunk(CLASS SubscriberPortData* const self,
const CLASS ChunkHeader** const);
void subscriber_releaseChunk(CLASS SubscriberPortData* const self, const CLASS ChunkHeader* const);
void subscriber_releaseQueuedChunks(CLASS SubscriberPortData* const self);
bool subscriber_hasNewChunks(CLASS SubscriberPortData* const self);
Expand Down
4 changes: 4 additions & 0 deletions iceoryx_binding_c/source/subscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,24 @@ using namespace iox::cxx;
using namespace iox::popo;
using namespace iox::capro;

#include <iostream>

SubscriberPortData* subscriber_new()
{
std::cout << __PRETTY_FUNCTION__ << std::endl;
return new SubscriberPortData(
ServiceDescription{1, 2, 3}, "bla", VariantQueueTypes::FiFo_SingleProducerSingleConsumer);
}

void subscriber_delete(SubscriberPortData* const self)
{
std::cout << __PRETTY_FUNCTION__ << std::endl;
delete self;
}

void subscriber_subscribe(SubscriberPortData* const self, const uint64_t queueCapacity)
{
std::cout << __PRETTY_FUNCTION__ << std::endl;
SubscriberPortUser(self).subscribe(queueCapacity);
}

Expand Down
36 changes: 36 additions & 0 deletions iceoryx_examples/icedelivery_on_c/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Build icedelivery example
cmake_minimum_required(VERSION 3.5)
project(example_icedelivery_on_c)

include(GNUInstallDirs)

find_package(iceoryx_posh CONFIG REQUIRED)
find_package(iceoryx_binding_c CONFIG REQUIRED)

get_target_property(ICEORYX_CXX_STANDARD iceoryx_posh::iceoryx_posh CXX_STANDARD)
if ( NOT ICEORYX_CXX_STANDARD )
include(IceoryxPlatformDetection)
endif ( NOT ICEORYX_CXX_STANDARD )

add_executable(iox-c-publisher ./ice_c_publisher.c)
target_link_libraries(iox-c-publisher
iceoryx_posh::iceoryx_posh
iceoryx_binding_c::iceoryx_binding_c
)
set_target_properties(iox-c-publisher PROPERTIES
POSITION_INDEPENDENT_CODE ON
)

add_executable(iox-c-subscriber ./ice_c_subscriber.c)
target_link_libraries(iox-c-subscriber
iceoryx_posh::iceoryx_posh
iceoryx_binding_c::iceoryx_binding_c
)
set_target_properties(iox-c-subscriber PROPERTIES
POSITION_INDEPENDENT_CODE ON
)

install(
TARGETS iox-c-publisher iox-c-subscriber
RUNTIME DESTINATION bin
)
Empty file.
22 changes: 22 additions & 0 deletions iceoryx_examples/icedelivery_on_c/ice_c_publisher.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) 2020 by Robert Bosch GmbH. 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.

void sending()
{
}

int main()
{
return 0;
}
27 changes: 27 additions & 0 deletions iceoryx_examples/icedelivery_on_c/ice_c_subscriber.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) 2020 by Robert Bosch GmbH. 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.

#include "iceoryx_binding_c/subscriber.h"

void receiving()
{
}

int main()
{
struct SubscriberPortData* subscriber = subscriber_new();
subscriber_subscribe(subscriber, 10);
subscriber_delete(subscriber);
return 0;
}
25 changes: 25 additions & 0 deletions iceoryx_examples/icedelivery_on_c/topic_data.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) 2020 by Robert Bosch GmbH. 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_EXAMPLES_ICEDELIVERY_ON_C_TOPIC_DATA_HPP
#define IOX_EXAMPLES_ICEDELIVERY_ON_C_TOPIC_DATA_HPP

#include <stdint.h>

struct CounterTopic
{
uint32_t counter;
};

#endif // IOX_EXAMPLES_ICEDELIVERY_TOPIC_DATA_HPP
15 changes: 8 additions & 7 deletions iceoryx_meta/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@ if(introspection)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../tools/introspection ${CMAKE_BINARY_DIR}/iceoryx_introspection)
endif(introspection)

if(examples)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../iceoryx_examples/icedelivery ${CMAKE_BINARY_DIR}/iceoryx_examples/icedelivery)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../iceoryx_examples/iceperf ${CMAKE_BINARY_DIR}/iceoryx_examples/iceperf)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../iceoryx_examples/singleprocess ${CMAKE_BINARY_DIR}/iceoryx_examples/singleprocess)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../iceoryx_examples/benchmark_optional_and_expected ${CMAKE_BINARY_DIR}/iceoryx_examples/benchmark_optional_and_expected)
endif(examples)

# ===== Gateways
if(dds_gateway)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/cyclonedds ${CMAKE_BINARY_DIR}/dependencies/cyclonedds/prebuild)
Expand All @@ -60,6 +53,14 @@ if(binding_c)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../iceoryx_binding_c ${CMAKE_BINARY_DIR}/iceoryx_binding_c)
endif(binding_c)

# ===== Examples
if(examples)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../iceoryx_examples/icedelivery ${CMAKE_BINARY_DIR}/iceoryx_examples/icedelivery)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../iceoryx_examples/icedelivery_on_c ${CMAKE_BINARY_DIR}/iceoryx_examples/icedelivery_on_c)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../iceoryx_examples/iceperf ${CMAKE_BINARY_DIR}/iceoryx_examples/iceperf)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../iceoryx_examples/singleprocess ${CMAKE_BINARY_DIR}/iceoryx_examples/singleprocess)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../iceoryx_examples/benchmark_optional_and_expected ${CMAKE_BINARY_DIR}/iceoryx_examples/benchmark_optional_and_expected)
endif(examples)


message("")
Expand Down

0 comments on commit c9109ae

Please sign in to comment.