MCPcopy Create free account
hub / github.com/OpenDDS/OpenDDS / copy

Function copy

dds/DCPS/XTypes/Utils.cpp:1475–1603  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1473}
1474
1475DDS::ReturnCode_t copy(DDS::DynamicData_ptr dest, DDS::DynamicData_ptr src)
1476{
1477 if (dest == src) {
1478 return DDS::RETCODE_OK;
1479 }
1480
1481 const DDS::DynamicType_var dest_type = dest->type();
1482 const DDS::DynamicType_var actual_dest_type = get_base_type(dest_type);
1483 const DDS::TypeKind dest_tk = actual_dest_type->get_kind();
1484
1485 const DDS::DynamicType_var src_type = src->type();
1486 const DDS::DynamicType_var actual_src_type = get_base_type(src_type);
1487 const DDS::TypeKind src_tk = actual_src_type->get_kind();
1488
1489 if (src_tk != dest_tk) {
1490 if (log_level >= LogLevel::Notice) {
1491 ACE_ERROR((LM_NOTICE, "(%P|%t) NOTICE: copy(DynamicData): "
1492 "Can not copy type %C to type %C\n",
1493 typekind_to_string(src_tk), typekind_to_string(dest_tk)));
1494 }
1495 return DDS::RETCODE_OK;
1496 }
1497
1498 DDS::ReturnCode_t rc = DDS::RETCODE_OK;
1499 switch (src_tk) {
1500 case TK_BOOLEAN:
1501 case TK_BYTE:
1502 case TK_INT8:
1503 case TK_INT16:
1504 case TK_INT32:
1505 case TK_INT64:
1506 case TK_UINT8:
1507 case TK_UINT16:
1508 case TK_UINT32:
1509 case TK_UINT64:
1510 case TK_FLOAT32:
1511 case TK_FLOAT64:
1512 case TK_FLOAT128:
1513 case TK_CHAR8:
1514 case TK_CHAR16:
1515 case TK_STRING8:
1516 case TK_STRING16:
1517 case TK_ENUM:
1518 return copy_member(dest, MEMBER_ID_INVALID, src, MEMBER_ID_INVALID);
1519
1520 case TK_UNION:
1521 {
1522 if (src->get_item_count() == 2) {
1523 const DDS::MemberId id = src->get_member_id_at_index(1);
1524 rc = copy_member(dest, id, src, id);
1525 if (rc != DDS::RETCODE_OK) {
1526 if (log_level >= LogLevel::Warning) {
1527 ACE_ERROR((LM_WARNING, "(%P|%t) WARNING: copy(DynamicData): "
1528 "Couldn't set union branch: %C\n", retcode_to_string(rc)));
1529 }
1530 return rc;
1531 }
1532 }

Callers 9

SingleValueMethod · 0.70
cloneMethod · 0.70
copy_memberFunction · 0.70
subject_name_to_strMethod · 0.50
accept_remove_visitorMethod · 0.50

Calls 12

get_base_typeFunction · 0.85
typekind_to_stringFunction · 0.85
copy_memberFunction · 0.85
retcode_to_stringFunction · 0.85
get_kindMethod · 0.80
get_all_membersMethod · 0.80
typeMethod · 0.45
get_item_countMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected