Skip to content
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

iox-#2044 Use new fixed position container #2053

Merged
merged 2 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
#ifndef IOX_POSH_ROUDI_INTROSPECTION_PORT_INTROSPECTION_HPP
#define IOX_POSH_ROUDI_INTROSPECTION_PORT_INTROSPECTION_HPP

#include "fixed_size_container.hpp"
#include "iceoryx_hoofs/internal/concurrent/periodic_task.hpp"
#include "iceoryx_posh/iceoryx_posh_types.hpp"
#include "iceoryx_posh/internal/popo/ports/publisher_port_data.hpp"
#include "iceoryx_posh/roudi/introspection_types.hpp"
#include "iox/fixed_position_container.hpp"
#include "iox/function.hpp"

#include <atomic>
Expand Down Expand Up @@ -55,10 +55,16 @@ class PortIntrospection
class PortData
{
private:
/// internal helper classes
struct Dummy
{
};
using PublisherContainerIndexType = typename FixedPositionContainer<Dummy, MAX_PUBLISHERS>::IndexType;
using ConnectionContainerIndexType = typename FixedPositionContainer<Dummy, MAX_SUBSCRIBERS>::IndexType;

struct ConnectionInfo;

/// internal helper classes

struct PublisherInfo
{
PublisherInfo() noexcept
Expand All @@ -83,8 +89,8 @@ class PortIntrospection
TimePointNs_t m_sequenceNumberTimestamp{DurationNs_t(0)};
mepoo::SequenceNumber_t m_sequenceNumber{0U};

/// map from indices to object pointers
std::map<int, ConnectionInfo*> connectionMap;
/// map from indices to ConnectionContainer indices
std::map<int, ConnectionContainerIndexType> connectionMap;
int index{-1};
};

Expand Down Expand Up @@ -123,12 +129,12 @@ class PortIntrospection
}

SubscriberInfo subscriberInfo;
PublisherInfo* publisherInfo{nullptr};
iox::optional<PublisherContainerIndexType> publisherInfoIndex;
ConnectionState state{ConnectionState::DEFAULT};

bool isConnected() const noexcept
{
return publisherInfo && state == ConnectionState::CONNECTED;
return publisherInfoIndex.has_value() && state == ConnectionState::CONNECTED;
}
};

Expand Down Expand Up @@ -208,16 +214,14 @@ class PortIntrospection
void setNew(bool value) noexcept;

private:
using PublisherContainer = FixedSizeContainer<PublisherInfo, MAX_PUBLISHERS>;
using ConnectionContainer = FixedSizeContainer<ConnectionInfo, MAX_SUBSCRIBERS>;
using PublisherContainer = FixedPositionContainer<PublisherInfo, MAX_PUBLISHERS>;
using ConnectionContainer = FixedPositionContainer<ConnectionInfo, MAX_SUBSCRIBERS>;

/// @brief inner map maps from unique port IDs to indices in the PublisherContainer
std::map<capro::ServiceDescription, std::map<popo::UniquePortId, typename PublisherContainer::Index_t>>
m_publisherMap;
std::map<capro::ServiceDescription, std::map<popo::UniquePortId, PublisherContainerIndexType>> m_publisherMap;

/// inner map maps from unique port IDs to indices in the ConnectionContainer
std::map<capro::ServiceDescription, std::map<popo::UniquePortId, typename ConnectionContainer::Index_t>>
m_connectionMap;
std::map<capro::ServiceDescription, std::map<popo::UniquePortId, ConnectionContainerIndexType>> m_connectionMap;

/// @note we avoid allocating the objects on the heap but can still use a map
/// to locate/remove them fast(er)
Expand Down
Loading