Skip to content

Commit

Permalink
iox-eclipse-iceoryx#91 Replace std::string in PortManager and RouDiPr…
Browse files Browse the repository at this point in the history
…ocess

Signed-off-by: Hoinkis Simon (CC-AD/ESW1) <simon.hoinkis2@de.bosch.com>
  • Loading branch information
mossmaurice committed Aug 25, 2020
1 parent 5ddecf3 commit 4f6251a
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 134 deletions.
20 changes: 10 additions & 10 deletions iceoryx_posh/include/iceoryx_posh/internal/roudi/port_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace iox
{
namespace roudi
{
capro::Interfaces StringToCaProInterface(const std::string& str);
capro::Interfaces StringToCaProInterface(const cxx::CString100& str);

class PortManager
{
Expand All @@ -58,31 +58,31 @@ class PortManager

virtual cxx::expected<SenderPortType::MemberType_t*, PortPoolError>
acquireSenderPortData(const capro::ServiceDescription& service,
const std::string& processName,
const cxx::CString100& processName,
mepoo::MemoryManager* payloadMemoryManager,
const std::string& runnable = "",
const cxx::CString100& runnable = "",
const PortConfigInfo& portConfigInfo = PortConfigInfo());

virtual ReceiverPortType::MemberType_t*
acquireReceiverPortData(const capro::ServiceDescription& service,
const std::string& processName,
const std::string& runnable = "",
const cxx::CString100& processName,
const cxx::CString100& runnable = "",
const PortConfigInfo& portConfigInfo = PortConfigInfo());

popo::InterfacePortData* acquireInterfacePortData(capro::Interfaces interface,
const std::string& processName,
const std::string& runnable = "");
const cxx::CString100& processName,
const cxx::CString100& runnable = "");

popo::ApplicationPortData* acquireApplicationPortData(const std::string& processName);
popo::ApplicationPortData* acquireApplicationPortData(const cxx::CString100& processName);

runtime::RunnableData* acquireRunnableData(const cxx::CString100& process, const cxx::CString100& runnable);

cxx::expected<popo::ConditionVariableData*, PortPoolError>
acquireConditionVariableData(const cxx::CString100& processName);

bool areAllReceiverPortsSubscribed(std::string appName);
bool areAllReceiverPortsSubscribed(const cxx::CString100& appName);

void deletePortsOfProcess(std::string processName);
void deletePortsOfProcess(const cxx::CString100& processName);

void destroySenderPort(SenderPortType::MemberType_t* const senderPortData);

Expand Down
60 changes: 30 additions & 30 deletions iceoryx_posh/include/iceoryx_posh/internal/roudi/roudi_process.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
#include "iceoryx_posh/internal/roudi/port_manager.hpp"
#include "iceoryx_posh/internal/runtime/message_queue_interface.hpp"
#include "iceoryx_posh/mepoo/chunk_header.hpp"
#include "iceoryx_utils/fixed_string/string100.hpp"
#include "iceoryx_utils/posix_wrapper/posix_access_rights.hpp"

#include <csignal>
#include <cstdint>
#include <ctime>
#include <list>
#include <string>

namespace iox
{
Expand All @@ -44,7 +44,7 @@ class RouDiProcess
/// @param [in] isMonitored indicates if the process should be monitored for being alive
/// @param [in] payloadSegmentId is an identifier for the shm payload segment
/// @param [in] sessionId is an ID generated by RouDi to prevent sending outdated mqueue transmission
RouDiProcess(std::string name,
RouDiProcess(cxx::CString100 name,
int32_t pid,
mepoo::MemoryManager* payloadMemoryManager,
bool isMonitored,
Expand All @@ -60,7 +60,7 @@ class RouDiProcess

int32_t getPid() const noexcept;

const std::string& getName() const noexcept;
const cxx::CString100 getName() const noexcept;

void sendToMQ(const runtime::MqMessage& data) noexcept;

Expand Down Expand Up @@ -96,16 +96,16 @@ class ProcessManagerInterface
/// @param [in] sessionId the sender expects to be currently valid
/// @return true if the message was delivered, false otherwise
virtual bool
sendMessageToProcess(const std::string& name, const iox::runtime::MqMessage& message, const uint64_t sessionId) = 0;
sendMessageToProcess(const cxx::CString100& name, const iox::runtime::MqMessage& message, const uint64_t sessionId) = 0;

// port handling
virtual ReceiverPortType addInternalReceiverPort(const capro::ServiceDescription& service,
const std::string& process_name) = 0;
const cxx::CString100& process_name) = 0;
virtual SenderPortType addInternalSenderPort(const capro::ServiceDescription& service,
const std::string& process_name) = 0;
virtual void removeInternalPorts(const std::string& process_name) = 0;
virtual void sendServiceRegistryChangeCounterToProcess(const std::string& process_name) = 0;
virtual bool areAllReceiverPortsSubscribed(const std::string& process_name) = 0;
const cxx::CString100& process_name) = 0;
virtual void removeInternalPorts(const cxx::CString100& process_name) = 0;
virtual void sendServiceRegistryChangeCounterToProcess(const cxx::CString100& process_name) = 0;
virtual bool areAllReceiverPortsSubscribed(const cxx::CString100& process_name) = 0;
virtual void discoveryUpdate() = 0;

// enable data-triggering -> based on receiver port
Expand Down Expand Up @@ -135,7 +135,7 @@ class ProcessManager : public ProcessManagerInterface
/// @param [in] isMonitored indicates if the process should be monitored for being alive
/// @param [in] transmissionTimestamp is an ID for the application to check for the expected response
/// @param [in] sessionId is an ID generated by RouDi to prevent sending outdated mqueue transmission
bool registerProcess(const std::string& name,
bool registerProcess(const cxx::CString100& name,
int32_t pid,
posix::PosixUser user,
bool isMonitored,
Expand All @@ -144,25 +144,25 @@ class ProcessManager : public ProcessManagerInterface

void killAllProcesses() noexcept;

void updateLivlinessOfProcess(const std::string& name) noexcept;
void updateLivlinessOfProcess(const cxx::CString100& name) noexcept;

void findServiceForProcess(const std::string& name, const capro::ServiceDescription& service) noexcept;
void findServiceForProcess(const cxx::CString100& name, const capro::ServiceDescription& service) noexcept;

void
addInterfaceForProcess(const std::string& name, capro::Interfaces interface, const std::string& runnable) noexcept;
addInterfaceForProcess(const cxx::CString100& name, capro::Interfaces interface, const cxx::CString100& runnable) noexcept;

void addApplicationForProcess(const std::string& name) noexcept;
void addApplicationForProcess(const cxx::CString100& name) noexcept;

void addRunnableForProcess(const std::string& process, const std::string& runnable) noexcept;
void addRunnableForProcess(const cxx::CString100& process, const cxx::CString100& runnable) noexcept;

void addReceiverForProcess(const std::string& name,
void addReceiverForProcess(const cxx::CString100& name,
const capro::ServiceDescription& service,
const std::string& runnable,
const cxx::CString100& runnable,
const PortConfigInfo& portConfigInfo = PortConfigInfo()) noexcept;

void addSenderForProcess(const std::string& name,
void addSenderForProcess(const cxx::CString100& name,
const capro::ServiceDescription& service,
const std::string& runnable,
const cxx::CString100& runnable,
const PortConfigInfo& portConfigInfo = PortConfigInfo()) noexcept;

void addConditionVariableForProcess(const cxx::CString100& processName) noexcept;
Expand All @@ -172,35 +172,35 @@ class ProcessManager : public ProcessManagerInterface
void run() noexcept;

SenderPortType addIntrospectionSenderPort(const capro::ServiceDescription& service,
const std::string& process_name) noexcept;
const cxx::CString100& process_name) noexcept;

/// @brief Notify the application that it sent an unsupported message
void sendMessageNotSupportedToRuntime(const std::string& name) noexcept;
void sendMessageNotSupportedToRuntime(const cxx::CString100& name) noexcept;

// BEGIN ProcessActivationInterface
/// @brief This is an interface to send messages to processes handled by a ProcessManager
/// @param [in] name of the process the message shall be delivered
/// @param [in] message which shall be delivered
/// @param [in] sessionId the sender expects to be currently valid
/// @return true if the message was delivered, false otherwise
bool sendMessageToProcess(const std::string& name,
bool sendMessageToProcess(const cxx::CString100& name,
const iox::runtime::MqMessage& message,
const uint64_t sessionId) noexcept override;
// END

// BEGIN PortHandling interface
ReceiverPortType addInternalReceiverPort(const capro::ServiceDescription& service,
const std::string& process_name) noexcept override;
const cxx::CString100& process_name) noexcept override;
SenderPortType addInternalSenderPort(const capro::ServiceDescription& service,
const std::string& process_name) noexcept override;
void removeInternalPorts(const std::string& process_name) noexcept override;
void sendServiceRegistryChangeCounterToProcess(const std::string& process_name) noexcept override;
const cxx::CString100& process_name) noexcept override;
void removeInternalPorts(const cxx::CString100& process_name) noexcept override;
void sendServiceRegistryChangeCounterToProcess(const cxx::CString100& process_name) noexcept override;

bool areAllReceiverPortsSubscribed(const std::string& process_name) noexcept override;
bool areAllReceiverPortsSubscribed(const cxx::CString100& process_name) noexcept override;
// END

private:
RouDiProcess* getProcessFromList(const std::string& name) noexcept;
RouDiProcess* getProcessFromList(const cxx::CString100& name) noexcept;
void monitorProcesses() noexcept;
void discoveryUpdate() noexcept override;

Expand All @@ -211,15 +211,15 @@ class ProcessManager : public ProcessManagerInterface
/// @param [in] transmissionTimestamp is an ID for the application to check for the expected response
/// @param [in] payloadSegmentId is an identifier for the shm payload segment
/// @param [in] sessionId is an ID generated by RouDi to prevent sending outdated mqueue transmission
bool addProcess(const std::string& name,
bool addProcess(const cxx::CString100& name,
int32_t pid,
mepoo::MemoryManager* payloadMemoryManager,
bool isMonitored,
int64_t transmissionTimestamp,
const uint64_t payloadSegmentId,
const uint64_t sessionId) noexcept;

bool removeProcess(const std::string& name) noexcept;
bool removeProcess(const cxx::CString100& name) noexcept;

RouDiMemoryInterface& m_roudiMemoryInterface;
PortManager& m_portManager;
Expand Down
26 changes: 13 additions & 13 deletions iceoryx_posh/source/roudi/port_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace iox
{
namespace roudi
{
capro::Interfaces StringToCaProInterface(const std::string& str)
capro::Interfaces StringToCaProInterface(const cxx::CString100& str)
{
int32_t i;
cxx::convert::fromString(str.c_str(), i);
Expand Down Expand Up @@ -379,7 +379,7 @@ void PortManager::sendToAllMatchingInterfacePorts(const capro::CaproMessage& mes
}
}

bool PortManager::areAllReceiverPortsSubscribed(std::string appName)
bool PortManager::areAllReceiverPortsSubscribed(const cxx::CString100& appName)
{
int32_t numberOfReceiverPorts{0};
int32_t numberOfConnectedReceiverPorts{0};
Expand All @@ -396,7 +396,7 @@ bool PortManager::areAllReceiverPortsSubscribed(std::string appName)
return numberOfReceiverPorts == numberOfConnectedReceiverPorts;
}

void PortManager::deletePortsOfProcess(std::string processName)
void PortManager::deletePortsOfProcess(const cxx::CString100& processName)
{
for (auto port : m_portPool->senderPortDataList())
{
Expand Down Expand Up @@ -518,9 +518,9 @@ const std::atomic<uint64_t>* PortManager::serviceRegistryChangeCounter()

cxx::expected<SenderPortType::MemberType_t*, PortPoolError>
PortManager::acquireSenderPortData(const capro::ServiceDescription& service,
const std::string& processName,
const cxx::CString100& processName,
mepoo::MemoryManager* payloadMemoryManager,
const std::string& runnable,
const cxx::CString100& runnable,
const PortConfigInfo& portConfigInfo)
{
// check if already in list, we currently do not support multi publisher for one CaPro ID
Expand Down Expand Up @@ -557,8 +557,8 @@ PortManager::acquireSenderPortData(const capro::ServiceDescription& service,

/// @todo return a cxx::expected
ReceiverPortType::MemberType_t* PortManager::acquireReceiverPortData(const capro::ServiceDescription& service,
const std::string& processName,
const std::string& runnable,
const cxx::CString100& processName,
const cxx::CString100& runnable,
const PortConfigInfo& portConfigInfo)
{
auto result = m_portPool->addReceiverPort(service, processName, portConfigInfo.memoryInfo);
Expand All @@ -575,8 +575,8 @@ ReceiverPortType::MemberType_t* PortManager::acquireReceiverPortData(const capro

/// @todo return a cxx::expected
popo::InterfacePortData* PortManager::acquireInterfacePortData(capro::Interfaces interface,
const std::string& processName,
const std::string& /*runnable*/)
const cxx::CString100& processName,
const cxx::CString100& /*runnable*/)
{
auto result = m_portPool->addInterfacePort(processName, interface);
if (!result.has_error())
Expand All @@ -590,7 +590,7 @@ popo::InterfacePortData* PortManager::acquireInterfacePortData(capro::Interfaces
}

/// @todo return a cxx::expected
popo::ApplicationPortData* PortManager::acquireApplicationPortData(const std::string& processName)
popo::ApplicationPortData* PortManager::acquireApplicationPortData(const cxx::CString100& processName)
{
auto result = m_portPool->addApplicationPort(processName);
if (!result.has_error())
Expand All @@ -603,14 +603,14 @@ popo::ApplicationPortData* PortManager::acquireApplicationPortData(const std::st
}
}

void PortManager::addEntryToServiceRegistry(const capro::IdString& service, const capro::IdString& instance) noexcept
void PortManager::addEntryToServiceRegistry(const cxx::CString100& service, const cxx::CString100& instance) noexcept
{
m_serviceRegistry.add(service, instance);
m_portPool->serviceRegistryChangeCounter()->fetch_add(1, std::memory_order_relaxed);
}

void PortManager::removeEntryFromServiceRegistry(const capro::IdString& service,
const capro::IdString& instance) noexcept
void PortManager::removeEntryFromServiceRegistry(const cxx::CString100& service,
const cxx::CString100& instance) noexcept
{
m_serviceRegistry.remove(service, instance);
m_portPool->serviceRegistryChangeCounter()->fetch_add(1, std::memory_order_relaxed);
Expand Down
Loading

0 comments on commit 4f6251a

Please sign in to comment.