Skip to content

Commit

Permalink
Refs #12390. Always get statistics publisher's impl
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>
  • Loading branch information
richiware committed Aug 30, 2021
1 parent 7f5d083 commit 7779ca0
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
14 changes: 14 additions & 0 deletions src/cpp/fastdds/domain/DomainParticipantImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,15 @@ Publisher* DomainParticipantImpl::create_publisher(
const PublisherQos& qos,
PublisherListener* listener,
const StatusMask& mask)
{
return create_publisher(qos, nullptr, listener, mask);
}

Publisher* DomainParticipantImpl::create_publisher(
const PublisherQos& qos,
PublisherImpl** impl,
PublisherListener* listener,
const StatusMask& mask)
{
if (!PublisherImpl::check_qos(qos))
{
Expand Down Expand Up @@ -507,6 +516,11 @@ Publisher* DomainParticipantImpl::create_publisher(
(void)ret_publisher_enable;
}

if (impl)
{
*impl = pubimpl;
}

return pub;
}

Expand Down
14 changes: 14 additions & 0 deletions src/cpp/fastdds/domain/DomainParticipantImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,20 @@ class DomainParticipantImpl
PublisherListener* listener = nullptr,
const StatusMask& mask = StatusMask::all());

/**
* Create a Publisher in this Participant.
* @param qos QoS of the Publisher.
* @param[out] impl Return a pointer to the created Publisher's implementation.
* @param listenerer Pointer to the listener.
* @param mask StatusMask
* @return Pointer to the created Publisher.
*/
Publisher* create_publisher(
const PublisherQos& qos,
PublisherImpl** impl,
PublisherListener* listener = nullptr,
const StatusMask& mask = StatusMask::all());

/**
* Create a Publisher in this Participant.
* @param profile_name Publisher profile name.
Expand Down
14 changes: 7 additions & 7 deletions src/cpp/statistics/fastdds/domain/DomainParticipantImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,7 @@ efd::PublisherImpl* DomainParticipantImpl::create_publisher_impl(
const efd::PublisherQos& qos,
efd::PublisherListener* listener)
{
auto impl = new PublisherImpl(this, qos, listener, statistics_listener_);
if (nullptr == builtin_publisher_impl_)
{
builtin_publisher_impl_ = impl;
}
return impl;
return new PublisherImpl(this, qos, listener, statistics_listener_);
}

efd::SubscriberImpl* DomainParticipantImpl::create_subscriber_impl(
Expand All @@ -243,8 +238,13 @@ efd::SubscriberImpl* DomainParticipantImpl::create_subscriber_impl(

void DomainParticipantImpl::create_statistics_builtin_entities()
{
efd::PublisherImpl* builtin_publisher_impl = nullptr;

// Builtin publisher
builtin_publisher_ = create_publisher(efd::PUBLISHER_QOS_DEFAULT);
builtin_publisher_ = create_publisher(efd::PUBLISHER_QOS_DEFAULT, &builtin_publisher_impl);

builtin_publisher_impl_ = dynamic_cast<PublisherImpl*>(builtin_publisher_impl);
assert(nullptr != builtin_publisher_impl_);

// Enable statistics datawriters
// 1. Find fastdds_statistics PropertyPolicyQos
Expand Down

0 comments on commit 7779ca0

Please sign in to comment.