| 397 | } |
| 398 | |
| 399 | bool run_multitopic_test(const Publisher_var& pub, const Subscriber_var& sub) |
| 400 | { |
| 401 | DomainParticipant_var sub_dp = sub->get_participant(); |
| 402 | |
| 403 | // Writer-side setup |
| 404 | Writer<LocationInfo> location(pub, "Location", sub_dp); |
| 405 | Writer<PlanInfo> flightplan(pub, "FlightPlan", sub_dp); |
| 406 | Writer<MoreInfo> more(pub, "More", sub_dp); |
| 407 | Writer<UnrelatedInfo> unrelated(pub, "Unrelated", sub_dp); |
| 408 | MoreInfoDataWriter_var midw = MoreInfoDataWriter::_narrow(more.dw_); |
| 409 | |
| 410 | // Reader-side setup |
| 411 | ResultingTypeSupport_var ts_res = new ResultingTypeSupportImpl; |
| 412 | check_rc(ts_res->register_type(sub_dp, ""), "register resulting type"); |
| 413 | CORBA::String_var type_name = ts_res->get_type_name(); |
| 414 | MoreInfoWrapper mi; |
| 415 | DDS::DataReader_var dr; |
| 416 | |
| 417 | for (int i = 0; i < N_ITERATIONS; ++i) { |
| 418 | |
| 419 | MultiTopic_var mt = sub_dp->create_multitopic("MyMultiTopic", type_name, |
| 420 | "SELECT flight_name, type, destination, alternative_destinations, " |
| 421 | "x, y, z AS height, more, even_more, misc, misc_union " |
| 422 | "FROM Location NATURAL JOIN FlightPlan NATURAL JOIN More NATURAL JOIN Unrelated " |
| 423 | "WHERE height < 1000 AND x < 23 AND type = 'instrument'", StringSeq()); |
| 424 | if (!mt) { |
| 425 | throw std::runtime_error("failed to create multitopic"); |
| 426 | } |
| 427 | dr = sub->create_datareader(mt, DATAREADER_QOS_DEFAULT, 0, DEFAULT_STATUS_MASK); |
| 428 | |
| 429 | // Write samples (Location) |
| 430 | waitForMatch(location.dw_); |
| 431 | LocationInfoDataWriter_var locdw = LocationInfoDataWriter::_narrow(location.dw_); |
| 432 | |
| 433 | LocationInfoWrapper loc97; |
| 434 | loc97.flight_id() = 97; |
| 435 | loc97.departure_date() = 103; |
| 436 | loc97.x() = 23; |
| 437 | loc97.y() = 2; |
| 438 | loc97.z() = 3; |
| 439 | check_rc(locdw->write(loc97, HANDLE_NIL), "write loc97"); // filtered out (x < 23) |
| 440 | |
| 441 | LocationInfoWrapper loc96; |
| 442 | loc96.flight_id() = 96; |
| 443 | loc96.departure_date() = 103; |
| 444 | loc96.x() = 1; |
| 445 | loc96.y() = 2; |
| 446 | loc96.z() = 3000; |
| 447 | check_rc(locdw->write(loc96, HANDLE_NIL), "write loc96"); // filtered out (height < 1000) |
| 448 | |
| 449 | LocationInfoWrapper loc99; |
| 450 | loc99.flight_id() = 99; |
| 451 | loc99.departure_date() = 103; |
| 452 | loc99.x() = 1; |
| 453 | loc99.y() = 2; |
| 454 | loc99.z() = 3; |
| 455 | check_rc(locdw->write(loc99, HANDLE_NIL), "write loc99"); // matches plan99, isn't filtered out |
| 456 |
no test coverage detected