Skip to content

Iox #27 add client and server port to runtime, roudi and process manager [stacked PR #3] #1087

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2019 - 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2020 - 2021 by Apex.AI Inc. All rights reserved.
// Copyright (c) 2020 - 2022 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.
Expand Down Expand Up @@ -38,12 +38,18 @@ namespace iox
error(POSH__RUNTIME_PUBLISHER_PORT_NOT_UNIQUE) \
error(POSH__RUNTIME_PUBLISHER_PORT_CREATION_UNKNOWN_ERROR) \
error(POSH__RUNTIME_SUBSCRIBER_PORT_CREATION_UNKNOWN_ERROR) \
error(POSH__RUNTIME_CLIENT_PORT_CREATION_UNKNOWN_ERROR) \
error(POSH__RUNTIME_SERVER_PORT_CREATION_UNKNOWN_ERROR) \
error(POSH__RUNTIME_ROUDI_PUBLISHER_LIST_FULL) \
error(POSH__RUNTIME_ROUDI_SUBSCRIBER_LIST_FULL) \
error(POSH__RUNTIME_ROUDI_OUT_OF_CLIENTS) \
error(POSH__RUNTIME_ROUDI_OUT_OF_SERVERS) \
error(POSH__RUNTIME_ROUDI_CONDITION_VARIABLE_LIST_FULL) \
error(POSH__RUNTIME_ROUDI_EVENT_VARIABLE_LIST_FULL) \
error(POSH__RUNTIME_ROUDI_REQUEST_PUBLISHER_WRONG_IPC_MESSAGE_RESPONSE) \
error(POSH__RUNTIME_ROUDI_REQUEST_SUBSCRIBER_WRONG_IPC_MESSAGE_RESPONSE) \
error(POSH__RUNTIME_ROUDI_REQUEST_CLIENT_WRONG_IPC_MESSAGE_RESPONSE) \
error(POSH__RUNTIME_ROUDI_REQUEST_SERVER_WRONG_IPC_MESSAGE_RESPONSE) \
error(POSH__RUNTIME_ROUDI_REQUEST_CONDITION_VARIABLE_WRONG_IPC_MESSAGE_RESPONSE) \
error(POSH__RUNTIME_ROUDI_REQUEST_EVENT_VARIABLE_WRONG_MESSAGE_QUEUE_RESPONSE) \
error(POSH__RUNTIME_ROUDI_GET_MW_INTERFACE_WRONG_IPC_MESSAGE_RESPONSE) \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,30 @@ class ProcessManager : public ProcessManagerInterface
const popo::PublisherOptions& publisherOptions,
const PortConfigInfo& portConfigInfo = PortConfigInfo()) noexcept;

/// @brief Adds a client port to the internal process object and sends it to the OS process
/// @param[in] name is the name of the runtime requesting the port
/// @param[in] service is the service description for the new client port
/// @param[in] clientOptions like the queue capacity and queue full policy by a client
/// @param[in] portConfigInfo configuration information for the port
/// (what type of port is requested, device where its payload memory is located on etc.)
/// @return pointer to a created client port data
void addClientForProcess(const RuntimeName_t& name,
const capro::ServiceDescription& service,
const popo::ClientOptions& clientOptions,
const PortConfigInfo& portConfigInfo) noexcept;

/// @brief Adds a server port to the internal process object and sends it to the OS process
/// @param[in] name is the name of the runtime requesting the port
/// @param[in] service is the service description for the new server port
/// @param[in] serverOptions like the queue capacity and queue full policy by a server
/// @param[in] portConfigInfo configuration information for the port
/// (what type of port is requested, device where its payload memory is located on etc.)
/// @return pointer to a created server port data
void addServerForProcess(const RuntimeName_t& name,
const capro::ServiceDescription& service,
const popo::ServerOptions& serverOptions,
const PortConfigInfo& portConfigInfo) noexcept;

void addConditionVariableForProcess(const RuntimeName_t& runtimeName) noexcept;

void initIntrospection(ProcessIntrospectionType* processIntrospection) noexcept;
Expand All @@ -135,9 +159,7 @@ class ProcessManager : public ProcessManagerInterface


private:
bool searchForProcessAndThen(const RuntimeName_t& name,
cxx::function_ref<void(Process&)> AndThenCallable,
cxx::function_ref<void()> OrElseCallable) noexcept;
cxx::optional<Process*> findProcess(const RuntimeName_t& name) noexcept;

void monitorProcesses() noexcept;
void discoveryUpdate() noexcept override;
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_posh/include/iceoryx_posh/internal/roudi/roudi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class RouDi
RouDi& operator=(const RouDi& other) = delete;
RouDi(const RouDi& other) = delete;

RouDi(RouDiMemoryInterface& roudiMemoryInteface,
RouDi(RouDiMemoryInterface& roudiMemoryInterface,
PortManager& portManager,
RoudiStartupParameters roudiStartupParameters) noexcept;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2021 by Apex.AI Inc. All rights reserved.
// Copyright (c) 2021 - 2022 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.
Expand Down Expand Up @@ -56,6 +56,10 @@ enum class IpcMessageType : int32_t
CREATE_PUBLISHER_ACK,
CREATE_SUBSCRIBER,
CREATE_SUBSCRIBER_ACK,
CREATE_CLIENT,
CREATE_CLIENT_ACK,
CREATE_SERVER,
CREATE_SERVER_ACK,
CREATE_INTERFACE,
CREATE_INTERFACE_ACK,
CREATE_CONDITION_VARIABLE,
Expand Down Expand Up @@ -86,10 +90,16 @@ enum class IpcMessageErrorType : int32_t
REQUEST_PUBLISHER_WRONG_IPC_MESSAGE_RESPONSE,
REQUEST_PUBLISHER_NO_WRITABLE_SHM_SEGMENT,
REQUEST_SUBSCRIBER_WRONG_IPC_MESSAGE_RESPONSE,
REQUEST_CLIENT_WRONG_IPC_MESSAGE_RESPONSE,
REQUEST_CLIENT_NO_WRITABLE_SHM_SEGMENT,
REQUEST_SERVER_WRONG_IPC_MESSAGE_RESPONSE,
REQUEST_SERVER_NO_WRITABLE_SHM_SEGMENT,
REQUEST_CONDITION_VARIABLE_WRONG_IPC_MESSAGE_RESPONSE,
REQUEST_EVENT_VARIABLE_WRONG_IPC_MESSAGE_RESPONSE,
PUBLISHER_LIST_FULL,
SUBSCRIBER_LIST_FULL,
CLIENT_LIST_FULL,
SERVER_LIST_FULL,
CONDITION_VARIABLE_LIST_FULL,
EVENT_VARIABLE_LIST_FULL,
NODE_DATA_LIST_FULL,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2021 by Apex.AI Inc. All rights reserved.
// Copyright (c) 2021 - 2022 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.
Expand Down Expand Up @@ -55,6 +55,18 @@ class PoshRuntimeImpl : public PoshRuntime
const popo::SubscriberOptions& subscriberOptions = popo::SubscriberOptions(),
const PortConfigInfo& portConfigInfo = PortConfigInfo()) noexcept override;

/// @copydoc PoshRuntime::getMiddlewareClient
popo::ClientPortUser::MemberType_t*
getMiddlewareClient(const capro::ServiceDescription& service,
const popo::ClientOptions& clientOptions = {},
const PortConfigInfo& portConfigInfo = PortConfigInfo()) noexcept override;

/// @copydoc PoshRuntime::getMiddlewareServer
popo::ServerPortUser::MemberType_t*
getMiddlewareServer(const capro::ServiceDescription& service,
const popo::ServerOptions& ServerOptions = {},
const PortConfigInfo& portConfigInfo = PortConfigInfo()) noexcept override;

/// @copydoc PoshRuntime::getMiddlewareInterface
popo::InterfacePortData* getMiddlewareInterface(const capro::Interfaces interface,
const NodeName_t& nodeName = {""}) noexcept override;
Expand Down Expand Up @@ -83,6 +95,12 @@ class PoshRuntimeImpl : public PoshRuntime
cxx::expected<SubscriberPortUserType::MemberType_t*, IpcMessageErrorType>
requestSubscriberFromRoudi(const IpcMessage& sendBuffer) noexcept;

cxx::expected<popo::ClientPortUser::MemberType_t*, IpcMessageErrorType>
requestClientFromRoudi(const IpcMessage& sendBuffer) noexcept;

cxx::expected<popo::ServerPortUser::MemberType_t*, IpcMessageErrorType>
requestServerFromRoudi(const IpcMessage& sendBuffer) noexcept;

cxx::expected<popo::ConditionVariableData*, IpcMessageErrorType>
requestConditionVariableFromRoudi(const IpcMessage& sendBuffer) noexcept;

Expand Down
28 changes: 27 additions & 1 deletion iceoryx_posh/include/iceoryx_posh/runtime/posh_runtime.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2021 by Apex.AI Inc. All rights reserved.
// Copyright (c) 2021 - 2022 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.
Expand All @@ -21,11 +21,15 @@
#include "iceoryx_posh/capro/service_description.hpp"
#include "iceoryx_posh/iceoryx_posh_types.hpp"
#include "iceoryx_posh/internal/popo/building_blocks/condition_variable_data.hpp"
#include "iceoryx_posh/internal/popo/ports/client_port_user.hpp"
#include "iceoryx_posh/internal/popo/ports/interface_port.hpp"
#include "iceoryx_posh/internal/popo/ports/publisher_port_user.hpp"
#include "iceoryx_posh/internal/popo/ports/server_port_user.hpp"
#include "iceoryx_posh/internal/popo/ports/subscriber_port_user.hpp"
#include "iceoryx_posh/internal/runtime/ipc_runtime_interface.hpp"
#include "iceoryx_posh/internal/runtime/node_property.hpp"
#include "iceoryx_posh/popo/client_options.hpp"
#include "iceoryx_posh/popo/server_options.hpp"
#include "iceoryx_posh/popo/subscriber_options.hpp"
#include "iceoryx_posh/runtime/port_config_info.hpp"

Expand Down Expand Up @@ -95,6 +99,28 @@ class PoshRuntime
const popo::SubscriberOptions& subscriberOptions = {},
const PortConfigInfo& portConfigInfo = {}) noexcept = 0;

/// @brief request the RouDi daemon to create a client port
/// @param[in] serviceDescription service description for the new client port
/// @param[in] clientOptions like the queue capacity and queue full policy by a client
/// @param[in] portConfigInfo configuration information for the port
/// (what type of port is requested, device where its payload memory is located on etc.)
/// @return pointer to a created client port data
virtual popo::ClientPortData*
getMiddlewareClient(const capro::ServiceDescription& service,
const popo::ClientOptions& clientOptions = {},
const PortConfigInfo& portConfigInfo = PortConfigInfo()) noexcept = 0;

/// @brief request the RouDi daemon to create a server port
/// @param[in] serviceDescription service description for the new server port
/// @param[in] serverOptions like the queue capacity and queue full policy by a server
/// @param[in] portConfigInfo configuration information for the port
/// (what type of port is requested, device where its payload memory is located on etc.)
/// @return pointer to a created server port data
virtual popo::ServerPortData*
getMiddlewareServer(const capro::ServiceDescription& service,
const popo::ServerOptions& serverOptions = {},
const PortConfigInfo& portConfigInfo = PortConfigInfo()) noexcept = 0;

/// @brief request the RouDi daemon to create an interface port
/// @param[in] interface interface to create
/// @param[in] nodeName name of the node where the interface should belong to
Expand Down
Loading