本文整理汇总了C++中dds::DataReader_var::delete_readcondition方法的典型用法代码示例。如果您正苦于以下问题:C++ DataReader_var::delete_readcondition方法的具体用法?C++ DataReader_var::delete_readcondition怎么用?C++ DataReader_var::delete_readcondition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dds::DataReader_var
的用法示例。
在下文中一共展示了DataReader_var::delete_readcondition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run_multitopic_test
//.........这里部分代码省略.........
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;
ret = ws->wait(active, infinite);
if (ret != RETCODE_OK) return false;
ws->detach_condition(rc);
ResultingDataReader_var res_dr = ResultingDataReader::_narrow(dr);
ResultingSeq data;
SampleInfoSeq info;
ret = res_dr->take_w_condition(data, info, LENGTH_UNLIMITED, rc);
if (ret != RETCODE_OK) return false;
if (data.length() > 1 || !info[0].valid_data) return false;
std::cout << "Received: " << data[0].flight_id1 << '-' <<
data[0].flight_id2 << " \"" << data[0].flight_name << "\" " << data[0].x <<
" " << data[0].y << " " << data[0].height << " \"" << data[0].more <<
"\" \"" << data[0].misc << "\"" << std::endl;
if (data[0].flight_id1 != sample4.flight_id1 || data[0].flight_id2 !=
sample4.flight_id2 || strcmp(data[0].flight_name, sample4.flight_name) ||
data[0].x != sample3.x || data[0].y != sample3.y ||
data[0].height != sample3.z || strcmp(data[0].more, mi.more) ||
strcmp(data[0].misc, ui.misc)) {
return false;
}
// Check return get_key_value
Resulting resulting_value;
ret = res_dr->get_key_value(resulting_value, DDS::HANDLE_NIL);
if (ret != RETCODE_BAD_PARAMETER) return false;
data.length(0);
info.length(0);
ret = res_dr->read_w_condition(data, info, LENGTH_UNLIMITED, rc);
dr->delete_readcondition(rc);
if (ret != RETCODE_NO_DATA) return false;
// Reader cleanup
if (i != N_ITERATIONS - 1) {
sub->delete_datareader(dr);
waitForMatch(location.dw_, 0);
waitForMatch(flightplan.dw_, 0);
waitForMatch(more.dw_, 0);
waitForMatch(unrelated.dw_, 0);
sub_dp->delete_multitopic(mt);
}
}
// Dispose
ReturnCode_t ret = midw->dispose(mi, HANDLE_NIL);
if (ret != RETCODE_OK) return false;
ReadCondition_var rc =
dr->create_readcondition(ANY_SAMPLE_STATE, ANY_VIEW_STATE,
NOT_ALIVE_DISPOSED_INSTANCE_STATE);
WaitSet_var ws = new WaitSet;
ws->attach_condition(rc);
const Duration_t infinite = {DURATION_INFINITE_SEC, DURATION_INFINITE_NSEC};
ConditionSeq active;
ret = ws->wait(active, infinite);
if (ret != RETCODE_OK) return false;
ws->detach_condition(rc);
ResultingDataReader_var res_dr = ResultingDataReader::_narrow(dr);
ResultingSeq data;
SampleInfoSeq info;
ret = res_dr->read_w_condition(data, info, LENGTH_UNLIMITED, rc);
dr->delete_readcondition(rc);
if (ret != RETCODE_OK) return false;
if (info[0].valid_data ||
info[0].instance_state != NOT_ALIVE_DISPOSED_INSTANCE_STATE) return false;
return true;
}