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

[20595] DynamicType implementation #4190

Merged
merged 100 commits into from
Mar 25, 2024
Merged
Changes from 1 commit
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
f446e29
Refs 17138. DynamicTypePtr as shared_ptr alias
Feb 8, 2023
877138d
Refs 17138. Applied new dynamic-types Types.hpp
richiware Nov 27, 2023
4e919ff
Refs 17138. New TypeDescriptor
richiware Nov 29, 2023
3579434
Refs 17138. Applying new TypeDescriptor
richiware Nov 29, 2023
3b1baca
Refs 17138. Update after rebase new TypeDescriptor
richiware Nov 30, 2023
75eb833
Refs 17138. New MemberDescriptor API
richiware Dec 4, 2023
59c8550
Refs 17138. New MemberDescriptor impl
richiware Dec 4, 2023
853e776
Refs 17138. Fix after rebase
richiware Dec 11, 2023
6dc121d
Refs 17138. New AnnotationDescriptor impl
richiware Dec 11, 2023
8403e76
Refs 17138. New DynamicTypeMember API
richiware Dec 14, 2023
ee96a5d
Refs 17138. New DynamicTypeMember impl
richiware Dec 14, 2023
73301b5
Refs 17138. Fix after rebase
richiware Dec 14, 2023
58a9761
Refs 17138. New DynamicType API
richiware Dec 14, 2023
db913bb
Refs 17138. New DynamicType impl
richiware Dec 14, 2023
af1a25e
Refs 17138. New DynamicTypeBuilder API
richiware Dec 18, 2023
48a37d4
Refs 17138. New DynamicTypeBuilder impl
richiware Dec 18, 2023
aa4105b
Refs 17138. New DynamicTypeBuilderFactory API
richiware Dec 19, 2023
1bae894
Refs 17138. New DynamicTypeBuilderFactory impl
richiware Dec 19, 2023
3980d08
Refs #17138. New DynamicData API
richiware Dec 21, 2023
2011fdb
Refs #17138. New DynamicData impl
richiware Dec 21, 2023
45b6f38
Refs #17138. Fix after rebase
richiware Dec 21, 2023
2b4177f
Refs #17138. Fixes
richiware Dec 22, 2023
ab62c5b
Refs #17138. Continue impl DynamicData
richiware Dec 29, 2023
f18d368
Refs #17138. First approach XVCRv2
richiware Jan 9, 2024
beb5dd0
Refs #17138. Several:
richiware Jan 11, 2024
1dbc9a7
Refs #17138. Support string types
richiware Jan 11, 2024
b9f03be
Refs #17138. Support string types
richiware Jan 11, 2024
793a21d
Refs #17138. Fixes after rebase
richiware Jan 15, 2024
023bbe6
Refs #17138. Add primitive sequences
richiware Jan 15, 2024
0781c8a
Refs #17138. Support sequences inside sequences
richiware Jan 16, 2024
29d87b2
Refs #17138. Support of arrays
richiware Jan 17, 2024
cbf6d35
Refs #17138. Improve structure support
richiware Jan 18, 2024
88c46c3
Refs #17138. Support unions.
richiware Jan 23, 2024
6ea0dc5
Refs #17138. Support of maps.
richiware Jan 25, 2024
733470b
Refs #17138. Support of bitmasks
richiware Jan 29, 2024
a96950e
Refs #17138. Fix rebase and remove use of old dynamic api
richiware Jan 29, 2024
45eeec1
Refs #17138. Remove old code
richiware Jan 29, 2024
d0ed6fb
Refs #17138. Refactor test to use DDS API
richiware Jan 31, 2024
f9c9a38
Refs #17138. Fixes
richiware Jan 31, 2024
91dbea9
Refs #17138. Bring to live xml tests
richiware Feb 1, 2024
4d91513
Refs #17138. Fix
richiware Feb 7, 2024
33dca37
Refs #17138. Forgotten use of template
richiware Feb 7, 2024
91b374f
Refs #17138. Support of bitsets
richiware Feb 8, 2024
9e272a7
Refs #17138.
richiware Feb 11, 2024
a355bd7
Refs #17138. Testing calculate_max_serialized_size.
richiware Feb 13, 2024
b9dc526
Refs #17138. Implement DynamicData::clone
richiware Feb 14, 2024
a04e951
Refs #17138. Implement get_complex_data
richiware Feb 15, 2024
8430790
Refs #17138. Fix aliases of enumerators
richiware Feb 15, 2024
eb4a7dc
Refs #17138. Move dynamictests to feature folder
richiware Feb 15, 2024
5cd7a04
Refs #17138. Implementation set_complex_value
richiware Feb 15, 2024
c299de6
Refs #17138. Fix warning on windows
richiware Feb 15, 2024
2d7e511
Refs #17138. Improve alias management
richiware Feb 16, 2024
9887b35
Refs #17138. Remove unused file
richiware Feb 16, 2024
e2a13b5
Refs #17138. Fix warnings on Windows
richiware Feb 16, 2024
77cf260
Refs #17138. Change Bitmask behaviour
richiware Feb 16, 2024
7852bb7
Refs #17138. Fix warnings on Windows
richiware Feb 19, 2024
a1dead4
Refs #17138. Improve bitmask usage
richiware Feb 19, 2024
f1f70f9
Refs #17138. Removed examples
richiware Feb 19, 2024
e83400e
Refs #17138. Fix warnings
richiware Feb 19, 2024
dd5d112
Refs #17138. Fix bitfield as boolean
richiware Feb 19, 2024
7e1cd25
Refs #17138. Fix warnings on windows
richiware Feb 19, 2024
f323249
Refs #17138. Fix bitset
richiware Feb 19, 2024
abe4c56
Refs #17138. Remove unused header
richiware Feb 19, 2024
dab3062
Refs #17138. Using new CdrSizeCalculator API for arrays
richiware Feb 20, 2024
3d5e887
Refs #17138. Refactor xtypes interface library
richiware Feb 20, 2024
ee34a9d
Refs #17138. Fix warnings on windows
richiware Feb 21, 2024
1923d7d
Refs #17138. Improves reviewing
richiware Feb 22, 2024
8e090d0
Refs #17138. Fix deserialization of unions
richiware Feb 23, 2024
b950678
Refs #17138. Applying review
richiware Feb 26, 2024
918ffbc
Refs #17138. Applying changes after review
richiware Feb 26, 2024
b58da2f
Refs #17138. Several fixes
richiware Feb 27, 2024
13db9ad
Refs #17138. Several fixes
richiware Feb 27, 2024
e06e3ec
Refs #17138.
richiware Feb 28, 2024
bdf23ff
Refs #17138.
richiware Feb 29, 2024
e951acb
Refs #17138. Remove obsolete test code
richiware Feb 29, 2024
e416331
Refs #17138. Fixing arrays and sequences
richiware Feb 29, 2024
74d2245
Refs #17138. Remove todos
richiware Feb 29, 2024
2400112
Refs #17138. Fix
richiware Feb 29, 2024
1797a78
Refs #17138. Fix accessing an empty sequence
richiware Mar 1, 2024
4aa3480
Refs #17138. Fix warning on windows
richiware Mar 1, 2024
aeeb5c8
Refs #17138. Fix warnings on windows
richiware Mar 1, 2024
64abaec
Refs #17138. Fix warnings on windows
richiware Mar 4, 2024
7ee35ae
Refs #17138. Fix warnings
richiware Mar 4, 2024
8173e9c
Refs #17138. Fixes in maps
richiware Mar 12, 2024
fb58ee1
Refs #17138. Apply suggestions 1
richiware Mar 13, 2024
4156690
Refs #17138. Apply suggestions 2
richiware Mar 13, 2024
10dde74
Refs #17138. Fix inheritance
richiware Mar 14, 2024
b064d4d
Refs #17138. Apply suggestions 3
richiware Mar 15, 2024
2613dbe
Refs #17138. Apply suggestions 4
richiware Mar 18, 2024
9c69c3a
Refs #17138. Forgotten suggestion
richiware Mar 19, 2024
bf187e0
Refs #17138. Applying suggestions 5
richiware Mar 21, 2024
17f34e8
Refs #17138. Move test to other branch
richiware Mar 21, 2024
c8b1745
Refs #17138. Applying suggestions 6
richiware Mar 22, 2024
d5af16a
Refs #17138. Apply suggestions 7
richiware Mar 22, 2024
8dc454d
Refs #17138. Apply suggestion 8
richiware Mar 22, 2024
c8f6dde
Refs #17138. Apply suggestions 9
richiware Mar 23, 2024
675f796
Refs #17138. Fix uncrustify
richiware Mar 23, 2024
4af3c43
Refs #20595: apply review suggestions
JLBuenoLopez Mar 25, 2024
3a1c2bc
Refs #20595: linters
JLBuenoLopez Mar 25, 2024
f7b29df
Refs #20595: apply review suggestion and fix Mac warnings
JLBuenoLopez Mar 25, 2024
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
Prev Previous commit
Next Next commit
Refs #17138. Apply suggestion 8
Signed-off-by: Ricardo González Moreno <[email protected]>
richiware committed Mar 22, 2024

Verified

This commit was signed with the committer’s verified signature.
richiware Ricardo González
commit 8dc454d5ce33267f53b532569ef572cd8f81e13f
30 changes: 20 additions & 10 deletions src/cpp/fastdds/xtypes/dynamic_types/DynamicDataImpl.cpp
Original file line number Diff line number Diff line change
@@ -1570,19 +1570,24 @@ size_t DynamicDataImpl::calculate_key_serialized_size(
for (auto& member : enclosing_type_->get_all_members())
{
auto member_impl {traits<DynamicTypeMember>::narrow<DynamicTypeMemberImpl>(member.second)};
auto it = value_.find(member.first);
auto member_type {traits<DynamicType>::narrow<DynamicTypeImpl>(member_impl->get_descriptor().type())};

if (it != value_.end())
if (TK_MAP != member_type->resolve_alias_enclosed_type()->get_kind())
{
auto member_data {std::static_pointer_cast<DynamicDataImpl>(it->second)};
auto it = value_.find(member.first);

calculated_size += calculator.calculate_member_serialized_size(
member.first, member_data, current_alignment);
}
else
{
EPROSIMA_LOG_ERROR(DYN_TYPES,
"Error serializing structure member because not found on DynamicData");
if (it != value_.end())
{
auto member_data {std::static_pointer_cast<DynamicDataImpl>(it->second)};

calculated_size += calculator.calculate_member_serialized_size(
member.first, member_data, current_alignment);
}
else
{
EPROSIMA_LOG_ERROR(DYN_TYPES,
"Error serializing structure member because not found on DynamicData");
}
}
}
}
@@ -1958,6 +1963,10 @@ void DynamicDataImpl::serialize_key(
for (auto& member : enclosing_type_->get_all_members())
{
auto member_impl {traits<DynamicTypeMember>::narrow<DynamicTypeMemberImpl>(member.second)};
auto member_type {traits<DynamicType>::narrow<DynamicTypeImpl>(member_impl->get_descriptor().type())};

if (TK_MAP != member_type->resolve_alias_enclosed_type()->get_kind())
{
auto it = value_.find(member.first);

if (it != value_.end())
@@ -1971,6 +1980,7 @@ void DynamicDataImpl::serialize_key(
EPROSIMA_LOG_ERROR(DYN_TYPES,
"Error serializing structure member because not found on DynamicData");
}
}
}
}

7 changes: 7 additions & 0 deletions src/cpp/fastdds/xtypes/dynamic_types/MemberDescriptorImpl.cpp
Original file line number Diff line number Diff line change
@@ -201,6 +201,13 @@ bool MemberDescriptorImpl::is_consistent() noexcept
return false;
}

// TK_MAP member cannot be key.
if (TK_MAP == type->get_kind() && is_key_)
{
EPROSIMA_LOG_ERROR(DYN_TYPES, "TK_MAP member cannot be part of the key.");
return false;
}

// Check name consistency
if (0 == name_.size() && (TK_ANNOTATION == parent_kind_ ||
TK_BITMASK == parent_kind_ ||
33 changes: 15 additions & 18 deletions test/profiling/MemoryTestSubscriber.cpp
Original file line number Diff line number Diff line change
@@ -33,9 +33,6 @@

using namespace eprosima::fastdds::dds;

using std::cout;
using std::endl;

MemoryTestSubscriber::MemoryTestSubscriber()
{
m_datasublistener.up_ = this;
@@ -239,11 +236,11 @@ void MemoryTestSubscriber::DataSubListener::on_subscription_matched(

if (0 < info.current_count_change)
{
cout << C_MAGENTA << "Data Sub Matched " << C_DEF << endl;
std::cout << C_MAGENTA << "Data Sub Matched " << C_DEF << std::endl;
}
else
{
cout << C_MAGENTA << "Data Sub unmatched " << C_DEF << endl;
std::cout << C_MAGENTA << "Data Sub unmatched " << C_DEF << std::endl;
}
up_->disc_count_ += info.current_count_change;

@@ -259,11 +256,11 @@ void MemoryTestSubscriber::CommandPubListener::on_publication_matched(

if (0 < info.current_count_change)
{
cout << C_MAGENTA << "Command Pub Matched " << C_DEF << endl;
std::cout << C_MAGENTA << "Command Pub Matched " << C_DEF << std::endl;
}
else
{
cout << C_MAGENTA << "Command Pub unmatched " << C_DEF << endl;
std::cout << C_MAGENTA << "Command Pub unmatched " << C_DEF << std::endl;
}
up_->disc_count_ += info.current_count_change;

@@ -279,11 +276,11 @@ void MemoryTestSubscriber::CommandSubListener::on_subscription_matched(

if (0 < info.current_count_change)
{
cout << C_MAGENTA << "Command Sub Matched " << C_DEF << endl;
std::cout << C_MAGENTA << "Command Sub Matched " << C_DEF << std::endl;
}
else
{
cout << C_MAGENTA << "Command Sub unmatched " << C_DEF << endl;
std::cout << C_MAGENTA << "Command Sub unmatched " << C_DEF << std::endl;
}
up_->disc_count_ += info.current_count_change;

@@ -297,26 +294,26 @@ void MemoryTestSubscriber::CommandSubListener::on_data_available(
TestCommandType command;
if (RETCODE_OK == reader->take_next_sample(&command, &up_->m_sampleinfo))
{
cout << "RCOMMAND: " << command.m_command << endl;
std::cout << "RCOMMAND: " << command.m_command << std::endl;
if (command.m_command == READY)
{
cout << "Publisher has new test ready..." << endl;
std::cout << "Publisher has new test ready..." << std::endl;
up_->mutex_.lock();
++up_->comm_count_;
up_->mutex_.unlock();
up_->comm_cond_.notify_one();
}
else if (command.m_command == STOP)
{
cout << "Publisher has stopped the test" << endl;
std::cout << "Publisher has stopped the test" << std::endl;
up_->mutex_.lock();
++up_->data_count_;
up_->mutex_.unlock();
up_->data_cond_.notify_one();
}
else if (command.m_command == STOP_ERROR)
{
cout << "Publisher has canceled the test" << endl;
std::cout << "Publisher has canceled the test" << std::endl;
up_->m_status = -1;
up_->mutex_.lock();
++up_->data_count_;
@@ -372,9 +369,9 @@ void MemoryTestSubscriber::run()
bool MemoryTestSubscriber::test(
uint32_t datasize)
{
cout << "Preparing test with data size: " << datasize + 4 << endl;
std::cout << "Preparing test with data size: " << datasize + 4 << std::endl;

//cout << "Ready to start data size: " << m_datasize << " and demand; "<<m_demand << endl;
//cout << "Ready to start data size: " << m_datasize << " and demand; "<<m_demand << std::endl;
if (dynamic_data_)
{
m_DynData = DynamicDataFactory::get_instance()->create_data(m_pDynType);
@@ -392,7 +389,7 @@ bool MemoryTestSubscriber::test(
});
disc_lock.unlock();

cout << C_B_MAGENTA << "DISCOVERY COMPLETE " << C_DEF << endl;
std::cout << C_B_MAGENTA << "DISCOVERY COMPLETE " << C_DEF << std::endl;

std::unique_lock<std::mutex> lock(mutex_);
if (comm_count_ == 0)
@@ -406,7 +403,7 @@ bool MemoryTestSubscriber::test(
n_received = 0;
TestCommandType command;
command.m_command = BEGIN;
cout << "Testing with data size: " << datasize + 4 << endl;
std::cout << "Testing with data size: " << datasize + 4 << std::endl;
command_writer_->write(&command);

lock.lock();
@@ -417,7 +414,7 @@ bool MemoryTestSubscriber::test(
--data_count_;
lock.unlock();

cout << "TEST OF SIZE: " << datasize + 4 << " ENDS" << endl;
std::cout << "TEST OF SIZE: " << datasize + 4 << " ENDS" << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(50));
if (dynamic_data_)
{