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

Function vwrite_union

dds/DCPS/XTypes/DynamicVwrite.cpp:1252–1316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1250}
1251
1252bool vwrite_union(ValueWriter& vw, DDS::DynamicData_ptr value, const DDS::DynamicType_var& dt)
1253{
1254 DDS::TypeDescriptor_var type_desc;
1255 DDS::ReturnCode_t rc = dt->get_descriptor(type_desc);
1256 if (rc != DDS::RETCODE_OK) {
1257 if (log_level >= LogLevel::Notice) {
1258 ACE_ERROR((LM_NOTICE, "(%P|%t) NOTICE: vwrite_union: get_descriptor failed (%C)\n",
1259 retcode_to_string(rc)));
1260 }
1261 return false;
1262 }
1263
1264 const Extensibility extensibility = XTypes::dds_to_opendds_ext(type_desc->extensibility_kind());
1265 if (!vw.begin_union(extensibility)) {
1266 return false;
1267 }
1268
1269 DDS::DynamicTypeMember_var dtm;
1270 rc = dt->get_member(dtm, XTypes::DISCRIMINATOR_ID);
1271 if (rc != DDS::RETCODE_OK) {
1272 if (log_level >= LogLevel::Notice) {
1273 ACE_ERROR((LM_NOTICE, "(%P|%t) NOTICE: vwrite_union: get_member failed (%C)\n",
1274 retcode_to_string(rc)));
1275 }
1276 return false;
1277 }
1278 DDS::MemberDescriptor_var disc_md;
1279 rc = dtm->get_descriptor(disc_md);
1280 if (rc != DDS::RETCODE_OK) {
1281 if (log_level >= LogLevel::Notice) {
1282 ACE_ERROR((LM_NOTICE, "(%P|%t) NOTICE: vwrite_union: get_descriptor failed (%C)\n",
1283 retcode_to_string(rc)));
1284 }
1285 return false;
1286 }
1287 MemberParam params(XTypes::DISCRIMINATOR_SERIALIZED_ID,
1288 disc_md->is_must_understand() || disc_md->is_key(),
1289 disc_md->name(), disc_md->is_optional(), true);
1290 if (!vw.begin_discriminator(params)) {
1291 return false;
1292 }
1293 CORBA::Long disc_val = 0;
1294 if (!vwrite_discriminator(vw, value, disc_md, disc_val)) {
1295 return false;
1296 }
1297 if (!vw.end_discriminator()) {
1298 return false;
1299 }
1300
1301 bool has_branch = false;
1302 DDS::MemberDescriptor_var selected_md;
1303 rc = XTypes::get_selected_union_branch(dt, disc_val, has_branch, selected_md);
1304 if (rc != DDS::RETCODE_OK) {
1305 if (log_level >= LogLevel::Notice) {
1306 ACE_ERROR((LM_NOTICE, "(%P|%t) NOTICE: vwrite_union: get_selected_union_branch failed (%C)\n",
1307 retcode_to_string(rc)));
1308 }
1309 return false;

Callers 1

vwriteFunction · 0.85

Calls 15

retcode_to_stringFunction · 0.85
dds_to_opendds_extFunction · 0.85
vwrite_discriminatorFunction · 0.85
vwrite_memberFunction · 0.85
get_memberMethod · 0.80
is_must_understandMethod · 0.80
is_optionalMethod · 0.80
get_descriptorMethod · 0.45
begin_unionMethod · 0.45
is_keyMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected