本文整理汇总了C++中DataWriter_var::get_statuscondition方法的典型用法代码示例。如果您正苦于以下问题:C++ DataWriter_var::get_statuscondition方法的具体用法?C++ DataWriter_var::get_statuscondition怎么用?C++ DataWriter_var::get_statuscondition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataWriter_var
的用法示例。
在下文中一共展示了DataWriter_var::get_statuscondition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_setup
void test_setup(const DomainParticipant_var& dp,
const MessageTypeSupport_var& ts, const Publisher_var& pub,
const Subscriber_var& sub, const char* topicName, DataWriter_var& dw,
DataReader_var& dr)
{
Topic_var topic = dp->create_topic(topicName, ts->get_type_name(),
TOPIC_QOS_DEFAULT, 0,
DEFAULT_STATUS_MASK);
DataWriterQos dw_qos;
pub->get_default_datawriter_qos(dw_qos);
dw_qos.history.kind = KEEP_ALL_HISTORY_QOS;
dw = pub->create_datawriter(topic, dw_qos, 0, DEFAULT_STATUS_MASK);
DataReaderQos dr_qos;
sub->get_default_datareader_qos(dr_qos);
dr_qos.history.kind = KEEP_ALL_HISTORY_QOS;
dr = sub->create_datareader(topic, dr_qos, 0, DEFAULT_STATUS_MASK);
StatusCondition_var dw_sc = dw->get_statuscondition();
dw_sc->set_enabled_statuses(PUBLICATION_MATCHED_STATUS);
WaitSet_var ws = new WaitSet;
ws->attach_condition(dw_sc);
Duration_t infinite = {DURATION_INFINITE_SEC, DURATION_INFINITE_NSEC};
ConditionSeq active;
ws->wait(active, infinite);
ws->detach_condition(dw_sc);
}
示例2: waitForMatch
void waitForMatch(const DataWriter_var& dw, int count = 1)
{
StatusCondition_var sc = dw->get_statuscondition();
sc->set_enabled_statuses(PUBLICATION_MATCHED_STATUS);
WaitSet_var ws = new WaitSet;
ws->attach_condition(sc);
const Duration_t infinite = {DURATION_INFINITE_SEC, DURATION_INFINITE_NSEC};
ConditionSeq active;
PublicationMatchedStatus pubmatched;
while (dw->get_publication_matched_status(pubmatched) == RETCODE_OK
&& pubmatched.current_count != count) {
ws->wait(active, infinite);
}
ws->detach_condition(sc);
}
示例3: run_test
int run_test(int argc, ACE_TCHAR *argv[])
{
using namespace DDS;
using namespace OpenDDS::DCPS;
WaitSet_var ws = new WaitSet;
DomainParticipantFactory_var dpf = TheParticipantFactoryWithArgs(argc, argv);
DomainParticipant_var dp = dpf->create_participant(23,
PARTICIPANT_QOS_DEFAULT, 0, ::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
Messenger::MessageTypeSupport_var ts = new Messenger::MessageTypeSupportImpl;
ts->register_type(dp, ts->get_type_name());
Topic_var topic = dp->create_topic("MyTopic", ts->get_type_name(),
TOPIC_QOS_DEFAULT, 0, ::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
Publisher_var pub = dp->create_publisher(PUBLISHER_QOS_DEFAULT, 0,
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
TransportImpl_rch pub_tport =
TheTransportFactory->create_transport_impl(1, AUTO_CONFIG);
PublisherImpl* pub_impl = dynamic_cast<PublisherImpl*> (pub.in());
pub_impl->attach_transport(pub_tport.in());
DataWriter_var dw = pub->create_datawriter(topic, DATAWRITER_QOS_DEFAULT, 0,
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
StatusCondition_var cond = dw->get_statuscondition();
cond->set_enabled_statuses(OFFERED_INCOMPATIBLE_QOS_STATUS);
ws->attach_condition(cond);
Subscriber_var sub = dp->create_subscriber(SUBSCRIBER_QOS_DEFAULT, 0,
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
TransportImpl_rch sub_tport =
TheTransportFactory->create_transport_impl(2, AUTO_CONFIG);
SubscriberImpl* sub_impl = dynamic_cast<SubscriberImpl*> (sub.in());
sub_impl->attach_transport(sub_tport.in());
DataReaderQos dr_qos;
sub->get_default_datareader_qos(dr_qos);
dr_qos.durability.kind = PERSISTENT_DURABILITY_QOS;
Waiter w(ws);
w.activate();
DataReader_var dr = sub->create_datareader(topic, dr_qos, 0,
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
w.wait();
bool passed = (w.result() == RETCODE_OK);
ws->detach_condition(cond);
dp->delete_contained_entities();
dpf->delete_participant(dp);
return passed ? 0 : 1;
}
示例4: run_test_instance
int run_test_instance(DDS::DomainParticipant_ptr dp)
{
using namespace DDS;
using namespace OpenDDS::DCPS;
using namespace Messenger;
WaitSet_var ws = new WaitSet;
MessageTypeSupport_var ts = new MessageTypeSupportImpl;
ts->register_type(dp, "");
CORBA::String_var type_name = ts->get_type_name();
Topic_var topic = dp->create_topic("MyTopic", type_name,
TOPIC_QOS_DEFAULT, 0, ::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
Publisher_var pub = dp->create_publisher(PUBLISHER_QOS_DEFAULT, 0,
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
DataWriter_var dw = pub->create_datawriter(topic, DATAWRITER_QOS_DEFAULT, 0,
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
Subscriber_var sub = dp->create_subscriber(SUBSCRIBER_QOS_DEFAULT, 0,
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
DataReader_var dr = sub->create_datareader(topic, DATAREADER_QOS_DEFAULT, 0,
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
StatusCondition_var dw_sc = dw->get_statuscondition();
dw_sc->set_enabled_statuses(PUBLICATION_MATCHED_STATUS);
ws->attach_condition(dw_sc);
Duration_t infinite = {DURATION_INFINITE_SEC, DURATION_INFINITE_NSEC};
ConditionSeq active;
ReturnCode_t ret = ws->wait(active, infinite);
if (ret != RETCODE_OK) return ret;
ret = ws->detach_condition(dw_sc);
if (ret != RETCODE_OK) return ret;
MessageDataWriter_var mdw = MessageDataWriter::_narrow(dw);
Message msg = {0};
for (int i(0); i < 12; ++i) {
++msg.subject_id;
ret = mdw->write(msg, HANDLE_NIL);
if (ret != RETCODE_OK) return ret;
}
ReadCondition_var dr_rc = dr->create_readcondition(NOT_READ_SAMPLE_STATE,
NEW_VIEW_STATE, ALIVE_INSTANCE_STATE);
ReadCondition_var dr_rc2 = dr->create_readcondition(ANY_SAMPLE_STATE,
ANY_VIEW_STATE, NOT_ALIVE_DISPOSED_INSTANCE_STATE);
ws->attach_condition(dr_rc);
ws->attach_condition(dr_rc2);
MessageDataReader_var mdr = MessageDataReader::_narrow(dr);
bool passed = true, done = false;
while (!done) {
ret = ws->wait(active, infinite);
if (ret != RETCODE_OK) {
passed = false;
break;
}
cout << "wait returned" << endl;
for (CORBA::ULong i(0); i < active.length(); ++i) {
if (active[i] == dr_rc) {
// To test both take_w_condition and
// take_next_instance_w_condition, we'll limit the "take" to 3
// samples and then use take_next_instance_w_condition.
MessageSeq data;
SampleInfoSeq info;
ret = mdr->take_w_condition(data, info, 3, dr_rc);
if (ret == RETCODE_NO_DATA) break;
if (ret != RETCODE_OK) {
cout << "ERROR: take_w_condition returned " << ret << endl;
passed = false;
done = true;
}
InstanceHandle_t handle = HANDLE_NIL;
received_data(data, mdw, msg);
handle = info[info.length() - 1].instance_handle;
if (handle == HANDLE_NIL) {
cout << "ERROR: instance handle is nil" << endl;
passed = false;
done = true;
break;
}
cout << "testing take_instance_w_condition" << endl;
while (true) {
ret = mdr->take_instance_w_condition(data, info, 1,
handle, dr_rc);
if (ret == RETCODE_NO_DATA) break;
if (ret != RETCODE_OK) {
cout << "ERROR: take_instance_w_condition returned "
<< ret << endl;
passed = false;
done = true;
break;
}
received_data(data, mdw, msg);
}
} else if (active[i] == dr_rc2) {
cout << "an instance has been disposed, exiting" << endl;
done = true;
}
}
}
//.........这里部分代码省略.........