本文整理汇总了C++中dds::DataWriter_var::get_matched_subscriptions方法的典型用法代码示例。如果您正苦于以下问题:C++ DataWriter_var::get_matched_subscriptions方法的具体用法?C++ DataWriter_var::get_matched_subscriptions怎么用?C++ DataWriter_var::get_matched_subscriptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dds::DataWriter_var
的用法示例。
在下文中一共展示了DataWriter_var::get_matched_subscriptions方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]){
try
{
DDS::DomainParticipantFactory_var dpf =
TheParticipantFactoryWithArgs(argc, argv);
DDS::DomainParticipant_var participant =
dpf->create_participant(311,
PARTICIPANT_QOS_DEFAULT,
DDS::DomainParticipantListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (participant.in ())) {
cerr << "create_participant failed." << endl;
return 1;
}
MessageTypeSupportImpl* servant = new MessageTypeSupportImpl();
if (DDS::RETCODE_OK != servant->register_type(participant.in (), "")) {
cerr << "register_type failed." << endl;
exit(1);
}
CORBA::String_var type_name = servant->get_type_name ();
DDS::TopicQos topic_qos;
participant->get_default_topic_qos(topic_qos);
DDS::Topic_var topic =
participant->create_topic ("Movie Discussion List",
type_name.in (),
topic_qos,
DDS::TopicListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (topic.in ())) {
cerr << "create_topic failed." << endl;
exit(1);
}
DDS::PublisherQos pub_qos;
participant->get_default_publisher_qos (pub_qos);
pub_qos.partition.name.length (1);
pub_qos.partition.name[0] = PARTITION_A;
DDS::Publisher_var pub =
participant->create_publisher(pub_qos, DDS::PublisherListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (pub.in ())) {
cerr << "create_publisher failed." << endl;
exit(1);
}
// ----------------------------------------------
// Create DataWriter which is belongs to PARTITION_A
DDS::DataWriter_var dw =
pub->create_datawriter (topic.in (),
DATAWRITER_QOS_DEFAULT,
DDS::DataWriterListener::_nil (),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
int const max_attempts = 15;
int attempts = 1;
// ----------------------------------------------
// Wait for first DataReader that belongs to PARTITION_A too,
// then write samples.
// cache handle for first reader.
::DDS::InstanceHandle_t handle = -1;
{
std::auto_ptr<Writer> writer (new Writer (dw.in ()));
cout << "Pub waiting for match on A partition." << std::endl;
if (OpenDDS::Model::WriterSync::wait_match(dw)) {
cerr << "Error waiting for match on A partition" << std::endl;
return 1;
}
while (attempts != max_attempts)
{
::DDS::InstanceHandleSeq handles;
dw->get_matched_subscriptions(handles);
cout << "Pub matched " << handles.length() << " A subs." << std::endl;
if (handles.length() == 1)
{
handle = handles[0];
break;
}
else
ACE_OS::sleep(1);
++attempts;
}
if (attempts == max_attempts)
{
cerr << "ERROR: failed to wait for first DataReader." << endl;
exit (1);
}
writer->start ();
//.........这里部分代码省略.........
示例2: ACE_TMAIN
//.........这里部分代码省略.........
if (deadline_status.total_count_change != NUM_EXPIRATIONS * NUM_WRITE_THREADS)
{
cerr << "ERROR: Incorrect missed offered "
<< "deadline count change ("
<< deadline_status.total_count_change
<< ") instead of " << NUM_EXPIRATIONS * NUM_WRITE_THREADS
<< endl;
exit (1);
}
if (deadline_status.last_instance_handle != handle1
&& deadline_status.last_instance_handle != handle2)
{
cerr << "ERROR: Unexpected last instance handle "
<< deadline_status.last_instance_handle << " instead of "
<< handle1 << " or "
<< handle2 << endl;
exit (1);
}
writer1->wait ();
writer2->wait ();
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Publisher: sleep for %d milliseconds\n"),
SLEEP_DURATION.msec()));
// Wait for another set of deadline periods to expire.
ACE_OS::sleep (SLEEP_DURATION);
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Publisher: now verify missed ")
ACE_TEXT ("deadline status \n")));
if (dw->get_offered_deadline_missed_status(deadline_status) != ::DDS::RETCODE_OK)
{
cerr << "ERROR: Failed to get offered deadline missed status" << endl;
exit (1);
}
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Publisher: got missed")
ACE_TEXT ("deadline status \n")));
if (deadline_status.total_count != (NUM_EXPIRATIONS + 2) * NUM_WRITE_THREADS)
{
cerr << "ERROR: Unexpected number of missed offered "
<< "deadlines (" << deadline_status.total_count
<< " instead of " << (NUM_EXPIRATIONS + 2) * NUM_WRITE_THREADS << ") "
<< endl;
exit (1);
}
if (deadline_status.total_count_change != NUM_WRITE_THREADS * 2)
{
cerr << "ERROR: Incorrect missed offered "
<< "deadline count change ("
<< deadline_status.total_count_change
<< ") instead of " << NUM_WRITE_THREADS * 2
<< endl;
exit (1);
}
if (deadline_status.last_instance_handle != handle1
&& deadline_status.last_instance_handle != handle2)
{
cerr << "ERROR: Unexpected last instance handle "
<< deadline_status.last_instance_handle << " instead of "
<< handle1 << " or "
<< handle2 << endl;
exit (1);
}
// Wait for datareader finish.
while (1)
{
::DDS::InstanceHandleSeq handles;
dw->get_matched_subscriptions (handles);
if (handles.length () == 0)
break;
else
ACE_OS::sleep(1);
}
}
participant->delete_contained_entities();
dpf->delete_participant(participant.in ());
TheServiceParticipant->shutdown ();
}
catch (CORBA::Exception& e)
{
cerr << "PUB: Exception caught in main.cpp:" << endl
<< e << endl;
exit(1);
}
return 0;
}
示例3: TheParticipantFactoryWithArgs
//.........这里部分代码省略.........
exit (1);
}
// Explicitly destroy the DataWriter.
if (pub->delete_datawriter (dw.in ())
== ::DDS::RETCODE_PRECONDITION_NOT_MET)
{
cerr << "Unable to delete DataWriter" << endl;
exit (1);
}
}
else
{
int const max_attempts = 50;
int attempts;
for (attempts = 1;
attempts != max_attempts
&& listener->publication_matched_.value () == false;
++attempts)
{
ACE_OS::sleep (5);
}
if (attempts == max_attempts)
{
cerr << "ERROR: subscriptions failed to match." << endl;
exit (1);
}
// Wait for DataReader to finish.
::DDS::InstanceHandleSeq handles;
for (attempts = 1; attempts != max_attempts; ++attempts)
{
dw->get_matched_subscriptions (handles);
if (handles.length () == 0)
break;
else
ACE_OS::sleep(1);
}
// The data durability cache should no longer contain samples
// for this domain/topic/type.
}
}
// -------------------------------------------------------
{
// Write samples that will not be sent. Exercise
// service_cleanup_delay. We can either do this through the
// durability member or durability_service member in either of
// TopicQos or DataWriterQos. This test arbitrarily uses the
// DataWriterQos::durability_service member.
// Cleanup data after this number of seconds.
CORBA::Long const delay_seconds = 5;
::DDS::Duration_t & cleanup_delay =
dw_qos.durability_service.service_cleanup_delay;
cleanup_delay.sec = delay_seconds;
cleanup_delay.nanosec = 0;
// Create a dummy topic which will have no subscriptions.
DDS::Topic_var dummy_topic =
participant->create_topic ("Dummy Topic",
type_name.in (),
示例4: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]){
try
{
DDS::DomainParticipantFactory_var dpf =
TheParticipantFactoryWithArgs(argc, argv);
DDS::DomainParticipant_var participant =
dpf->create_participant(11,
PARTICIPANT_QOS_DEFAULT,
DDS::DomainParticipantListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (participant.in ())) {
ACE_DEBUG((LM_DEBUG, "create_participant failed.\n"));
return 1;
}
MessageTypeSupportImpl* servant = new MessageTypeSupportImpl();
if (DDS::RETCODE_OK != servant->register_type(participant.in (), "")) {
ACE_DEBUG((LM_DEBUG, "register_type failed.\n"));
exit(1);
}
CORBA::String_var type_name = servant->get_type_name ();
DDS::TopicQos topic_qos;
participant->get_default_topic_qos(topic_qos);
DDS::Topic_var topic =
participant->create_topic ("Movie Discussion List",
type_name.in (),
topic_qos,
DDS::TopicListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (topic.in ())) {
ACE_DEBUG((LM_DEBUG, "create_topic failed.\n"));
exit(1);
}
DDS::Publisher_var pub =
participant->create_publisher(PUBLISHER_QOS_DEFAULT,
DDS::PublisherListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (pub.in ())) {
ACE_DEBUG((LM_DEBUG, "create_publisher failed.\n"));
exit(1);
}
DDS::DataWriterQos dw_qos;
pub->get_default_datawriter_qos (dw_qos);
dw_qos.deadline.period.sec = 4;
dw_qos.deadline.period.nanosec = 0;
// Create DataWriter with 4 second deadline period which
// should be compatible with first DataReader which has 5
// seconds deadline period and not with second DataReader
// which has 3 seconds deadline period.
DDS::DataWriter_var dw =
pub->create_datawriter(topic, dw_qos, 0,
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
int const max_attempts = 20000;
int attempts = 1;
{
// Wait for both first DataReader connect and write messages.
std::auto_ptr<Writer> writer (new Writer (dw.in ()));
while (attempts != max_attempts)
{
::DDS::InstanceHandleSeq handles;
dw->get_matched_subscriptions(handles);
if (handles.length() == 1)
break;
else
ACE_OS::sleep(1);
++attempts;
}
if (attempts == max_attempts)
{
ACE_DEBUG((LM_DEBUG, "ERROR: subscriptions failed to match.\n"));
exit (1);
}
writer->start ();
writer->end ();
ACE_DEBUG((LM_DEBUG, "Writer changing deadline to incompatible value\n"));
// Now set DataWriter deadline to be 6 seconds which is not
// compatible with the existing DataReader. This QoS change
// should be applied and the association broken.
dw_qos.deadline.period.sec = 6;
if (dw->set_qos (dw_qos) != ::DDS::RETCODE_OK) {
ACE_DEBUG((LM_DEBUG,
"ERROR: DataWriter could not change deadline period which "
"should break DataReader associations\n"));
exit (1);
} else {
//.........这里部分代码省略.........