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

[20869] Create DomainParticipantExtendedQos class #4779

Merged
merged 8 commits into from
Jun 24, 2024
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
25 changes: 25 additions & 0 deletions include/fastdds/dds/domain/DomainParticipantFactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include <fastdds/dds/core/ReturnCode.hpp>
#include <fastdds/dds/core/status/StatusMask.hpp>
#include <fastdds/dds/domain/qos/DomainParticipantExtendedQos.hpp>
#include <fastdds/dds/domain/qos/DomainParticipantFactoryQos.hpp>
#include <fastdds/dds/domain/qos/DomainParticipantQos.hpp>
#include <fastdds/dds/xtypes/dynamic_types/DynamicType.hpp>
Expand Down Expand Up @@ -93,6 +94,19 @@ class DomainParticipantFactory
DomainParticipantListener* listener = nullptr,
const StatusMask& mask = StatusMask::all());

/**
* Create a Participant.
*
* @param extended_qos DomainParticipantExtendedQos Reference.
* @param listener DomainParticipantListener Pointer (default: nullptr)
* @param mask StatusMask Reference (default: all)
* @return DomainParticipant pointer. (nullptr if not created.)
*/
FASTDDS_EXPORTED_API DomainParticipant* create_participant(
const DomainParticipantExtendedQos& extended_qos,
DomainParticipantListener* listener = nullptr,
const StatusMask& mask = StatusMask::all());

/**
* Create a Participant with default domain id and qos.
*
Expand Down Expand Up @@ -214,6 +228,17 @@ class DomainParticipantFactory
const std::string& profile_name,
DomainParticipantQos& qos) const;

/**
* Fills the DomainParticipantExtendedQos with the values of the XML profile.
*
* @param profile_name DomainParticipant profile name.
* @param extended_qos DomainParticipantExtendedQos object where the domain and qos are returned.
* @return RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise.
*/
FASTDDS_EXPORTED_API ReturnCode_t get_participant_extended_qos_from_profile(
const std::string& profile_name,
DomainParticipantExtendedQos& extended_qos) const;

/**
* Remove a Participant and all associated publishers and subscribers.
*
Expand Down
102 changes: 102 additions & 0 deletions include/fastdds/dds/domain/qos/DomainParticipantExtendedQos.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* @file DomainParticipantExtendedQos.hpp
*
*/

#ifndef _FASTDDS_PARTICIPANTEXTENDEDQOS_HPP_
#define _FASTDDS_PARTICIPANTEXTENDEDQOS_HPP_

#include <fastdds/fastdds_dll.hpp>
elianalf marked this conversation as resolved.
Show resolved Hide resolved

#include "DomainParticipantQos.hpp"

namespace eprosima {
namespace fastdds {
namespace dds {

class DomainParticipantExtendedQos : public DomainParticipantQos
{
public:

/**
* @brief Constructor
*/
FASTDDS_EXPORTED_API DomainParticipantExtendedQos()
{
}

/**
* @brief Destructor
*/
FASTDDS_EXPORTED_API virtual ~DomainParticipantExtendedQos()
{
}

DomainParticipantExtendedQos& operator =(
const DomainParticipantQos& qos)
{
static_cast<DomainParticipantQos&>(*this) = qos;

return *this;
}

bool operator ==(
const DomainParticipantExtendedQos& b) const
{
return (this->domainId_ == b.domainId()) &&
(DomainParticipantQos::operator ==(b));
}

bool operator ==(
const DomainParticipantQos& b) const override
{
return (DomainParticipantQos::operator ==(b));
}

/**
* Getter for domainId
*
* @return domainId reference
*/
const uint32_t& domainId() const
{
return domainId_;
}

/**
* Getter for domainId
*
* @return domainId reference
*/
uint32_t& domainId()
{
return domainId_;
}

private:

//! DomainId to be used by the associated DomainParticipant (default: 0)
uint32_t domainId_ = 0;

};


} /* namespace dds */
} /* namespace fastdds */
} /* namespace eprosima */

#endif /* _FASTDDS_PARTICIPANTEXTENDEDQOS_HPP_ */
4 changes: 3 additions & 1 deletion include/fastdds/dds/domain/qos/DomainParticipantQos.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class DomainParticipantQos
{
public:

friend class DomainParticipantExtendedQos;

/*!
* User defined flow controllers to use alongside.
*
Expand Down Expand Up @@ -73,7 +75,7 @@ class DomainParticipantQos
{
}

bool operator ==(
virtual bool operator ==(
const DomainParticipantQos& b) const
{
return (this->user_data_ == b.user_data()) &&
Expand Down
23 changes: 23 additions & 0 deletions src/cpp/fastdds/domain/DomainParticipantFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,14 @@ DomainParticipant* DomainParticipantFactory::create_participant(
return dom_part;
}

DomainParticipant* DomainParticipantFactory::create_participant(
const DomainParticipantExtendedQos& extended_qos,
DomainParticipantListener* listener,
const StatusMask& mask)
{
return create_participant(extended_qos.domainId(), extended_qos, listener, mask);
}

DomainParticipant* DomainParticipantFactory::create_participant_with_default_profile()
{
return create_participant_with_default_profile(nullptr, StatusMask::none());
Expand Down Expand Up @@ -333,6 +341,21 @@ ReturnCode_t DomainParticipantFactory::get_participant_qos_from_profile(
return RETCODE_BAD_PARAMETER;
}

ReturnCode_t DomainParticipantFactory::get_participant_extended_qos_from_profile(
const std::string& profile_name,
DomainParticipantExtendedQos& extended_qos) const
{
extended_qos = default_participant_qos_;
ParticipantAttributes attr;
if (XMLP_ret::XML_OK == XMLProfileManager::fillParticipantAttributes(profile_name, attr, false))
{
elianalf marked this conversation as resolved.
Show resolved Hide resolved
utils::set_extended_qos_from_attributes(extended_qos, attr);
return RETCODE_OK;
}

return RETCODE_BAD_PARAMETER;
}

ReturnCode_t DomainParticipantFactory::load_profiles()
{
// NOTE: This could be done with a bool atomic to avoid taking the mutex in most cases, however the use of
Expand Down
16 changes: 16 additions & 0 deletions src/cpp/fastdds/utils/QosConverters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,14 @@ void set_qos_from_attributes(
qos.properties().binary_properties() = attr.properties.binary_properties();
}

void set_extended_qos_from_attributes(
DomainParticipantExtendedQos& extended_qos,
const eprosima::fastdds::ParticipantAttributes& attr)
{
extended_qos.domainId() = attr.domainId;
set_qos_from_attributes(extended_qos, attr.rtps);
}

void set_attributes_from_qos(
fastdds::rtps::RTPSParticipantAttributes& attr,
const DomainParticipantQos& qos)
Expand Down Expand Up @@ -213,6 +221,14 @@ void set_attributes_from_qos(
#endif // if HAVE_SECURITY
}

void set_attributes_from_extended_qos(
eprosima::fastdds::ParticipantAttributes& attr,
const DomainParticipantExtendedQos& extended_qos)
{
attr.domainId = extended_qos.domainId();
set_attributes_from_qos(attr.rtps, extended_qos);
}

void set_qos_from_attributes(
TopicQos& qos,
const TopicAttributes& attr)
Expand Down
30 changes: 30 additions & 0 deletions src/cpp/fastdds/utils/QosConverters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC

#include <fastdds/dds/domain/DomainParticipant.hpp>
#include <fastdds/dds/domain/qos/DomainParticipantExtendedQos.hpp>
elianalf marked this conversation as resolved.
Show resolved Hide resolved
#include <fastdds/dds/domain/qos/DomainParticipantQos.hpp>
#include <fastdds/dds/domain/qos/ReplierQos.hpp>
#include <fastdds/dds/domain/qos/RequesterQos.hpp>
Expand All @@ -29,6 +30,7 @@
#include <fastdds/rtps/attributes/RTPSParticipantAttributes.h>
#include <fastdds/rtps/attributes/TopicAttributes.h>

#include <xmlparser/attributes/ParticipantAttributes.hpp>
#include <xmlparser/attributes/PublisherAttributes.hpp>
#include <xmlparser/attributes/ReplierAttributes.hpp>
#include <xmlparser/attributes/RequesterAttributes.hpp>
Expand Down Expand Up @@ -77,6 +79,24 @@ void set_qos_from_attributes(
DomainParticipantQos& qos,
const eprosima::fastdds::rtps::RTPSParticipantAttributes& attr);

/**
* @brief Fill DomainParticipantExtendedQos from a given attributes ParticipantAttributes object
*
* For the case of the non-binary properties, instead of the ParticipantAttributes overriding the
* property list in the DomainParticipantExtendedQos, a merge is performed in the following manner:
*
* - If any property from the ParticipantAttributes is not in the DomainParticipantExtendedQos, then it is appended
* to the DomainParticipantExtendedQos.
* - If any property from the ParticipantAttributes property is also in the DomainParticipantExtendedQos, then the
* value in the DomainParticipantExtendedQos is overridden with that of the ParticipantAttributes.
*
* @param[in, out] extended_qos The DomainParticipantExtendedQos to set
* @param[in] attr The ParticipantAttributes from which the @c extended_qos is set.
*/
void set_extended_qos_from_attributes(
DomainParticipantExtendedQos& extended_qos,
const eprosima::fastdds::ParticipantAttributes& attr);

/**
* Obtains the RTPSParticipantAttributes from the DomainParticipantQos provided.
*
Expand All @@ -87,6 +107,16 @@ void set_attributes_from_qos(
fastdds::rtps::RTPSParticipantAttributes& attr,
const DomainParticipantQos& qos);

/**
* Obtains the ParticipantAttributes from the DomainParticipantExtendedQos provided.
*
* @param[out] attr Pointer to the attributes from which to obtain data
* @param[in] extended_qos Pointer to the QoS to write on
*/
void set_attributes_from_extended_qos(
eprosima::fastdds::ParticipantAttributes& attr,
const DomainParticipantExtendedQos& extended_qos);

/**
* Obtains the TopicQos from the TopicAttributes provided.
*
Expand Down
Loading
Loading