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

[21198] Add product version on Participant Discovery information #4964

Merged
merged 7 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
38 changes: 37 additions & 1 deletion include/fastdds/dds/core/policy/ParameterTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <fastdds/dds/core/Types.hpp>
#include <fastdds/rtps/common/InstanceHandle.hpp>
#include <fastdds/rtps/common/Locator.hpp>
#include <fastdds/rtps/common/ProductVersion_t.hpp>
#include <fastdds/rtps/common/SampleIdentity.hpp>
#include <fastdds/rtps/common/SerializedPayload.hpp>
#include <fastdds/rtps/common/Time_t.hpp>
Expand Down Expand Up @@ -165,11 +166,12 @@ enum ParameterId_t : uint16_t
PID_RELATED_SAMPLE_IDENTITY = 0x0083,

/* eProsima Fast DDS extensions */
PID_PRODUCT_VERSION = 0x8000,
juanlofer-eprosima marked this conversation as resolved.
Show resolved Hide resolved
PID_PERSISTENCE_GUID = 0x8002,
PID_CUSTOM_RELATED_SAMPLE_IDENTITY = 0x800f,
PID_DISABLE_POSITIVE_ACKS = 0x8005,
PID_DATASHARING = 0x8006,
PID_NETWORK_CONFIGURATION_SET = 0x8007,
PID_CUSTOM_RELATED_SAMPLE_IDENTITY = 0x800f,
};

/*!
Expand Down Expand Up @@ -632,6 +634,39 @@ class ParameterVendorId_t : public Parameter_t

#define PARAMETER_VENDOR_LENGTH 4

/**
* @ingroup PARAMETER_MODULE
*/
class ParameterProductVersion_t : public Parameter_t
{
public:

rtps::ProductVersion_t version;

/**
* @brief Constructor without parameters
*/
ParameterProductVersion_t()
{
}

/**
* Constructor using a parameter PID and the parameter length
*
* @param pid Pid of the parameter
* @param in_length Its associated length
*/
ParameterProductVersion_t(
ParameterId_t pid,
uint16_t in_length)
: Parameter_t(pid, in_length)
{
}

};

#define PARAMETER_PRODUCT_VERSION_LENGTH 4

/**
* @ingroup PARAMETER_MODULE
*/
Expand Down Expand Up @@ -1883,6 +1918,7 @@ using ParameterGuid_t = fastdds::dds::ParameterGuid_t;
using ParameterDomainId_t = fastdds::dds::ParameterDomainId_t;
using ParameterProtocolVersion_t = fastdds::dds::ParameterProtocolVersion_t;
using ParameterVendorId_t = fastdds::dds::ParameterVendorId_t;
using ParameterProductVersion_t = fastdds::dds::ParameterProductVersion_t;
using ParameterIP4Address_t = fastdds::dds::ParameterIP4Address_t;
using ParameterBool_t = fastdds::dds::ParameterBool_t;
using ParameterStatusInfo_t = fastdds::dds::ParameterStatusInfo_t;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <fastdds/dds/core/policy/QosPolicies.hpp>
#include <fastdds/rtps/builtin/data/BuiltinTopicKey.hpp>
#include <fastdds/rtps/common/ProductVersion_t.hpp>
#include <fastdds/rtps/common/RemoteLocators.hpp>

namespace eprosima {
Expand Down Expand Up @@ -57,6 +58,9 @@ struct ParticipantBuiltinTopicData
/// Vendor id
VendorId_t vendor_id;

/// Product version
ProductVersion_t product_version;

/// Participant domain id
dds::DomainId_t domain_id;
};
Expand Down
59 changes: 59 additions & 0 deletions include/fastdds/rtps/common/ProductVersion_t.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// 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 ProductVersion_t.hpp
*/

#ifndef FASTDDS_RTPS_COMMON__PRODUCTVERSION_T_HPP
#define FASTDDS_RTPS_COMMON__PRODUCTVERSION_T_HPP

#include <cstdint>
#include <iomanip>
#include <iostream>

namespace eprosima {
namespace fastdds {
namespace rtps {

struct ProductVersion_t
{
uint8_t major {0};
uint8_t minor {0};
uint8_t patch {0};
uint8_t tweak {0};
};

} // namespace rtps
} // namespace fastdds
} // namespace eprosima

/**
* @brief ostream operator<< for ProductVersion_t
*
* @param output: the output stream
* @param product_version: the product version to append to the output stream
*/
inline std::ostream& operator <<(
std::ostream& output,
eprosima::fastdds::rtps::ProductVersion_t product_version)
{
output << static_cast<uint32_t>(product_version.major)
<< "." << static_cast<uint32_t>(product_version.minor)
<< "." << static_cast<uint32_t>(product_version.patch)
<< "." << static_cast<uint32_t>(product_version.tweak);
return output;
}

#endif /* FASTDDS_RTPS_COMMON__PRODUCTVERSION_T_HPP */
1 change: 1 addition & 0 deletions include/fastdds/rtps/common/Types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include <fastdds/fastdds_dll.hpp>

#include <fastdds/rtps/common/ProductVersion_t.hpp>
#include <fastdds/rtps/common/VendorId_t.hpp>

namespace eprosima {
Expand Down
30 changes: 30 additions & 0 deletions src/cpp/fastdds/core/policy/ParameterSerializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,36 @@ inline bool ParameterSerializer<ParameterVendorId_t>::read_content_from_cdr_mess
return valid;
}

template<>
inline bool ParameterSerializer<ParameterProductVersion_t>::add_content_to_cdr_message(
const ParameterProductVersion_t& parameter,
rtps::CDRMessage_t* cdr_message)
{
bool valid = rtps::CDRMessage::addOctet(cdr_message, parameter.version.major);
valid &= rtps::CDRMessage::addOctet(cdr_message, parameter.version.minor);
valid &= rtps::CDRMessage::addOctet(cdr_message, parameter.version.patch);
valid &= rtps::CDRMessage::addOctet(cdr_message, parameter.version.tweak);
return valid;
}

template<>
inline bool ParameterSerializer<ParameterProductVersion_t>::read_content_from_cdr_message(
ParameterProductVersion_t& parameter,
rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != PARAMETER_PRODUCT_VERSION_LENGTH)
{
return false;
}
parameter.length = parameter_length;
bool valid = rtps::CDRMessage::readOctet(cdr_message, &parameter.version.major);
valid &= rtps::CDRMessage::readOctet(cdr_message, &parameter.version.minor);
valid &= rtps::CDRMessage::readOctet(cdr_message, &parameter.version.patch);
valid &= rtps::CDRMessage::readOctet(cdr_message, &parameter.version.tweak);
return valid;
}

template<>
inline bool ParameterSerializer<ParameterDomainId_t>::add_content_to_cdr_message(
const ParameterDomainId_t& parameter,
Expand Down
Loading
Loading