本文整理汇总了C++中dds::DataReader_var::get_subscription_matched_status方法的典型用法代码示例。如果您正苦于以下问题:C++ DataReader_var::get_subscription_matched_status方法的具体用法?C++ DataReader_var::get_subscription_matched_status怎么用?C++ DataReader_var::get_subscription_matched_status使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dds::DataReader_var
的用法示例。
在下文中一共展示了DataReader_var::get_subscription_matched_status方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
int
OpenDDS::Model::ReaderSync::wait_unmatch(const DDS::DataReader_var& reader,
unsigned int num_writers)
{
DDS::ReturnCode_t stat;
DDS::StatusCondition_var condition = reader->get_statuscondition();
condition->set_enabled_statuses(DDS::SUBSCRIPTION_MATCHED_STATUS);
DDS::WaitSet_var ws = new DDS::WaitSet;
ws->attach_condition(condition);
DDS::ConditionSeq conditions;
DDS::SubscriptionMatchedStatus ms = { 0, 0, 0, 0, 0 };
DDS::Duration_t timeout = { 1, 0 };
do {
if (DCPS_debug_level > 4) {
ACE_DEBUG((LM_NOTICE, ACE_TEXT("ReaderSync: sub checking unmatched\n")));
}
stat = reader->get_subscription_matched_status(ms);
if (stat != DDS::RETCODE_OK) {
ACE_ERROR_RETURN((
LM_ERROR,
ACE_TEXT("(%P|%t) ERROR: %N:%l: wait_unmatch() -")
ACE_TEXT(" get_subscription_matched_status failed!\n")),
-1);
} else if (ms.current_count == 0 && (unsigned int)ms.total_count >= num_writers) {
if (DCPS_debug_level > 4) {
ACE_DEBUG((LM_NOTICE, ACE_TEXT("ReaderSync: sub match count %d total count %d\n"),
ms.current_count, ms.total_count));
}
break; // unmatched
}
if (DCPS_debug_level > 4) {
ACE_DEBUG((LM_NOTICE, ACE_TEXT("ReaderSync: sub match count %d total count %d\n"),
ms.current_count, ms.total_count));
}
// wait for a change
stat = ws->wait(conditions, timeout);
if ((stat != DDS::RETCODE_OK) && (stat != DDS::RETCODE_TIMEOUT)) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) ERROR: %N:%l: wait_unmatch() -")
ACE_TEXT(" wait failed!\n")),
-1);
}
} while (true);
ws->detach_condition(condition);
if (DCPS_debug_level > 4) {
ACE_DEBUG((LM_NOTICE, ACE_TEXT("ReaderSync: sub unmatched\n")));
}
return 0;
}
示例2: listener
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try {
// Initialize DomainParticipantFactory
DDS::DomainParticipantFactory_var dpf =
TheParticipantFactoryWithArgs(argc, argv);
// Create DomainParticipant
DDS::DomainParticipant_var participant =
dpf->create_participant(42,
PARTICIPANT_QOS_DEFAULT,
0,
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (!participant) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: main() -")
ACE_TEXT(" create_participant failed!\n")), -1);
}
// Register Type (Messenger::Message)
Messenger::MessageTypeSupport_var ts =
new Messenger::MessageTypeSupportImpl;
if (ts->register_type(participant, "") != DDS::RETCODE_OK) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: main() -")
ACE_TEXT(" register_type failed!\n")), -1);
}
// Create Topic (Movie Discussion List)
CORBA::String_var type_name = ts->get_type_name();
DDS::Topic_var topic =
participant->create_topic("Movie Discussion List",
type_name,
TOPIC_QOS_DEFAULT,
0,
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (!topic) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: main() -")
ACE_TEXT(" create_topic failed!\n")), -1);
}
// Create Subscriber
DDS::Subscriber_var subscriber =
participant->create_subscriber(SUBSCRIBER_QOS_DEFAULT,
0,
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (!subscriber) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: main() -")
ACE_TEXT(" create_subscriber failed!\n")), -1);
}
// Create DataReader
DDS::DataReaderListener_var listener(new DataReaderListenerImpl);
DDS::DataReader_var reader =
subscriber->create_datareader(topic,
DATAREADER_QOS_DEFAULT,
listener,
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (!reader) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: main() -")
ACE_TEXT(" create_datareader failed!\n")), -1);
}
Messenger::MessageDataReader_var reader_i =
Messenger::MessageDataReader::_narrow(reader);
if (!reader_i) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: main() -")
ACE_TEXT(" _narrow failed!\n")),
-1);
}
// Block until Publisher completes
DDS::StatusCondition_var condition = reader->get_statuscondition();
condition->set_enabled_statuses(DDS::SUBSCRIPTION_MATCHED_STATUS);
DDS::WaitSet_var ws = new DDS::WaitSet;
ws->attach_condition(condition);
while (true) {
DDS::SubscriptionMatchedStatus matches;
if (reader->get_subscription_matched_status(matches) != DDS::RETCODE_OK) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: main() -")
ACE_TEXT(" get_subscription_matched_status failed!\n")), -1);
}
if (matches.current_count == 0 && matches.total_count > 0) {
break;
//.........这里部分代码省略.........
示例3: DataReaderListenerImpl
//.........这里部分代码省略.........
// Register Type (FooType)
FooTypeSupport_var ts = new FooTypeSupportImpl;
if (ts->register_type(participant.in(), "") != DDS::RETCODE_OK)
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" register_type failed!\n")), 5);
// Create Topic (FooTopic)
DDS::Topic_var topic =
participant->create_topic("FooTopic",
ts->get_type_name(),
TOPIC_QOS_DEFAULT,
DDS::TopicListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(topic.in()))
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" create_topic failed!\n")), 6);
// Create DataReader
ProgressIndicator progress =
ProgressIndicator("(%P|%t) SUBSCRIBER %d%% (%d samples received)\n",
expected_samples);
DDS::DataReaderListener_var listener =
new DataReaderListenerImpl(received_samples, progress);
DDS::DataReaderQos reader_qos;
subscriber->get_default_datareader_qos(reader_qos);
reader_qos.history.kind = DDS::KEEP_ALL_HISTORY_QOS;
DDS::DataReader_var reader =
subscriber->create_datareader(topic.in(),
reader_qos,
listener.in(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(reader.in()))
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" create_datareader failed!\n")), 7);
// Block until Publisher completes
DDS::StatusCondition_var cond = reader->get_statuscondition();
cond->set_enabled_statuses(DDS::SUBSCRIPTION_MATCHED_STATUS);
DDS::WaitSet_var ws = new DDS::WaitSet;
ws->attach_condition(cond);
DDS::Duration_t timeout =
{ DDS::DURATION_INFINITE_SEC, DDS::DURATION_INFINITE_NSEC };
DDS::ConditionSeq conditions;
DDS::SubscriptionMatchedStatus matches = {0, 0, 0, 0, 0};
do
{
if (ws->wait(conditions, timeout) != DDS::RETCODE_OK)
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" wait failed!\n")), 8);
if (reader->get_subscription_matched_status(matches) != ::DDS::RETCODE_OK)
{
ACE_ERROR ((LM_ERROR,
"ERROR: failed to get subscription matched status\n"));
return 1;
}
}
while (matches.current_count > 0 || matches.total_count < n_publishers);
ws->detach_condition(cond);
// Clean-up!
participant->delete_contained_entities();
dpf->delete_participant(participant.in());
TheTransportFactory->release();
TheServiceParticipant->shutdown();
}
catch (const CORBA::Exception& e)
{
e._tao_print_exception("caught in main()");
return 9;
}
ACE_DEBUG((LM_INFO, ACE_TEXT("(%P|%t) <- SUBSCRIBER FINISHED\n")));
if (received_samples != expected_samples) {
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) ERROR: subscriber - ")
ACE_TEXT("received %d of expected %d samples.\n"),
received_samples,
expected_samples
));
return 10;
}
return 0;
}
示例4: MessageTypeSupportImpl
//.........这里部分代码省略.........
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l main()")
ACE_TEXT(" ERROR: register_type() failed!\n")), -1);
}
// Create Topic (Movie Discussion List)
CORBA::String_var type_name = ts->get_type_name();
DDS::Topic_var topic =
participant->create_topic("Movie Discussion List",
type_name.in(),
TOPIC_QOS_DEFAULT,
DDS::TopicListener::_nil(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(topic.in())) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l main()")
ACE_TEXT(" ERROR: create_topic() failed!\n")), -1);
}
// Create Subscriber
DDS::Subscriber_var sub =
participant->create_subscriber(SUBSCRIBER_QOS_DEFAULT,
DDS::SubscriberListener::_nil(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(sub.in())) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l main()")
ACE_TEXT(" ERROR: create_subscriber() failed!\n")), -1);
}
// Create DataReader
DataReaderListenerImpl* const listener_servant = new DataReaderListenerImpl;
DDS::DataReaderListener_var listener(listener_servant);
DDS::DataReaderQos dr_qos;
sub->get_default_datareader_qos(dr_qos);
if (DataReaderListenerImpl::is_reliable()) {
std::cout << "Reliable DataReader" << std::endl;
dr_qos.reliability.kind = DDS::RELIABLE_RELIABILITY_QOS;
}
DDS::DataReader_var reader =
sub->create_datareader(topic.in(),
dr_qos,
listener.in(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(reader.in())) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l main()")
ACE_TEXT(" ERROR: create_datareader() failed!\n")), -1);
}
// Block until Publisher completes
DDS::StatusCondition_var condition = reader->get_statuscondition();
condition->set_enabled_statuses(DDS::SUBSCRIPTION_MATCHED_STATUS);
DDS::WaitSet_var ws = new DDS::WaitSet;
ws->attach_condition(condition);
DDS::Duration_t timeout =
{ DDS::DURATION_INFINITE_SEC, DDS::DURATION_INFINITE_NSEC };
DDS::ConditionSeq conditions;
DDS::SubscriptionMatchedStatus matches = { 0, 0, 0, 0, 0 };
while (true) {
if (reader->get_subscription_matched_status(matches) != DDS::RETCODE_OK) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l main()")
ACE_TEXT(" ERROR: get_subscription_matched_status() failed!\n")), -1);
}
if (matches.current_count == 0 && matches.total_count > 0) {
break;
}
if (ws->wait(conditions, timeout) != DDS::RETCODE_OK) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l main()")
ACE_TEXT(" ERROR: wait() failed!\n")), -1);
}
}
status = listener_servant->is_valid() ? 0 : -1;
ws->detach_condition(condition);
// Clean-up!
participant->delete_contained_entities();
dpf->delete_participant(participant.in());
TheServiceParticipant->shutdown();
} catch (const CORBA::Exception& e) {
e._tao_print_exception("Exception caught in main():");
status = -1;
}
return status;
}
示例5: MessageTypeSupportImpl
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try {
// Initialize DomainParticipantFactory
DDS::DomainParticipantFactory_var dpf =
TheParticipantFactoryWithArgs(argc, argv);
int error;
if ((error = parse_args(argc, argv)) != 0) {
return error;
}
// Create DomainParticipant
DDS::DomainParticipant_var participant =
dpf->create_participant(4,
PARTICIPANT_QOS_DEFAULT,
DDS::DomainParticipantListener::_nil(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(participant.in())) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l main()")
ACE_TEXT(" ERROR: create_participant() failed!\n")), -1);
}
// Register Type (Messenger::Message)
Messenger::MessageTypeSupport_var ts =
new Messenger::MessageTypeSupportImpl();
if (ts->register_type(participant.in(), "") != DDS::RETCODE_OK) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l main()")
ACE_TEXT(" ERROR: register_type() failed!\n")), -1);
}
// Create Topic (Movie Discussion List)
DDS::Topic_var topic =
participant->create_topic("Movie Discussion List",
ts->get_type_name(),
TOPIC_QOS_DEFAULT,
DDS::TopicListener::_nil(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(topic.in())) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l main()")
ACE_TEXT(" ERROR: create_topic() failed!\n")), -1);
}
// Create Subscriber
DDS::Subscriber_var sub =
participant->create_subscriber(SUBSCRIBER_QOS_DEFAULT,
DDS::SubscriberListener::_nil(),
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(sub.in())) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l main()")
ACE_TEXT(" ERROR: create_subscriber() failed!\n")), -1);
}
// Create DataReader
DataReaderListenerImpl listener;
DDS::DataReader_var reader =
sub->create_datareader(topic.in(),
DATAREADER_QOS_DEFAULT,
&listener,
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(reader.in())) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l main()")
ACE_TEXT(" ERROR: create_datareader() failed!\n")), -1);
}
// Block until Publisher completes
DDS::StatusCondition_var condition = reader->get_statuscondition();
condition->set_enabled_statuses(DDS::SUBSCRIPTION_MATCHED_STATUS);
DDS::WaitSet_var ws = new DDS::WaitSet;
ws->attach_condition(condition);
DDS::Duration_t timeout =
{ DDS::DURATION_INFINITE_SEC, DDS::DURATION_INFINITE_NSEC };
DDS::ConditionSeq conditions;
DDS::SubscriptionMatchedStatus matches = { 0, 0, 0, 0, 0 };
do {
if (ws->wait(conditions, timeout) != DDS::RETCODE_OK) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l main()")
ACE_TEXT(" ERROR: wait() failed!\n")), -1);
}
if (reader->get_subscription_matched_status(matches) != DDS::RETCODE_OK) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l main()")
//.........这里部分代码省略.........