Skip to content

Commit

Permalink
iox-eclipse-iceoryx#32 merging with master and reverting PROJECT_PREF…
Browse files Browse the repository at this point in the history
…IX to not use iceoryx

Signed-off-by: Christian Eltzschig <[email protected]>
  • Loading branch information
elfenpiff committed Jun 25, 2020
2 parents ce11042 + 87ffb17 commit 0fc970a
Show file tree
Hide file tree
Showing 51 changed files with 1,973 additions and 950 deletions.
45 changes: 27 additions & 18 deletions iceoryx_dds_gateway/CMakeLists.txt → iceoryx_dds/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.7)

set(iceoryx_dds_gateway_VERSION 0.1.0)
project(iceoryx_dds_gateway VERSION ${iceoryx_dds_gateway_VERSION})
file (STRINGS "../VERSION" iceoryx_dds_VERSION)
project(iceoryx_dds VERSION ${iceoryx_dds_VERSION})

option(BUILD_TESTS "build test binaries")

Expand All @@ -15,7 +15,7 @@ include(IceoryxPackageHelper)
#
setup_package_name_and_create_files(
NAME ${PROJECT_NAME}
NAMESPACE iceoryx_dds_gateway
NAMESPACE iceoryx_dds
PROJECT_PREFIX ${PREFIX}
)

Expand All @@ -34,33 +34,34 @@ endif()
#
########## build building-block library ##########
#
add_library(ioxdds
add_library(iceoryx_dds
STATIC
source/ioxdds/log/logging.cpp
source/iceoryx_dds/log/logging.cpp
)
add_library(${PROJECT_NAMESPACE}::ioxdds ALIAS ioxdds)
add_library(${PROJECT_NAMESPACE}::iceoryx_dds ALIAS iceoryx_dds)

target_compile_options(ioxdds PUBLIC -std=c++11)
target_compile_options(iceoryx_dds PUBLIC -std=c++11)

target_include_directories(ioxdds
target_include_directories(iceoryx_dds
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/${PREFIX}>
)
target_link_libraries(ioxdds
target_link_libraries(iceoryx_dds
PRIVATE
iceoryx_posh::iceoryx_posh
iceoryx_utils::iceoryx_utils
)

if(USE_CYCLONE_DDS)
target_sources(ioxdds
target_sources(iceoryx_dds
PRIVATE
source/ioxdds/dds/cyclone_data_writer.cpp
source/iceoryx_dds/dds/cyclone_data_reader.cpp
source/iceoryx_dds/dds/cyclone_data_writer.cpp
)
target_compile_definitions(ioxdds PUBLIC -DUSE_CYCLONE_DDS)
target_compile_definitions(iceoryx_dds PUBLIC -DUSE_CYCLONE_DDS)
idl_ddscxx_generate(mempoolMessages_lib "msg/Mempool.idl")
target_link_libraries(ioxdds
target_link_libraries(iceoryx_dds
PUBLIC
CycloneDDS_CXX_API::ddscxx
mempoolMessages_lib
Expand All @@ -70,12 +71,20 @@ endif()
#
########## build gateway apps ##########
#
add_executable(gateway_iox2dds
source/iox2dds_app/main.cpp
add_executable(gateway_iceoryx2dds
source/iceoryx2dds_app/main.cpp
)
target_link_libraries(gateway_iox2dds
target_link_libraries(gateway_iceoryx2dds
iceoryx_posh::iceoryx_posh
${PROJECT_NAMESPACE}::ioxdds
${PROJECT_NAMESPACE}::iceoryx_dds
)

add_executable(gateway_dds2iceoryx
source/dds2iceoryx_app/main.cpp
)
target_link_libraries(gateway_dds2iceoryx
iceoryx_posh::iceoryx_posh
${PROJECT_NAMESPACE}::iceoryx_dds
)

#
Expand All @@ -89,7 +98,7 @@ endif(BUILD_TESTS)
########## export library ##########
#
setup_install_directories_and_export_package(
TARGETS gateway_iox2dds
TARGETS gateway_iceoryx2dds gateway_dds2iceoryx
INCLUDE_DIRECTORY include/
)

File renamed without changes.
File renamed without changes.
File renamed without changes.
34 changes: 34 additions & 0 deletions iceoryx_dds/include/iceoryx_dds/dds/cyclone_data_reader.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// 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_DDS_DDS_CYCLONE_DATA_READER_HPP
#define IOX_DDS_DDS_CYCLONE_DATA_READER_HPP

#include "iceoryx_dds/dds/data_reader.hpp"

namespace iox
{
namespace dds
{
/// @note Implementation coming soon.
class CycloneDataReader : DataReader<CycloneDataReader>
{
public:
CycloneDataReader(IdString serviceId, IdString instanceId, IdString eventId) noexcept;
};

} // namespace dds
} // namespace iox

#endif // IOX_DDS_DDS_CYCLONE_DATA_READER_HPP
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
// 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_DDS_GATEWAY_DDS_CYCLONE_DATA_WRITER_HPP
#define IOX_DDS_GATEWAY_DDS_CYCLONE_DATA_WRITER_HPP

#ifndef IOX_DDS_DDS_CYCLONE_DATA_WRITER_HPP
#define IOX_DDS_DDS_CYCLONE_DATA_WRITER_HPP

#include "iceoryx_dds/dds/data_writer.hpp"

#include <Mempool_DCPS.hpp>
#include <dds/dds.hpp>

#include "ioxdds/dds/data_writer.hpp"

namespace iox
{
Expand Down Expand Up @@ -61,4 +63,4 @@ class CycloneDataWriter : public iox::dds::DataWriter<CycloneDataWriter>
} // namespace dds
} // namespace iox

#endif // IOX_DDS_GATEWAY_DDS_CYCLONE_DATA_WRITER_HPP
#endif // IOX_DDS_DDS_CYCLONE_DATA_WRITER_HPP
34 changes: 34 additions & 0 deletions iceoryx_dds/include/iceoryx_dds/dds/data_reader.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// 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_DDS_DDS_DATA_READER_HPP
#define IOX_DDS_DDS_DATA_READER_HPP

#include "iceoryx_utils/cxx/string.hpp"

namespace iox
{
namespace dds
{
using IdString = iox::cxx::string<100u>;

/// @note Implementation coming soon.
template <typename Impl>
class DataReader
{
};
} // namespace dds
} // namespace iox

#endif // IOX_DDS_DDS_DATA_READER_HPP
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
// 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_DDS_GATEWAY_DDS_DATA_WRITER_HPP
#define IOX_DDS_GATEWAY_DDS_DATA_WRITER_HPP

#include <cstdint>
#ifndef IOX_DDS_DDS_DATA_WRITER_HPP
#define IOX_DDS_DDS_DATA_WRITER_HPP

#include "iceoryx_utils/cxx/string.hpp"

#include <iceoryx_utils/cxx/string.hpp>
#include <cstdint>

namespace iox
{
Expand Down Expand Up @@ -72,6 +73,6 @@ class DataWriter
} // namespace dds
} // namespace iox

#include "ioxdds/internal/dds/data_writer.inl"
#include "iceoryx_dds/internal/dds/data_writer.inl"

#endif // IOX_DDS_GATEWAY_DDS_DATA_WRITER_HPP
#endif // IOX_DDS_DDS_DATA_WRITER_HPP
32 changes: 32 additions & 0 deletions iceoryx_dds/include/iceoryx_dds/dds/dds_config.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// 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_DDS_DDS_CONFIG_HPP
#define IOX_DDS_DDS_CONFIG_HPP

#include "iceoryx_posh/iceoryx_posh_types.hpp"

namespace iox
{
namespace dds
{
static constexpr units::Duration DISCOVERY_PERIOD = 1000_ms;
static constexpr units::Duration FORWARDING_PERIOD = 50_ms;
static constexpr uint32_t SUBSCRIBER_CACHE_SIZE = 128u;
static constexpr uint32_t MAX_CHANNEL_NUMBER = iox::MAX_PORT_NUMBER;

} // namespace dds
} // namespace iox

#endif // IOX_DDS_DDS_CONFIG_HPP
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
// 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_DDS_GATEWAY_DDS_DDS_TYPES_HPP
#define IOX_DDS_GATEWAY_DDS_DDS_TYPES_HPP

#include "ioxdds/dds/data_writer.hpp"
#ifndef IOX_DDS_DDS_DDS_TYPES_HPP
#define IOX_DDS_DDS_DDS_TYPES_HPP

#ifdef USE_CYCLONE_DDS
#include "ioxdds/dds/cyclone_data_writer.hpp"
#include "iceoryx_dds/dds/cyclone_data_reader.hpp"
#include "iceoryx_dds/dds/cyclone_data_writer.hpp"
#else
#error "A DDS implementation must be provided."
#endif
Expand All @@ -26,13 +26,17 @@ namespace iox
{
namespace dds
{
// Fixed strings
using IdString = iox::cxx::string<100u>;

// DDS implementation defined with compiler flags
#ifdef USE_CYCLONE_DDS
using data_reader_t = iox::dds::CycloneDataReader;
using data_writer_t = iox::dds::CycloneDataWriter;
#else
#error "A DDS implementation must be set."
#endif
}
}
} // namespace dds
} // namespace iox

#endif // IOX_DDS_GATEWAY_DDS_DDS_TYPES_HPP
#endif // IOX_DDS_DDS_DDS_TYPES_HPP
87 changes: 87 additions & 0 deletions iceoryx_dds/include/iceoryx_dds/gateway/channel.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// 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_DDS_GATEWAY_CHANNEL_HPP
#define IOX_DDS_GATEWAY_CHANNEL_HPP

#include "iceoryx_dds/dds/dds_config.hpp"
#include "iceoryx_posh/capro/service_description.hpp"
#include "iceoryx_utils/cxx/expected.hpp"
#include "iceoryx_utils/internal/objectpool/objectpool.hpp"

#include <memory>

namespace iox
{
namespace dds
{
enum class ChannelError : uint8_t
{
OBJECT_POOL_FULL
};

///
/// @class Channel
/// @brief A data structure representing a channel between Iceoryx and DDS.
///
/// The class couples related iceoryx and dds entities that communicate with eachother to form the communication
/// channel.
/// For example: An Iceoryx subscriber and its corresponding DDS data writer, which communicate eachother to form
/// an outbound communication channel.
/// These entites are conceptualized as channel "Terminals".
///
/// The structure holds pointers to the instances of the terminals.
/// The terminals can be created and managed externally, in which case the structure only serves as a means of coupling
/// the two.
/// This can be achieved by simply calling the constructor with pointers to them.
///
/// Alternatively, the class can manage the terminals internally in a static object pool, automatically
/// cleaning them up when the channel is discarded.
/// This can be achieved via the Channel::create method.
///
template <typename IceoryxTerminal, typename DDSTerminal>
class Channel
{
using IceoryxTerminalPtr = std::shared_ptr<IceoryxTerminal>;
using IceoryxTerminalPool = iox::cxx::ObjectPool<IceoryxTerminal, MAX_CHANNEL_NUMBER>;
using DDSTerminalPtr = std::shared_ptr<DDSTerminal>;
using DDSTerminalPool = iox::cxx::ObjectPool<DDSTerminal, MAX_CHANNEL_NUMBER>;

public:
Channel(const iox::capro::ServiceDescription& service,
const IceoryxTerminalPtr iceoryxTerminal,
const DDSTerminalPtr ddsTerminal) noexcept;
constexpr bool operator==(const Channel<IceoryxTerminal, DDSTerminal>& rhs) const noexcept;

static iox::cxx::expected<Channel, ChannelError> create(const iox::capro::ServiceDescription& service) noexcept;

iox::capro::ServiceDescription getService() const noexcept;
IceoryxTerminalPtr getIceoryxTerminal() const noexcept;
DDSTerminalPtr getDDSTerminal() const noexcept;

private:
static IceoryxTerminalPool s_iceoryxTerminals;
static DDSTerminalPool s_ddsTerminals;

iox::capro::ServiceDescription m_service;
IceoryxTerminalPtr m_iceoryxTerminal;
DDSTerminalPtr m_ddsTerminal;
};

} // namespace dds
} // namespace iox

#include "iceoryx_dds/internal/gateway/channel.inl"

#endif // IOX_DDS_DDS_DDS_TYPES_HPP
Loading

0 comments on commit 0fc970a

Please sign in to comment.