Skip to content

Commit

Permalink
iox-eclipse-iceoryx#404 Address reviewing findings making params in P…
Browse files Browse the repository at this point in the history
…rocess c'tor const and check if callable contains value

Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
  • Loading branch information
mossmaurice authored and marthtz committed May 12, 2021
1 parent 980ae7b commit 3c550d7
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class PortManager
acquirePublisherPortData(const capro::ServiceDescription& service,
const popo::PublisherOptions& publisherOptions,
const ProcessName_t& processName,
mepoo::MemoryManager* payloadMemoryManager,
mepoo::MemoryManager* const payloadMemoryManager,
const PortConfigInfo& portConfigInfo) noexcept;

cxx::expected<SubscriberPortType::MemberType_t*, PortPoolError>
Expand Down Expand Up @@ -133,8 +133,8 @@ class PortManager
void removeEntryFromServiceRegistry(const capro::IdString_t& service, const capro::IdString_t& instance) noexcept;

template <typename T, std::enable_if_t<std::is_same<T, iox::build::OneToManyPolicy>::value>* = nullptr>
cxx::optional<ProcessName_t>
doesViolateCommunicationPolicy(const capro::ServiceDescription& service) const noexcept;
cxx::optional<ProcessName_t> doesViolateCommunicationPolicy(const capro::ServiceDescription& service) const
noexcept;

template <typename T, std::enable_if_t<std::is_same<T, iox::build::ManyToManyPolicy>::value>* = nullptr>
cxx::optional<ProcessName_t> doesViolateCommunicationPolicy(const capro::ServiceDescription& service
Expand Down
12 changes: 6 additions & 6 deletions iceoryx_posh/include/iceoryx_posh/internal/roudi/process.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ class Process
/// @param [in] payloadSegmentId is an identifier for the shm payload segment
/// @param [in] sessionId is an ID generated by RouDi to prevent sending outdated IPC channel transmission
Process(const ProcessName_t& name,
int32_t pid,
mepoo::MemoryManager* payloadMemoryManager,
bool isMonitored,
const uint32_t pid,
mepoo::MemoryManager* const payloadMemoryManager,
const bool isMonitored,
const uint64_t payloadSegmentId,
const uint64_t sessionId) noexcept;

Expand All @@ -60,7 +60,7 @@ class Process
Process& operator=(Process&& other) = delete;
~Process() = default;

int32_t getPid() const noexcept;
uint32_t getPid() const noexcept;

const ProcessName_t getName() const noexcept;

Expand All @@ -74,7 +74,7 @@ class Process

mepoo::TimePointNs_t getTimestamp() noexcept;

mepoo::MemoryManager* getPayloadMemoryManager() const noexcept;
mepoo::MemoryManager& getPayloadMemoryManager() const noexcept;
uint64_t getPayloadSegmentId() const noexcept;

bool isMonitored() const noexcept;
Expand All @@ -83,7 +83,7 @@ class Process
int m_pid;
runtime::IpcInterfaceUser m_ipcChannel;
mepoo::TimePointNs_t m_timestamp;
mepoo::MemoryManager* m_payloadMemoryManager{nullptr};
mepoo::MemoryManager* const m_payloadMemoryManager{nullptr};
bool m_isMonitored{true};
uint64_t m_payloadSegmentId;
std::atomic<uint64_t> m_sessionId;
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_posh/source/roudi/port_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ cxx::expected<PublisherPortRouDiType::MemberType_t*, PortPoolError>
PortManager::acquirePublisherPortData(const capro::ServiceDescription& service,
const popo::PublisherOptions& publisherOptions,
const ProcessName_t& processName,
mepoo::MemoryManager* payloadMemoryManager,
mepoo::MemoryManager* const payloadMemoryManager,
const PortConfigInfo& portConfigInfo) noexcept
{
if (doesViolateCommunicationPolicy<iox::build::CommunicationPolicy>(service).and_then(
Expand Down
12 changes: 6 additions & 6 deletions iceoryx_posh/source/roudi/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ namespace iox
namespace roudi
{
Process::Process(const ProcessName_t& name,
int32_t pid,
mepoo::MemoryManager* payloadMemoryManager,
bool isMonitored,
const uint32_t pid,
mepoo::MemoryManager* const payloadMemoryManager,
const bool isMonitored,
const uint64_t payloadSegmentId,
const uint64_t sessionId) noexcept
: m_pid(pid)
Expand All @@ -41,7 +41,7 @@ Process::Process(const ProcessName_t& name,
{
}

int32_t Process::getPid() const noexcept
uint32_t Process::getPid() const noexcept
{
return m_pid;
}
Expand Down Expand Up @@ -76,9 +76,9 @@ mepoo::TimePointNs_t Process::getTimestamp() noexcept
return m_timestamp;
}

mepoo::MemoryManager* Process::getPayloadMemoryManager() const noexcept
mepoo::MemoryManager& Process::getPayloadMemoryManager() const noexcept
{
return m_payloadMemoryManager;
return *m_payloadMemoryManager;
}

uint64_t Process::getPayloadSegmentId() const noexcept
Expand Down
14 changes: 10 additions & 4 deletions iceoryx_posh/source/roudi/process_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ void ProcessManager::addPublisherForProcess(const ProcessName_t& name,
name,
[&](Process& process) { // create a PublisherPort
auto maybePublisher = m_portManager.acquirePublisherPortData(
service, publisherOptions, name, process.getPayloadMemoryManager(), portConfigInfo);
service, publisherOptions, name, &process.getPayloadMemoryManager(), portConfigInfo);

if (!maybePublisher.has_error())
{
Expand Down Expand Up @@ -722,11 +722,17 @@ bool ProcessManager::searchForProcessAndThen(const ProcessName_t& name,
{
if (name == it->getName())
{
AndThenCallable(*it);
return true;
if (AndThenCallable)
{
AndThenCallable(*it);
return true;
}
}
}
OrElseCallable();
if (OrElseCallable)
{
OrElseCallable();
}
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion iceoryx_posh/test/moduletests/test_roudi_process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ TEST_F(Process_test, getSessionId)
TEST_F(Process_test, getPayloadMemoryManager)
{
Process roudiproc(processname, pid, payloadMemoryManager, isMonitored, payloadSegmentId, sessionId);
EXPECT_THAT(roudiproc.getPayloadMemoryManager(), Eq(payloadMemoryManager));
EXPECT_THAT(&roudiproc.getPayloadMemoryManager(), Eq(payloadMemoryManager));
}

TEST_F(Process_test, sendViaIpcChannelPass)
Expand Down

0 comments on commit 3c550d7

Please sign in to comment.