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

[20335] DynamicTypeBuilderFactoryImpl::create_type_w_type_object implementation #4368

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
14 changes: 7 additions & 7 deletions examples/cpp/dds/Keys/samplePubSubTypes.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ samplePubSubType::samplePubSubType()
setName("sample");
uint32_t type_size =
#if FASTCDR_VERSION_MAJOR == 1
static_cast<uint32_t>(sample::getMaxCdrSerializedSize());
static_cast<uint32_t>(sample::getMaxCdrSerializedSize());
#else
sample_max_cdr_typesize;
#endif // if FASTCDR_VERSION_MAJOR == 1
sample_max_cdr_typesize;
#endif
type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */
m_typeSize = type_size + 4; /*encapsulation*/
m_isGetKeyDefined = true;
Expand Down Expand Up @@ -150,8 +150,8 @@ std::function<uint32_t()> samplePubSubType::getSerializedSizeProvider(
eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2);
size_t current_alignment {0};
return static_cast<uint32_t>(calculator.calculate_serialized_size(
*static_cast<sample*>(data), current_alignment)) +
4u /*encapsulation*/;
*static_cast<sample*>(data), current_alignment)) +
4u /*encapsulation*/;
}
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
{
Expand Down Expand Up @@ -189,8 +189,7 @@ bool samplePubSubType::getKey(
sample_max_key_cdr_typesize);

// Object that serializes the data.
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS,
eprosima::fastcdr::CdrVersion::XCDRv1);
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1);
#if FASTCDR_VERSION_MAJOR == 1
p_type->serializeKey(ser);
#else
Expand Down Expand Up @@ -225,5 +224,6 @@ void samplePubSubType::register_type_object_representation() const
register_sample_type_objects();
}


// Include auxiliary functions like for serializing/deserializing.
#include "sampleCdrAux.ipp"
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class DynamicDataFactory : public std::enable_shared_from_this<DynamicDataFactor
* @retval RETCODE_OK is otherwise returned.
*/
FASTDDS_EXPORTED_API virtual ReturnCode_t delete_data(
traits<DynamicData>::ref_type data) = 0;
traits<DynamicData>::ref_type& data) = 0;

protected:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ class DynamicTypeBuilderFactory : public std::enable_shared_from_this<DynamicTyp

/*!
* Creates a new @ref DynamicTypeBuilder reference based on the given @ref TypeObject instance.
* @remark Not implemented yet.
* @param[in] type_object @ref TypeObject instance to be used.
* @return New @ref DynamicTypeBuilder reference. Nil reference returned in error case.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ namespace xtypes {
struct TypeObjectPair
{
// Minimal TypeObject
MinimalTypeObject minimal_type_object;
TypeObject minimal_type_object;
// Complete TypeObject
CompleteTypeObject complete_type_object;
TypeObject complete_type_object;
};

class ITypeObjectRegistry
Expand Down
124 changes: 124 additions & 0 deletions include/fastdds/dds/xtypes/type_representation/TypeObjectUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
namespace eprosima {
namespace fastdds {
namespace dds {

class DynamicTypeBuilderFactoryImpl;

namespace xtypes {

class TypeObjectRegistry;
Expand Down Expand Up @@ -1867,6 +1870,7 @@ class TypeObjectUtils
private:

friend class TypeObjectRegistry;
friend class eprosima::fastdds::dds::DynamicTypeBuilderFactoryImpl;

// Class with only static methods
TypeObjectUtils() = delete;
Expand Down Expand Up @@ -2414,6 +2418,16 @@ class TypeObjectUtils
static void complete_struct_type_consistency(
const CompleteStructType& complete_struct_type);

/**
* @brief Check MinimalStructType consistency.
*
* @param[in] minimal_struct_type Instance to be checked.
* @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given MinimalStructType
* is not consistent.
*/
static void minimal_struct_type_consistency(
const MinimalStructType& minimal_struct_type);

/**
* @brief Check UnionCaseLabelSeq consistency.
*
Expand Down Expand Up @@ -2516,6 +2530,16 @@ class TypeObjectUtils
static void complete_union_type_consistency(
const CompleteUnionType& complete_union_type);

/**
* @brief Check MinimalUnionType consistency.
*
* @param[in] minimal_union_type Instance to be checked.
* @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given
* MinimalUnionType is not consistent.
*/
static void minimal_union_type_consistency(
const MinimalUnionType& minimal_union_type);

/**
* @brief Check that the annotation value is of the same type as the given TypeIdentifier.
*
Expand Down Expand Up @@ -2578,6 +2602,16 @@ class TypeObjectUtils
static void complete_annotation_type_consistency(
const CompleteAnnotationType& complete_annotation_type);

/**
* @brief Check MinimalAnnotationType consistency.
*
* @param[in] minimal_annotation_type Instance to be checked.
* @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given
* MinimalAnnotationType is not consistent.
*/
static void minimal_annotation_type_consistency(
const MinimalAnnotationType& minimal_annotation_type);

/**
* @brief Check CommonAliasBody consistency.
*
Expand Down Expand Up @@ -2628,6 +2662,16 @@ class TypeObjectUtils
static void complete_alias_type_consistency(
const CompleteAliasType& complete_alias_type);

/**
* @brief Check MinimalAliasType consistency.
*
* @param[in] minimal_alias_type Instance to be checked.
* @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given
* MinimalAliasType is not consistent.
*/
static void minimal_alias_type_consistency(
const MinimalAliasType& minimal_alias_type);

/**
* @brief Check CompleteElementDetail consistency.
*
Expand Down Expand Up @@ -2678,6 +2722,16 @@ class TypeObjectUtils
static void complete_sequence_type_consistency(
const CompleteSequenceType& complete_sequence_type);

/**
* @brief Check MinimalSequenceType consistency.
*
* @param[in] minimal_sequence_type Instance to be checked.
* @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given
* MinimalSequenceType is not consistent.
*/
static void minimal_sequence_type_consistency(
const MinimalSequenceType& minimal_sequence_type);

/**
* @brief Check CommonArrayHeader consistency.
*
Expand Down Expand Up @@ -2708,6 +2762,16 @@ class TypeObjectUtils
static void complete_array_type_consistency(
const CompleteArrayType& complete_array_type);

/**
* @brief Check MinimalArrayType consistency.
*
* @param[in] minimal_array_type Instance to be checked.
* @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given
* MinimalArrayType is not consistent.
*/
static void minimal_array_type_consistency(
const MinimalArrayType& minimal_array_type);

/**
* @brief Check CompleteMapType consistency.
*
Expand All @@ -2718,6 +2782,16 @@ class TypeObjectUtils
static void complete_map_type_consistency(
const CompleteMapType& complete_map_type);

/**
* @brief Check MinimalMapType consistency.
*
* @param[in] minimal_map_type Instance to be checked.
* @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given
* MinimalMapType is not consistent.
*/
static void minimal_map_type_consistency(
const MinimalMapType& minimal_map_type);

/**
* @brief Check CommonEnumeratedLiteral consistency.
*
Expand Down Expand Up @@ -2802,6 +2876,16 @@ class TypeObjectUtils
static void complete_enumerated_type_consistency(
const CompleteEnumeratedType& complete_enumerated_type);

/**
* @brief Check MinimalEnumeratedType consistency.
*
* @param[in] minimal_enumerated_type Instance to be checked.
* @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given
* MinimalEnumeratedType is not consistent.
*/
static void minimal_enumerated_type_consistency(
const MinimalEnumeratedType& minimal_enumerated_type);

/**
* @brief Check bitflag position consistency.
*
Expand Down Expand Up @@ -2852,6 +2936,16 @@ class TypeObjectUtils
static void complete_bitmask_type_consistency(
const CompleteBitmaskType& complete_bitmask_type);

/**
* @brief Check MinimalBitmaskType consistency.
*
* @param[in] minimal_bitmask_type Instance to be checked.
* @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given
* MinimalBitmaskType is not consistent.
*/
static void minimal_bitmask_type_consistency(
const MinimalBitmaskType& minimal_bitmask_type);

/**
* @brief Check consistency between the holder type and the bitcount.
*
Expand Down Expand Up @@ -2913,6 +3007,16 @@ class TypeObjectUtils
static void complete_bitset_type_consistency(
const CompleteBitsetType& complete_bitset_type);

/**
* @brief Check MinimalBitsetType consistency.
*
* @param[in] minimal_bitset_type Instance to be checked.
* @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given
* MinimalBitsetType is not consistent.
*/
static void minimal_bitset_type_consistency(
const MinimalBitsetType& minimal_bitset_type);

/**
* @brief Check CompleteTypeObject consistency.
*
Expand All @@ -2923,6 +3027,26 @@ class TypeObjectUtils
static void complete_type_object_consistency(
const CompleteTypeObject& complete_type_object);

/**
* @brief Check MinimalTypeObject consistency.
*
* @param[in] minimal_type_object Instance to be checked.
* @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given
* MinimalTypeObject is not consistent.
*/
static void minimal_type_object_consistency(
const MinimalTypeObject& minimal_type_object);

/**
* @brief Check TypeObject consistency.
*
* @param[in] type_object Instance to be checked.
* @exception eprosima::fastdds::dds::xtypes::InvalidArgumentError exception if the given
* TypeObject is not consistent.
*/
static void type_object_consistency(
const TypeObject& type_object);

};

} // xtypes
Expand Down
Loading
Loading