本文整理汇总了C++中Subscriber_var::get_participant方法的典型用法代码示例。如果您正苦于以下问题:C++ Subscriber_var::get_participant方法的具体用法?C++ Subscriber_var::get_participant怎么用?C++ Subscriber_var::get_participant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subscriber_var
的用法示例。
在下文中一共展示了Subscriber_var::get_participant方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run_multitopic_test
bool run_multitopic_test(const Publisher_var& pub, const Subscriber_var& sub)
{
DomainParticipant_var sub_dp = sub->get_participant();
// Writer-side setup
Writer<LocationInfo> location(pub, "Location", sub_dp);
Writer<PlanInfo> flightplan(pub, "FlightPlan", sub_dp);
Writer<MoreInfo> more(pub, "More", sub_dp);
Writer<UnrelatedInfo> unrelated(pub, "Unrelated", sub_dp);
MoreInfoDataWriter_var midw = MoreInfoDataWriter::_narrow(more.dw_);
// Reader-side setup
ResultingTypeSupport_var ts_res = new ResultingTypeSupportImpl;
check(ts_res->register_type(sub_dp, ""));
CORBA::String_var type_name = ts_res->get_type_name();
MoreInfo mi;
DDS::DataReader_var dr;
for (int i = 0; i < N_ITERATIONS; ++i) {
MultiTopic_var mt = sub_dp->create_multitopic("MyMultiTopic", type_name,
"SELECT flight_name, x, y, z AS height, more, misc "
"FROM Location NATURAL JOIN FlightPlan NATURAL JOIN More NATURAL JOIN "
"Unrelated WHERE height < 1000 AND x<23", StringSeq());
if (!mt) return false;
dr = sub->create_datareader(mt, DATAREADER_QOS_DEFAULT,
0, DEFAULT_STATUS_MASK);
// Write samples (Location)
waitForMatch(location.dw_);
LocationInfoDataWriter_var locdw =
LocationInfoDataWriter::_narrow(location.dw_);
LocationInfo sample = {100, 97, 23, 2, 3}; // filtered out (x < 23)
ReturnCode_t ret = locdw->write(sample, HANDLE_NIL);
if (ret != RETCODE_OK) return false;
LocationInfo sample2 = {100, 96, 1, 2, 3000}; // filtered out (height < 1000)
ret = locdw->write(sample2, HANDLE_NIL);
if (ret != RETCODE_OK) return false;
LocationInfo sample3 = {100, 99, 1, 2, 3};
ret = locdw->write(sample3, HANDLE_NIL);
if (ret != RETCODE_OK) return false;
LocationInfo sample3_5 = {100, 98, 4, 5, 6};
ret = locdw->write(sample3_5, HANDLE_NIL);
if (ret != RETCODE_OK) return false;
// Write samples (FlightPlan)
waitForMatch(flightplan.dw_);
PlanInfoDataWriter_var pidw = PlanInfoDataWriter::_narrow(flightplan.dw_);
PlanInfo sample4;
sample4.flight_id1 = 100;
sample4.flight_id2 = 99;
sample4.flight_name = "Flight 100-99";
sample4.tailno = "N12345";
ret = pidw->write(sample4, HANDLE_NIL);
if (ret != RETCODE_OK) return false;
PlanInfo sample4_1(sample4);
sample4_1.flight_id2 = 97;
sample4_1.flight_name = "Flight 100-97";
ret = pidw->write(sample4_1, HANDLE_NIL);
if (ret != RETCODE_OK) return false;
PlanInfo sample4_2(sample4);
sample4_2.flight_id2 = 96;
sample4_2.flight_name = "Flight 100-96";
ret = pidw->write(sample4_2, HANDLE_NIL);
if (ret != RETCODE_OK) return false;
// Write samples (More)
waitForMatch(more.dw_);
mi.flight_id1 = 12345;
mi.more = "Shouldn't see this";
ret = midw->write(mi, HANDLE_NIL);
if (ret != RETCODE_OK) return false;
mi.flight_id1 = 100;
mi.more = "Extra info for all flights with id1 == 100";
ret = midw->write(mi, HANDLE_NIL);
if (ret != RETCODE_OK) return false;
// Write samples (Unrelated)
waitForMatch(unrelated.dw_);
UnrelatedInfoDataWriter_var uidw =
UnrelatedInfoDataWriter::_narrow(unrelated.dw_);
UnrelatedInfo ui;
ui.misc = "Misc";
ret = uidw->write(ui, HANDLE_NIL);
if (ret != RETCODE_OK) return false;
// Read resulting samples
WaitSet_var ws = new WaitSet;
ReadCondition_var rc = dr->create_readcondition(ANY_SAMPLE_STATE,
ANY_VIEW_STATE, ANY_INSTANCE_STATE);
ws->attach_condition(rc);
Duration_t infinite = {DURATION_INFINITE_SEC, DURATION_INFINITE_NSEC};
ConditionSeq active;
//.........这里部分代码省略.........