Skip to content

Commit

Permalink
Refs #19837: use ExtensibilityKind and TryConstructKind defined in Dy…
Browse files Browse the repository at this point in the history
…namicType IDL

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>
  • Loading branch information
JLBuenoLopez committed Nov 30, 2023
1 parent 87e44ef commit b5ce5c2
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 89 deletions.
20 changes: 0 additions & 20 deletions include/fastdds/dds/xtypes/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,6 @@ namespace fastdds {
namespace dds {
namespace xtypes {

/**
* @brief Extensibility kinds (@extensibility annotation)
*/
enum ExtensibilityKind
{
FINAL,
APPENDABLE,
MUTABLE
};

/**
* @brief Try construct kinds (@try_construct annotation)
*/
enum TryConstructKind
{
USE_DEFAULT,
DISCARD,
TRIM
};

/**
* @brief EquivalenceKind values
*/
Expand Down
19 changes: 10 additions & 9 deletions include/fastdds/dds/xtypes/type_representation/TypeObjectUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <fastcdr/xcdr/optional.hpp>

#include <fastdds/dds/xtypes/common.hpp>
#include <fastdds/dds/xtypes/dynamic_types/Types.hpp>
#include <fastdds/dds/xtypes/exception/Exception.hpp>
#include <fastdds/dds/xtypes/type_representation/TypeObject.hpp>
#include <fastrtps/fastrtps_dll.h>
Expand Down Expand Up @@ -64,7 +65,7 @@ class TypeObjectUtils
* @return CollectionElementFlag instance.
*/
RTPS_DllAPI static CollectionElementFlag build_collection_element_flag(
TryConstructKind try_construct_kind,
eprosima::fastdds::dds::TryConstructKind try_construct_kind,
bool external);

/**
Expand All @@ -80,7 +81,7 @@ class TypeObjectUtils
* @return StructMemberFlag instance.
*/
RTPS_DllAPI static StructMemberFlag build_struct_member_flag(
TryConstructKind try_construct_kind,
eprosima::fastdds::dds::TryConstructKind try_construct_kind,
bool optional,
bool must_understand,
bool key,
Expand All @@ -95,7 +96,7 @@ class TypeObjectUtils
* @return UnionMemberFlag instance.
*/
RTPS_DllAPI static UnionMemberFlag build_union_member_flag(
TryConstructKind try_construct_kind,
eprosima::fastdds::dds::TryConstructKind try_construct_kind,
bool default_member,
bool external);

Expand All @@ -107,7 +108,7 @@ class TypeObjectUtils
* @return UnionDiscriminatorFlag instance.
*/
RTPS_DllAPI static UnionDiscriminatorFlag build_union_discriminator_flag(
TryConstructKind try_construct_kind,
eprosima::fastdds::dds::TryConstructKind try_construct_kind,
bool key);

/**
Expand Down Expand Up @@ -135,7 +136,7 @@ class TypeObjectUtils
* @return StructTypeFlag instance.
*/
RTPS_DllAPI static StructTypeFlag build_struct_type_flag(
ExtensibilityKind extensibility_kind,
eprosima::fastdds::dds::ExtensibilityKind extensibility_kind,
bool nested,
bool autoid_hash);

Expand All @@ -148,7 +149,7 @@ class TypeObjectUtils
* @return UnionTypeFlag instance.
*/
RTPS_DllAPI static UnionTypeFlag build_union_type_flag(
ExtensibilityKind extensibility_kind,
eprosima::fastdds::dds::ExtensibilityKind extensibility_kind,
bool nested,
bool autoid_hash);

Expand Down Expand Up @@ -1878,7 +1879,7 @@ class TypeObjectUtils
*/
static void set_try_construct_behavior(
MemberFlag& member_flag,
TryConstructKind try_construct_kind);
eprosima::fastdds::dds::TryConstructKind try_construct_kind);

/**
* @brief Set the TypeFlag object.
Expand All @@ -1890,7 +1891,7 @@ class TypeObjectUtils
*/
static void set_type_flag(
TypeFlag& type_flag,
ExtensibilityKind extensibility_kind,
eprosima::fastdds::dds::ExtensibilityKind extensibility_kind,
bool nested,
bool autoid_hash);

Expand All @@ -1902,7 +1903,7 @@ class TypeObjectUtils
*/
static void set_extensibility_kind(
TypeFlag& type_flag,
ExtensibilityKind extensibility_kind);
eprosima::fastdds::dds::ExtensibilityKind extensibility_kind);

/**
* @brief Check if a given TypeIdentifier is fully-descriptive.
Expand Down
33 changes: 17 additions & 16 deletions src/cpp/fastdds/xtypes/type_representation/TypeObjectUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <fastdds/dds/domain/DomainParticipantFactory.hpp>
#include <fastdds/dds/xtypes/common.hpp>
#include <fastdds/dds/xtypes/dynamic_types/Types.hpp>
#include <fastdds/dds/xtypes/exception/Exception.hpp>
#include <fastdds/dds/xtypes/type_representation/TypeObject.hpp>
#include <fastdds/dds/log/Log.hpp>
Expand Down Expand Up @@ -69,7 +70,7 @@ const TypeObjectHashId TypeObjectUtils::build_type_object_hash_id(
}

CollectionElementFlag TypeObjectUtils::build_collection_element_flag(
TryConstructKind try_construct_kind,
eprosima::fastdds::dds::TryConstructKind try_construct_kind,
bool external)
{
CollectionElementFlag collection_element_flag = 0;
Expand All @@ -82,7 +83,7 @@ CollectionElementFlag TypeObjectUtils::build_collection_element_flag(
}

StructMemberFlag TypeObjectUtils::build_struct_member_flag(
TryConstructKind try_construct_kind,
eprosima::fastdds::dds::TryConstructKind try_construct_kind,
bool optional,
bool must_understand,
bool key,
Expand Down Expand Up @@ -116,7 +117,7 @@ StructMemberFlag TypeObjectUtils::build_struct_member_flag(
}

UnionMemberFlag TypeObjectUtils::build_union_member_flag(
TryConstructKind try_construct_kind,
eprosima::fastdds::dds::TryConstructKind try_construct_kind,
bool default_member,
bool external)
{
Expand All @@ -134,7 +135,7 @@ UnionMemberFlag TypeObjectUtils::build_union_member_flag(
}

UnionDiscriminatorFlag TypeObjectUtils::build_union_discriminator_flag(
TryConstructKind try_construct_kind,
eprosima::fastdds::dds::TryConstructKind try_construct_kind,
bool key)
{
UnionDiscriminatorFlag union_discriminator_flag = 0;
Expand All @@ -158,7 +159,7 @@ EnumeratedLiteralFlag TypeObjectUtils::build_enumerated_literal_flag(
}

StructTypeFlag TypeObjectUtils::build_struct_type_flag(
ExtensibilityKind extensibility_kind,
eprosima::fastdds::dds::ExtensibilityKind extensibility_kind,
bool nested,
bool autoid_hash)
{
Expand All @@ -168,7 +169,7 @@ StructTypeFlag TypeObjectUtils::build_struct_type_flag(
}

UnionTypeFlag TypeObjectUtils::build_union_type_flag(
ExtensibilityKind extensibility_kind,
eprosima::fastdds::dds::ExtensibilityKind extensibility_kind,
bool nested,
bool autoid_hash)
{
Expand Down Expand Up @@ -1851,19 +1852,19 @@ const NameHash TypeObjectUtils::name_hash(

void TypeObjectUtils::set_try_construct_behavior(
MemberFlag& member_flag,
TryConstructKind try_construct_kind)
eprosima::fastdds::dds::TryConstructKind try_construct_kind)
{
switch (try_construct_kind)
{
case TryConstructKind::USE_DEFAULT:
case eprosima::fastdds::dds::TryConstructKind::USE_DEFAULT:
member_flag |= MemberFlagBits::TRY_CONSTRUCT2;
break;

case TryConstructKind::TRIM:
case eprosima::fastdds::dds::TryConstructKind::TRIM:
member_flag |= MemberFlagBits::TRY_CONSTRUCT1 | MemberFlagBits::TRY_CONSTRUCT2;
break;

case TryConstructKind::DISCARD:
case eprosima::fastdds::dds::TryConstructKind::DISCARD:
default:
member_flag |= MemberFlagBits::TRY_CONSTRUCT1;
break;
Expand All @@ -1872,7 +1873,7 @@ void TypeObjectUtils::set_try_construct_behavior(

void TypeObjectUtils::set_type_flag(
TypeFlag& type_flag,
ExtensibilityKind extensibility_kind,
eprosima::fastdds::dds::ExtensibilityKind extensibility_kind,
bool nested,
bool autoid_hash)
{
Expand All @@ -1889,19 +1890,19 @@ void TypeObjectUtils::set_type_flag(

void TypeObjectUtils::set_extensibility_kind(
TypeFlag& type_flag,
ExtensibilityKind extensibility_kind)
eprosima::fastdds::dds::ExtensibilityKind extensibility_kind)
{
switch (extensibility_kind)
{
case ExtensibilityKind::FINAL:
case eprosima::fastdds::dds::ExtensibilityKind::FINAL:
type_flag |= TypeFlagBits::IS_FINAL;
break;

case ExtensibilityKind::MUTABLE:
case eprosima::fastdds::dds::ExtensibilityKind::MUTABLE:
type_flag |= TypeFlagBits::IS_MUTABLE;
break;

case ExtensibilityKind::APPENDABLE:
case eprosima::fastdds::dds::ExtensibilityKind::APPENDABLE:
default:
type_flag |= TypeFlagBits::IS_APPENDABLE;
break;
Expand Down Expand Up @@ -1988,7 +1989,7 @@ void TypeObjectUtils::member_flag_consistency(
{
if (!(member_flags & MemberFlagBits::TRY_CONSTRUCT1 || member_flags & MemberFlagBits::TRY_CONSTRUCT2))
{
throw InvalidArgumentError("Inconsistent MemberFlag: INVALID TryConstructKind");
throw InvalidArgumentError("Inconsistent MemberFlag: INVALID eprosima::fastdds::dds::TryConstructKind");
}
}

Expand Down
Loading

0 comments on commit b5ce5c2

Please sign in to comment.