Skip to content

Commit

Permalink
Create DomainParticipantExtendedQos
Browse files Browse the repository at this point in the history
Signed-off-by: Lucia Echevarria <luciaechevarria@eprosima.com>
  • Loading branch information
LuciaEchevarria99 committed May 14, 2024
1 parent bc03220 commit 13d6ef8
Show file tree
Hide file tree
Showing 7 changed files with 271 additions and 2 deletions.
25 changes: 25 additions & 0 deletions include/fastdds/dds/domain/DomainParticipantFactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <fastdds/dds/core/status/StatusMask.hpp>
#include <fastdds/dds/domain/qos/DomainParticipantFactoryQos.hpp>
#include <fastdds/dds/domain/qos/DomainParticipantQos.hpp>
#include <fastdds/dds/domain/qos/DomainParticipantExtendedQos.hpp>
#include <fastdds/dds/xtypes/dynamic_types/DynamicType.hpp>
#include <fastdds/dds/xtypes/type_representation/ITypeObjectRegistry.hpp>
#include <fastdds/LibrarySettings.hpp>
Expand Down Expand Up @@ -95,6 +96,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 @@ -216,6 +230,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>

#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 RTPSParticipant (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
22 changes: 22 additions & 0 deletions src/cpp/fastdds/domain/DomainParticipantFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,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 @@ -335,6 +343,20 @@ 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
{
ParticipantAttributes attr;
if (XMLP_ret::XML_OK == XMLProfileManager::fillParticipantAttributes(profile_name, attr, false))
{
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 @@ -183,6 +183,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(
fastrtps::rtps::RTPSParticipantAttributes& attr,
const DomainParticipantQos& qos)
Expand Down Expand Up @@ -216,6 +224,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 @@ -22,13 +22,15 @@

#include <fastdds/dds/domain/DomainParticipant.hpp>
#include <fastdds/dds/domain/qos/DomainParticipantQos.hpp>
#include <fastdds/dds/domain/qos/DomainParticipantExtendedQos.hpp>
#include <fastdds/dds/domain/qos/ReplierQos.hpp>
#include <fastdds/dds/domain/qos/RequesterQos.hpp>
#include <fastdds/dds/publisher/qos/DataWriterQos.hpp>
#include <fastdds/dds/subscriber/qos/DataReaderQos.hpp>
#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 @@ -79,6 +81,24 @@ void set_qos_from_attributes(
DomainParticipantQos& qos,
const eprosima::fastrtps::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 @@ -89,6 +109,16 @@ void set_attributes_from_qos(
fastrtps::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

0 comments on commit 13d6ef8

Please sign in to comment.