Skip to content

Commit

Permalink
Tests for regression test: fix sequence of alias of primitives inside…
Browse files Browse the repository at this point in the history
… modules (#5350)

* Refs #21978. Update submodule and regenerate types

Signed-off-by: Ricardo González Moreno <[email protected]>

* Refs #21978. Add dynamic type test

Signed-off-by: Ricardo González Moreno <[email protected]>

* Refs #21978. Add type lookup service test

Signed-off-by: Ricardo González Moreno <[email protected]>

* Refs #21978. Update submodule

Signed-off-by: Ricardo González Moreno <[email protected]>

* Refs #21978. Apply suggestion

Signed-off-by: Ricardo González Moreno <[email protected]>

* Refs #21978. Fix compilation on Windows

Signed-off-by: Ricardo González Moreno <[email protected]>

---------

Signed-off-by: Ricardo González Moreno <[email protected]>
  • Loading branch information
richiware authored Nov 5, 2024
1 parent a7dfdf5 commit 680329c
Show file tree
Hide file tree
Showing 13 changed files with 1,051 additions and 17 deletions.
155 changes: 152 additions & 3 deletions test/dds-types-test/sequences.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
* This file was generated by the tool fastddsgen.
*/

#ifndef FAST_DDS_GENERATED__SEQUENCES_HPP
#define FAST_DDS_GENERATED__SEQUENCES_HPP
#ifndef FAST_DDS_GENERATED__NOCOMMON_MODULE_SEQUENCES_HPP
#define FAST_DDS_GENERATED__NOCOMMON_MODULE_SEQUENCES_HPP

#include <cstdint>
#include <string>
Expand Down Expand Up @@ -3872,7 +3872,156 @@ class BoundedBigSequences
std::vector<std::string> m_var_unbounded_string_large_bounded_sequence;

};
namespace Common_Module {

#endif // _FAST_DDS_GENERATED_SEQUENCES_HPP_
typedef char My_Char;

typedef std::vector<My_Char> My_String;


} // namespace Common_Module
namespace NoCommon_Module {

typedef Common_Module::My_String My_AliasString;

typedef std::vector<My_AliasString> My_SequenceString;

/*!
* @brief This class represents the structure My_Structure defined by the user in the IDL file.
* @ingroup sequences
*/
class My_Structure
{
public:

/*!
* @brief Default constructor.
*/
eProsima_user_DllExport My_Structure()
{
}

/*!
* @brief Default destructor.
*/
eProsima_user_DllExport ~My_Structure()
{
}

/*!
* @brief Copy constructor.
* @param x Reference to the object My_Structure that will be copied.
*/
eProsima_user_DllExport My_Structure(
const My_Structure& x)
{
m_list = x.m_list;

}

/*!
* @brief Move constructor.
* @param x Reference to the object My_Structure that will be copied.
*/
eProsima_user_DllExport My_Structure(
My_Structure&& x) noexcept
{
m_list = std::move(x.m_list);
}

/*!
* @brief Copy assignment.
* @param x Reference to the object My_Structure that will be copied.
*/
eProsima_user_DllExport My_Structure& operator =(
const My_Structure& x)
{

m_list = x.m_list;

return *this;
}

/*!
* @brief Move assignment.
* @param x Reference to the object My_Structure that will be copied.
*/
eProsima_user_DllExport My_Structure& operator =(
My_Structure&& x) noexcept
{

m_list = std::move(x.m_list);
return *this;
}

/*!
* @brief Comparison operator.
* @param x My_Structure object to compare.
*/
eProsima_user_DllExport bool operator ==(
const My_Structure& x) const
{
return (m_list == x.m_list);
}

/*!
* @brief Comparison operator.
* @param x My_Structure object to compare.
*/
eProsima_user_DllExport bool operator !=(
const My_Structure& x) const
{
return !(*this == x);
}

/*!
* @brief This function copies the value in member list
* @param _list New value to be copied in member list
*/
eProsima_user_DllExport void list(
const My_SequenceString& _list)
{
m_list = _list;
}

/*!
* @brief This function moves the value in member list
* @param _list New value to be moved in member list
*/
eProsima_user_DllExport void list(
My_SequenceString&& _list)
{
m_list = std::move(_list);
}

/*!
* @brief This function returns a constant reference to member list
* @return Constant reference to member list
*/
eProsima_user_DllExport const My_SequenceString& list() const
{
return m_list;
}

/*!
* @brief This function returns a reference to member list
* @return Reference to member list
*/
eProsima_user_DllExport My_SequenceString& list()
{
return m_list;
}



private:

My_SequenceString m_list;

};

} // namespace NoCommon_Module

#endif // _FAST_DDS_GENERATED_NOCOMMON_MODULE_SEQUENCES_HPP_


17 changes: 14 additions & 3 deletions test/dds-types-test/sequencesCdrAux.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
* This file was generated by the tool fastddsgen.
*/

#ifndef FAST_DDS_GENERATED__SEQUENCESCDRAUX_HPP
#define FAST_DDS_GENERATED__SEQUENCESCDRAUX_HPP
#ifndef FAST_DDS_GENERATED__NOCOMMON_MODULE_SEQUENCESCDRAUX_HPP
#define FAST_DDS_GENERATED__NOCOMMON_MODULE_SEQUENCESCDRAUX_HPP

#include "sequences.hpp"

Expand Down Expand Up @@ -78,6 +78,7 @@ constexpr uint32_t SequenceBitMask_max_cdr_typesize {12UL};
constexpr uint32_t SequenceBitMask_max_key_cdr_typesize {0UL};



constexpr uint32_t SequenceUShort_max_cdr_typesize {8UL};
constexpr uint32_t SequenceUShort_max_key_cdr_typesize {0UL};

Expand All @@ -86,19 +87,25 @@ constexpr uint32_t SequenceEnum_max_key_cdr_typesize {0UL};




constexpr uint32_t SequenceOctet_max_cdr_typesize {8UL};
constexpr uint32_t SequenceOctet_max_key_cdr_typesize {0UL};

constexpr uint32_t SequenceWChar_max_cdr_typesize {8UL};
constexpr uint32_t SequenceWChar_max_key_cdr_typesize {0UL};



constexpr uint32_t NoCommon_Module_My_Structure_max_cdr_typesize {12UL};
constexpr uint32_t NoCommon_Module_My_Structure_max_key_cdr_typesize {0UL};

constexpr uint32_t SequenceSequence_max_cdr_typesize {12UL};
constexpr uint32_t SequenceSequence_max_key_cdr_typesize {0UL};





constexpr uint32_t SequenceUnion_max_cdr_typesize {12UL};
constexpr uint32_t SequenceUnion_max_key_cdr_typesize {0UL};

Expand Down Expand Up @@ -241,9 +248,13 @@ eProsima_user_DllExport void serialize_key(
eprosima::fastcdr::Cdr& scdr,
const BoundedBigSequences& data);

eProsima_user_DllExport void serialize_key(
eprosima::fastcdr::Cdr& scdr,
const NoCommon_Module::My_Structure& data);


} // namespace fastcdr
} // namespace eprosima

#endif // FAST_DDS_GENERATED__SEQUENCESCDRAUX_HPP
#endif // FAST_DDS_GENERATED__NOCOMMON_MODULE_SEQUENCESCDRAUX_HPP

92 changes: 89 additions & 3 deletions test/dds-types-test/sequencesCdrAux.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
* This file was generated by the tool fastddsgen.
*/

#ifndef FAST_DDS_GENERATED__SEQUENCESCDRAUX_IPP
#define FAST_DDS_GENERATED__SEQUENCESCDRAUX_IPP
#ifndef FAST_DDS_GENERATED__NOCOMMON_MODULE_SEQUENCESCDRAUX_IPP
#define FAST_DDS_GENERATED__NOCOMMON_MODULE_SEQUENCESCDRAUX_IPP

#include "sequencesCdrAux.hpp"

Expand Down Expand Up @@ -2266,9 +2266,95 @@ void serialize_key(
}


template<>
eProsima_user_DllExport size_t calculate_serialized_size(
eprosima::fastcdr::CdrSizeCalculator& calculator,
const NoCommon_Module::My_Structure& data,
size_t& current_alignment)
{
using namespace NoCommon_Module;

static_cast<void>(data);

eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding();
size_t calculated_size {calculator.begin_calculate_type_serialized_size(
eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ?
eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 :
eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR,
current_alignment)};


calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0),
data.list(), current_alignment);


calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment);

return calculated_size;
}

template<>
eProsima_user_DllExport void serialize(
eprosima::fastcdr::Cdr& scdr,
const NoCommon_Module::My_Structure& data)
{
using namespace NoCommon_Module;

eprosima::fastcdr::Cdr::state current_state(scdr);
scdr.begin_serialize_type(current_state,
eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ?
eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 :
eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR);

scdr
<< eprosima::fastcdr::MemberId(0) << data.list()
;
scdr.end_serialize_type(current_state);
}

template<>
eProsima_user_DllExport void deserialize(
eprosima::fastcdr::Cdr& cdr,
NoCommon_Module::My_Structure& data)
{
using namespace NoCommon_Module;

cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ?
eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 :
eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR,
[&data](eprosima::fastcdr::Cdr& dcdr, const eprosima::fastcdr::MemberId& mid) -> bool
{
bool ret_value = true;
switch (mid.id)
{
case 0:
dcdr >> data.list();
break;

default:
ret_value = false;
break;
}
return ret_value;
});
}

void serialize_key(
eprosima::fastcdr::Cdr& scdr,
const NoCommon_Module::My_Structure& data)
{
using namespace NoCommon_Module;

static_cast<void>(scdr);
static_cast<void>(data);
scdr << data.list();

}



} // namespace fastcdr
} // namespace eprosima

#endif // FAST_DDS_GENERATED__SEQUENCESCDRAUX_IPP
#endif // FAST_DDS_GENERATED__NOCOMMON_MODULE_SEQUENCESCDRAUX_IPP

Loading

0 comments on commit 680329c

Please sign in to comment.