本文整理汇总了C++中dds::DomainParticipantFactory_var::delete_participant方法的典型用法代码示例。如果您正苦于以下问题:C++ DomainParticipantFactory_var::delete_participant方法的具体用法?C++ DomainParticipantFactory_var::delete_participant怎么用?C++ DomainParticipantFactory_var::delete_participant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dds::DomainParticipantFactory_var
的用法示例。
在下文中一共展示了DomainParticipantFactory_var::delete_participant方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: guard
//.........这里部分代码省略.........
publisher->get_default_datawriter_qos(writer_qos);
writer_qos.reliability.kind = DDS::RELIABLE_RELIABILITY_QOS;
writer_qos.durability.kind = DDS::TRANSIENT_LOCAL_DURABILITY_QOS;
#ifndef OPENDDS_NO_OWNERSHIP_PROFILE
writer_qos.history.depth = static_cast<CORBA::Long>(samples_per_thread_);
#endif
writer =
publisher->create_datawriter(topic.in(),
writer_qos,
DDS::DataWriterListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil(writer.in()))
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: svc()")
ACE_TEXT(" create_datawriter failed!\n")), 1);
writer_i = FooDataWriter::_narrow(writer);
if (CORBA::is_nil(writer_i))
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: svc()")
ACE_TEXT(" _narrow failed!\n")), 1);
// Block until Subscriber is available
cond = writer->get_statuscondition();
cond->set_enabled_statuses(DDS::PUBLICATION_MATCHED_STATUS);
ws->attach_condition(cond);
DDS::Duration_t timeout =
{ DDS::DURATION_INFINITE_SEC, DDS::DURATION_INFINITE_NSEC };
DDS::ConditionSeq conditions;
DDS::PublicationMatchedStatus matches = {0, 0, 0, 0, 0};
do
{
if (ws->wait(conditions, timeout) != DDS::RETCODE_OK)
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: svc()")
ACE_TEXT(" wait failed!\n")), 1);
if (writer->get_publication_matched_status(matches) != ::DDS::RETCODE_OK)
{
ACE_ERROR ((LM_ERROR,
"(%P|%t) ERROR: failed to get publication matched status\n"));
ACE_OS::exit (1);
}
}
while (matches.current_count < 1);
ws->detach_condition(cond);
// The following is intentionally inefficient to stress various
// pathways related to publication; we should be especially dull
// and write only one sample at a time per writer.
ProgressIndicator progress("(%P|%t) PARTICIPANT %d%% (%d samples sent)\n",
samples_per_thread_);
for (std::size_t i = 0; i < samples_per_thread_; ++i)
{
Foo foo;
foo.key = 3;
DDS::InstanceHandle_t handle = writer_i->register_instance(foo);
if (writer_i->write(foo, handle) != DDS::RETCODE_OK) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: svc()")
ACE_TEXT(" write failed!\n")), 1);
}
++progress;
}
DDS::Duration_t interval = { 30, 0};
if( DDS::RETCODE_OK != writer->wait_for_acknowledgments( interval)) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P:%t) ERROR: svc() - ")
ACE_TEXT("timed out waiting for acks!\n")
), 1);
}
}
// Clean-up!
ACE_DEBUG((LM_INFO, ACE_TEXT("(%P|%t) <- PUBLISHER PARTICIPANT DEL CONT ENTITIES\n")));
participant->delete_contained_entities();
ACE_DEBUG((LM_INFO, ACE_TEXT("(%P|%t) <- PUBLISHER DELETE PARTICIPANT\n")));
dpf->delete_participant(participant.in());
ACE_DEBUG((LM_INFO, ACE_TEXT("(%P|%t) <- PUBLISHER PARTICIPANT VARS GOING OUT OF SCOPE\n")));
}
catch (const CORBA::Exception& e)
{
e._tao_print_exception("caught in svc()");
return 1;
}
ACE_DEBUG((LM_INFO, ACE_TEXT("(%P|%t) <- PARTICIPANT FINISHED\n")));
return 0;
}
示例2: main
//.........这里部分代码省略.........
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());
if (CORBA::is_nil (topic.in ())) {
cerr << "create_topic failed." << endl;
exit(1);
}
TAO::DCPS::TransportImpl_rch tcp_impl =
TheTransportFactory->create_transport_impl (transport_impl_id,
::TAO::DCPS::AUTO_CONFIG);
DDS::Publisher_var pub =
participant->create_publisher(PUBLISHER_QOS_DEFAULT,
DDS::PublisherListener::_nil());
if (CORBA::is_nil (pub.in ())) {
cerr << "create_publisher failed." << endl;
exit(1);
}
// Attach the publisher to the transport.
TAO::DCPS::PublisherImpl* pub_impl =
TAO::DCPS::reference_to_servant<TAO::DCPS::PublisherImpl> (pub.in());
if (0 == pub_impl) {
cerr << "Failed to obtain publisher servant" << endl;
exit(1);
}
TAO::DCPS::AttachStatus status = pub_impl->attach_transport(tcp_impl.in());
if (status != TAO::DCPS::ATTACH_OK) {
std::string status_str;
switch (status) {
case TAO::DCPS::ATTACH_BAD_TRANSPORT:
status_str = "ATTACH_BAD_TRANSPORT";
break;
case TAO::DCPS::ATTACH_ERROR:
status_str = "ATTACH_ERROR";
break;
case TAO::DCPS::ATTACH_INCOMPATIBLE_QOS:
status_str = "ATTACH_INCOMPATIBLE_QOS";
break;
default:
status_str = "Unknown Status";
break;
}
cerr << "Failed to attach to the transport. Status == "
<< status_str.c_str() << endl;
exit(1);
}
// Create the datawriter
DDS::DataWriterQos dw_qos;
pub->get_default_datawriter_qos (dw_qos);
dw_qos.durability.kind = DDS::TRANSIENT_LOCAL_DURABILITY_QOS;
dw_qos.reliability.kind = ::DDS::RELIABLE_RELIABILITY_QOS;
dw_qos.resource_limits.max_samples_per_instance = 1000;
dw_qos.history.kind = ::DDS::KEEP_ALL_HISTORY_QOS;
DDS::DataWriter_var dw =
pub->create_datawriter(topic.in (),
dw_qos,
DDS::DataWriterListener::_nil());
if (CORBA::is_nil (dw.in ())) {
cerr << "create_datawriter failed." << endl;
exit(1);
}
Writer* writer = new Writer(dw.in());
writer->start ();
while ( !writer->is_finished()) {
ACE_Time_Value small(0,250000);
ACE_OS::sleep (small);
}
// Cleanup
writer->end ();
delete writer;
participant->delete_contained_entities();
dpf->delete_participant(participant.in ());
TheTransportFactory->release();
TheServiceParticipant->shutdown ();
}
catch (CORBA::Exception& e)
{
cerr << "PUB: Exception caught in main.cpp:" << endl
<< e << endl;
exit(1);
}
return 0;
}
示例3: ACE_TMAIN
//.........这里部分代码省略.........
{
::DDS::SubscriptionMatchedStatus status1;
::DDS::SubscriptionMatchedStatus status2;
if (dr1->get_subscription_matched_status (status1) == ::DDS::RETCODE_OK
&& dr2->get_subscription_matched_status (status2) == ::DDS::RETCODE_OK)
{
if (status1.total_count == 2 && status2.total_count == 2)
break;
++ attempts;
ACE_OS::sleep (1);
}
else
{
cerr << "ERROR: Failed to get subscription matched status" << endl;
exit (1);
}
}
if (attempts >= max_attempts)
{
cerr << "ERROR: failed to make associations. " << endl;
exit (1);
}
// ----------------------------------------------
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Subscriber: sleep for %d milliseconds\n"),
SLEEP_DURATION.msec()));
// Wait for publisher to finish sending
ACE_OS::sleep (SLEEP_DURATION);
long rej_max_samples = listener_servant->num_rejected_for_max_samples();
long rej_max_instances = listener_servant->num_rejected_for_max_instances();
long rej_max_samp_instance = listener_servant->num_rejected_for_max_samples_per_instance();
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Subscriber: %d rejected for ")
ACE_TEXT ("max_samples\n"),
rej_max_samples));
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Subscriber: %d rejected for ")
ACE_TEXT ("max_instances\n"),
rej_max_instances));
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Subscriber: %d rejected for ")
ACE_TEXT ("max_samples_per_instance\n"),
rej_max_samp_instance));
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Subscriber: received %d ")
ACE_TEXT ("samples\n"),
listener_servant->num_arrived() ));
// 3 instances writing 5 messages each
// expect 2 rejected for max_samples
// expect 6 rejected for max_instances (register_instance + 5 messages)
// expect 1 rejected for max_samples_per_instance
#ifndef OPENDDS_NO_OWNERSHIP_PROFILE
if (rej_max_samples != 2) {
cerr << "ERROR: Failed to reject expected for max_samples" << endl;
return_result = 1;
}
#endif
if (rej_max_instances != 6) {
cerr << "ERROR: Failed to reject expected for max_instances" << endl;
return_result = 1;
}
#ifndef OPENDDS_NO_OWNERSHIP_PROFILE
if (rej_max_samp_instance != 1) {
cerr << "ERROR: Failed to reject expected for max_samples_per_instance" << endl;
return_result = 1;
}
#endif
Messenger::MessageDataReader_var message_dr1 =
Messenger::MessageDataReader::_narrow(dr1.in());
Messenger::MessageDataReader_var message_dr2 =
Messenger::MessageDataReader::_narrow(dr2.in());
message_dr1->set_listener(DDS::DataReaderListener::_nil (),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
message_dr2->set_listener(DDS::DataReaderListener::_nil (),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
listener = DDS::DataReaderListener::_nil ();
ACE_OS::sleep (2);
if (!CORBA::is_nil (participant.in ())) {
participant->delete_contained_entities();
}
if (!CORBA::is_nil (dpf.in ())) {
dpf->delete_participant(participant.in ());
}
ACE_OS::sleep(2);
TheServiceParticipant->shutdown ();
}
catch (CORBA::Exception& e)
{
cerr << "SUB: Exception caught in main ():" << endl << e << endl;
return_result = 1;
}
return return_result;
}
示例4: ACE_TMAIN
//.........这里部分代码省略.........
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (dr.in ())) {
cerr << "create_datareader failed." << endl;
exit(1);
}
// Indicate that the subscriber is ready
FILE* readers_ready = ACE_OS::fopen (sub_ready_filename, ACE_TEXT ("w"));
if (readers_ready == 0) {
cerr << "ERROR Unable to create subscriber ready file." << endl;
exit(1);
}
ACE_OS::fclose(readers_ready);
// Wait for the publisher to be ready
FILE* writers_ready = 0;
do {
ACE_Time_Value small_time(0,250000);
ACE_OS::sleep (small_time);
writers_ready = ACE_OS::fopen (pub_ready_filename, ACE_TEXT ("r"));
} while (0 == writers_ready);
ACE_OS::fclose(writers_ready);
// Since the publisher continue sending while the subscriber crashes,
// some messages may be lost, we lower the num_expected_reads by 2.
num_expected_reads -= num_reads_deviation;
FILE* writers_completed = 0;
int timeout_writes = 0;
while ( listener_servant->num_reads() < num_expected_reads) {
// Get the number of the timed out writes from publisher so we
// can re-calculate the number of expected messages. Otherwise,
// the blocking timeout test will never exit from this loop.
if (writers_completed == 0) {
writers_completed = ACE_OS::fopen (pub_finished_filename, ACE_TEXT ("r"));
if (writers_completed != 0) {
if (end_with_publisher)
{
// Since we are in the "bp_timeout" test case that publisher
// close connection when backpressure last longer than
// max_output_pause_period, the publisher ends as it finishes
// sending. As the subscriber sees the publisher is done, it
// changes the read_delay_ms to 0 so it can read all received
// messages and them announce it completed.
int old_read_delay_ms = read_delay_ms;
read_delay_ms = 0;
// Give time to finish reading.
ACE_OS::sleep (old_read_delay_ms/1000 * 2);
break;
}
//writers_completed = ACE_OS::fopen (pub_finished_filename, "r");
fscanf (writers_completed, "%d\n", &timeout_writes);
num_expected_reads -= timeout_writes;
cout << "timed out writes " << timeout_writes << ", we expect "
<< num_expected_reads << endl;
}
}
ACE_OS::sleep (1);
}
// Indicate that the subscriber is done
FILE* readers_completed = ACE_OS::fopen (sub_finished_filename, ACE_TEXT ("w"));
if (readers_completed == 0) {
cerr << "ERROR Unable to create subscriber completed file." << endl;
exit(1);
}
ACE_OS::fclose(readers_completed);
// Wait for 5 seconds to (>passive_reconnect_duration)
// to give transport time to detect the connection lost due to
// backpressure timeout before shutdown the datareader.
if (end_with_publisher)
ACE_OS::sleep (5);
if (!CORBA::is_nil (participant.in ())) {
participant->delete_contained_entities();
}
if (!CORBA::is_nil (dpf.in ())) {
dpf->delete_participant(participant.in ());
}
TheServiceParticipant->shutdown ();
} catch (CORBA::Exception& e) {
cerr << "Exception caught in main ():" << endl << e << endl;
return 1;
}
if (verify_lost_sub_notification
&& actual_lost_sub_notification != expected_lost_sub_notification)
{
ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: on_subscription_lost called %d times "
"and expected %d times\n", actual_lost_sub_notification,
expected_lost_sub_notification));
return 1;
}
return 0;
}
示例5: SubscriberListenerImpl
//.........这里部分代码省略.........
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
DDS::TopicDescription_ptr topic_used = topic.in();
DDS::ContentFilteredTopic_ptr cft = 0;
if (use_cft)
{
// Topic name must be unique.
ACE_CString topic_name = "FooTopic-Filtered-" + toStr(i);
cft =
participant->create_contentfilteredtopic(topic_name.c_str(),
topic,
"key > 0",
DDS::StringSeq());
if (CORBA::is_nil(cft))
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" create_contentfilteredtopic failed!\n")), 8);
topic_used = cft;
}
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
DDS::DataReaderQos reader_qos;
subscriber->get_default_datareader_qos(reader_qos);
reader_qos.history.kind = DDS::KEEP_ALL_HISTORY_QOS;
if (deadline_used)
{
reader_qos.deadline.period.sec = DEADLINE_PERIOD.sec;
reader_qos.deadline.period.nanosec = DEADLINE_PERIOD.nanosec;
}
DDS::DataReader_var reader =
subscriber->create_datareader(topic_used,
reader_qos,
DDS::DataReaderListener::_nil(),
::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);
ACE_Time_Value sample_count_sleep(0, sample_count_sleep_msec * 1000);
std::size_t sample_count;
std::size_t sample_count_start = subscriberListener->samples_processed();
do
{
ACE_OS::sleep(sample_count_sleep);
sample_count =
subscriberListener->samples_processed();
expected_samples_received = sample_count >= expected_samples;
// ACE_DEBUG((LM_DEBUG, "(%P|%t) sample_count = %d\n", sample_count));
}
while (!expected_samples_received &&
(sample_count - sample_count_start) < samples_per_cycle);
subscriber->delete_datareader(reader.in());
if (use_cft)
CORBA::release(cft);
participant->delete_subscriber(subscriber.in());
ACE_OS::sleep(delay_between_cycles);
}
while (!expected_samples_received);
participant->delete_contained_entities();
dpf->delete_participant(participant.in());
TheServiceParticipant->shutdown();
ACE_DEBUG ((LM_INFO,
ACE_TEXT("INFO: %d samples received\n"),
subscriberListener->received_samples()));
if (deadline_used)
ACE_DEBUG ((LM_INFO,
ACE_TEXT("INFO: deadline missed %d times\n"),
subscriberListener->missed_samples()));
}
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")));
return 0;
}
示例6: shifter
//.........这里部分代码省略.........
ACE_TEXT("ERROR: %N:%l: main() -")
ACE_TEXT(" register_type failed!\n")),
-1);
}
// Create Topic
CORBA::String_var type_name = ts->get_type_name();
DDS::Topic_var topic =
participant->create_topic("TheTopic",
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);
}
const int n_msgs = reliable ? MSGS_PER_WRITER * total_writers : 0;
// Create DataReaders
for (std::vector<std::string>::iterator pos = readers.begin(), limit = readers.end();
pos != limit;
++pos) {
pos->resize(6);
DDS::DataReaderListener_var listener(new DataReaderListenerImpl(*pos, n_msgs, reader_done_callback));
DDS::DataReaderQos qos;
subscriber->get_default_datareader_qos(qos);
qos.user_data.value.length(3);
qos.user_data.value[0] = fromhex(*pos, 0);
qos.user_data.value[1] = fromhex(*pos, 1);
qos.user_data.value[2] = fromhex(*pos, 2);
qos.reliability.kind = reliable ? DDS::RELIABLE_RELIABILITY_QOS : DDS::BEST_EFFORT_RELIABILITY_QOS;
DDS::DataReader_var reader =
subscriber->create_datareader(topic,
qos,
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);
}
TestMsgDataReader_var reader_i =
TestMsgDataReader::_narrow(reader);
if (!reader_i) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: main() -")
ACE_TEXT(" _narrow failed!\n")),
-1);
}
}
WriterTask task(writers, participant, topic, reliable, total_readers);
task.activate(DEFAULT_FLAGS, writers.size());
task.wait();
if (!reliable)
ACE_OS::sleep(10);
else {
ACE_Guard<ACE_Thread_Mutex> g(readers_done_lock);
while (readers_done != static_cast<int>(readers.size()))
readers_done_cond.wait();
// Sleep allows an ACKNACK to be generated.
ACE_OS::sleep(3);
}
// Clean-up!
participant->delete_contained_entities();
dpf->delete_participant(participant);
TheServiceParticipant->shutdown();
} catch (const CORBA::Exception& e) {
e._tao_print_exception("Exception caught in main():");
return -1;
}
return 0;
}
示例7: MessageTypeSupportImpl
//.........这里部分代码省略.........
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* listener_svt = new DataReaderListenerImpl;
DDS::DataReaderListener_var listener(listener_svt);
DDS::DataReaderQos qos;
sub->get_default_datareader_qos(qos);
qos.liveliness.kind = DDS::AUTOMATIC_LIVELINESS_QOS;
qos.liveliness.lease_duration.sec = 10;
qos.liveliness.lease_duration.nanosec = 0;
qos.history.kind = DDS::KEEP_ALL_HISTORY_QOS;
bool reliable = true;
parse_args(argc, argv, reliable);
if (reliable) {
qos.reliability.kind = DDS::RELIABLE_RELIABILITY_QOS;
}
DDS::DataReader_var reader =
sub->create_datareader(topic.in(),
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);
}
for (int delay = 0; listener_svt->num_samples() != num_messages_expected
&& delay < 60; ++delay) {
ACE_OS::sleep(1);
}
const long received = listener_svt->num_samples();
const bool data_consistent = listener_svt->data_consistent();
if (reliable && data_consistent && received < num_messages_expected) {
std::cout << "ERROR: data loss (" << received << "/"
<< num_messages_expected << " received)\n";
status = EXIT_FAILURE;
}
else if (!data_consistent) {
status = EXIT_FAILURE;
}
else {
const unsigned int percent = ((num_messages_expected - received) * 100) / num_messages_expected;
std::cout << "data loss == " << percent << "% (" << received << "/"
<< num_messages_expected << " received)\n";
}
// Clean-up!
ACE_DEBUG((LM_DEBUG, "Subscriber delete contained entities\n"));
participant->delete_contained_entities();
ACE_DEBUG((LM_DEBUG, "Subscriber delete participant\n"));
dpf->delete_participant(participant);
ACE_DEBUG((LM_DEBUG, "Subscriber shutdown\n"));
TheServiceParticipant->shutdown();
ACE_DEBUG((LM_DEBUG, "Subscriber wait for thread manager\n"));
ACE_Thread_Manager::instance()->wait();
ACE_DEBUG((LM_DEBUG, "Subscriber vars going out of scope\n"));
} catch (const CORBA::Exception& e) {
e._tao_print_exception("Exception caught in main():");
status = EXIT_FAILURE;
}
ACE_DEBUG((LM_DEBUG, "Subscriber exiting with status=%d\n", status));
return status;
}
示例8: ACE_TMAIN
//.........这里部分代码省略.........
}
if (participant->enable () != ::DDS::RETCODE_PRECONDITION_NOT_MET)
{
cerr << "DomainParticipant can not be enabled because factory autoenable is off." << endl;
return 1;
}
MessageTypeSupport_var mts = new MessageTypeSupportImpl();
if (DDS::RETCODE_OK != mts->register_type(participant.in (), "")) {
cerr << "register_type failed." << endl;
exit(1);
}
CORBA::String_var type_name = mts->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 ())) {
cerr << "create_topic failed." << endl;
exit(1);
}
if (topic->enable () != ::DDS::RETCODE_PRECONDITION_NOT_MET)
{
cerr << "Topic can not be enabled because DomainParticipant is not enabled." << endl;
return 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 ())) {
cerr << "create_publisher failed." << endl;
exit(1);
}
if (pub->enable () != ::DDS::RETCODE_PRECONDITION_NOT_MET)
{
cerr << "Publisher can not be enabled because DomainParticipant is not enabled." << endl;
return 1;
}
// Create the datawriter
DDS::DataWriter_var dw =
pub->create_datawriter(topic.in (),
DATAWRITER_QOS_DEFAULT,
DDS::DataWriterListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (dw.in ())) {
cerr << "create_datawriter failed." << endl;
exit(1);
}
if (dw->enable () != ::DDS::RETCODE_PRECONDITION_NOT_MET)
{
cerr << "DataWriter can not be enabled because Publisher is not enabled." << endl;
return 1;
}
// Now enable DomainParticipantFactory autoenable
fqos.entity_factory.autoenable_created_entities = 1;
if (dpf->set_qos (fqos) != ::DDS::RETCODE_OK)
{
cerr << "DomainParticipantFactory set_qos failed." << endl;
return 1;
}
// Enable every entity from factory to it's entities and it should succeed.
if (participant->enable () != ::DDS::RETCODE_OK
|| topic->enable () != ::DDS::RETCODE_OK
|| pub->enable () != ::DDS::RETCODE_OK)
{
cerr << "Failed to enable factory." << endl;
return 1;
}
Writer* writer = new Writer(dw.in());
writer->start ();
writer->wait ();
delete writer;
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;
}
示例9: ACE_TMAIN
int ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
DDS::DomainParticipantFactory_var dpf;
DDS::DomainParticipant_var participant;
dpf = TheParticipantFactoryWithArgs(argc, argv);
participant = dpf->create_participant(111,
PARTICIPANT_QOS_DEFAULT,
DDS::DomainParticipantListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (participant.in ())) {
cerr << "create_participant failed." << endl;
return 1 ;
}
Messenger::MessageTypeSupport_var mts_servant =
new Messenger::MessageTypeSupportImpl;
if (DDS::RETCODE_OK != mts_servant->register_type (participant.in (),
""))
{
cerr << "Failed to register the MessageTypeTypeSupport." << endl;
exit(1);
}
CORBA::String_var type_name = mts_servant->get_type_name ();
DDS::TopicQos topic_qos;
participant->get_default_topic_qos(topic_qos);
topic_qos.lifespan.duration.sec = 10;
topic_qos.lifespan.duration.nanosec = 0;
topic_qos.durability.kind = DDS::TRANSIENT_LOCAL_DURABILITY_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 << "Failed to create_topic." << endl;
exit(1);
}
// Create the subscriber and attach to the corresponding
// transport.
DDS::Subscriber_var sub =
participant->create_subscriber(SUBSCRIBER_QOS_DEFAULT,
DDS::SubscriberListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (sub.in ()))
{
cerr << "Failed to create_subscriber." << endl;
exit(1);
}
// activate the listener
DDS::DataReaderListener_var listener (new DataReaderListenerImpl);
DataReaderListenerImpl* const listener_servant =
dynamic_cast<DataReaderListenerImpl*>(listener.in());
if (CORBA::is_nil (listener.in ())) {
cerr << "listener is nil." << endl;
exit(1);
}
if (!listener_servant) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l main()")
ACE_TEXT(" ERROR: listener_servant is nil (dynamic_cast failed)!\n")), -1);
}
// Create the Datareaders
DDS::DataReader_var dr = sub->create_datareader(topic.in (),
DATAREADER_QOS_USE_TOPIC_QOS,
listener.in (),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (dr.in ())) {
cerr << "create_datareader failed." << endl;
exit(1);
}
ACE_OS::sleep (10);
if (listener_servant->num_reads () != 1)
{
cerr << "ERROR: Incorrect number of samples received." << endl
<< " Expired data was probably read." << endl;
exit (1);
}
if (!CORBA::is_nil (participant.in ())) {
participant->delete_contained_entities();
}
if (!CORBA::is_nil (dpf.in ())) {
dpf->delete_participant(participant.in ());
}
ACE_OS::sleep(2);
TheServiceParticipant->shutdown ();
//.........这里部分代码省略.........
示例10: 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;
}
示例11: ACE_TMAIN
//.........这里部分代码省略.........
));
}
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 << "Failed to create_topic." << endl;
exit(1);
}
if( OpenDDS::DCPS::DCPS_debug_level > 0) {
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) subscriber: ")
ACE_TEXT("topic created.\n")
));
}
// Create the subscriber and attach to the corresponding
// transport.
DDS::Subscriber_var sub =
participant->create_subscriber(SUBSCRIBER_QOS_DEFAULT,
DDS::SubscriberListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (sub.in ())) {
cerr << "Failed to create_subscriber." << endl;
exit(1);
}
if( OpenDDS::DCPS::DCPS_debug_level > 0) {
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) subscriber: ")
ACE_TEXT("subscriber created.\n")
));
}
// activate the listener
DDS::DataReaderListener_var listener (new DataReaderListenerImpl);
DataReaderListenerImpl* listener_servant =
dynamic_cast<DataReaderListenerImpl*>(listener.in());
if (CORBA::is_nil (listener.in ())) {
cerr << "listener is nil." << endl;
exit(1);
}
if( OpenDDS::DCPS::DCPS_debug_level > 0) {
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) subscriber: ")
ACE_TEXT("listener created.\n")
));
}
// Create the Datareaders
DDS::DataReaderQos dr_qos;
sub->get_default_datareader_qos (dr_qos);
DDS::DataReader_var dr = sub->create_datareader(topic.in (),
dr_qos,
listener.in (),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (dr.in ())) {
cerr << "create_datareader failed." << endl;
exit(1);
}
if( OpenDDS::DCPS::DCPS_debug_level > 0) {
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) subscriber: ")
ACE_TEXT("processing starting.\n")
));
}
int expected = 5;
while ( listener_servant->num_reads() < expected) {
ACE_OS::sleep (1);
}
if (!CORBA::is_nil (participant.in ())) {
participant->delete_contained_entities();
}
if (!CORBA::is_nil (dpf.in ())) {
dpf->delete_participant(participant.in ());
}
ACE_OS::sleep(2);
TheServiceParticipant->shutdown ();
}
catch (CORBA::Exception& e)
{
cerr << "SUB: Exception caught in main ():" << endl << e << endl;
return 1;
}
return 0;
}
示例12: configopt
//.........这里部分代码省略.........
Puller r2(fplain, dpf, participant2, drl2);
TEST_ASSERT(assert_supported(configopt, r1.reader_));
TEST_ASSERT(assert_supported(configopt, r2.reader_));
r1.pull(ACE_Time_Value(1));
}
else if (configopt.collocation_str == "pubsub")
{
participant1 = fconfig.participant(dpf);
participant2 = participant1;
DDS::Subscriber_var subscriber1(fconfig.subscriber(participant1));
Puller r1(fconfig, dpf, participant1, subscriber1, drl1);
DDS::Subscriber_var subscriber2(fplain.subscriber(participant2));
Puller r2(fplain, dpf, participant2, subscriber2, drl1);
TEST_ASSERT(assert_supported(configopt, r1.reader_));
TEST_ASSERT(assert_supported(configopt, r2.reader_));
r1.pull(ACE_Time_Value(1));
}
if (configopt.collocation_str == "none")
{
TEST_ASSERT(assert_subscription_matched(configopt, drl1));
}
else if (configopt.collocation_str == "process")
{
TEST_ASSERT(assert_subscription_matched(configopt, drl1)
&& assert_subscription_matched(configopt, drl2));
}
else if (configopt.collocation_str == "participant")
{
TEST_ASSERT(assert_subscription_matched(configopt, drl1)
&& assert_subscription_matched(configopt, drl2));
}
else if (configopt.collocation_str == "pubsub")
{
TEST_ASSERT(assert_subscription_matched(configopt, drl1)
&& assert_subscription_matched(configopt, drl2));
}
}
ACE_DEBUG((LM_INFO, ACE_TEXT("(%P|%t) Shutting subscriber down ...\n")));
{
ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, shutdown_lock, 1);
shutdown_flag = true;
}
// only want to clean up participant2 if it isn't just pointing to
// participant1
if (participant1.in() == participant2.in())
participant2 = 0;
if (participant1) {
ACE_DEBUG((LM_INFO, ACE_TEXT("(%P|%t) deleting entities1\n")));
// Delete any topics, publishers and subscribers owned by participant
participant1->delete_contained_entities();
ACE_DEBUG((LM_INFO, ACE_TEXT("(%P|%t) deleting participant1\n")));
// Delete participant itself
dpf->delete_participant(participant1);
}
if (participant2) {
ACE_DEBUG((LM_INFO, ACE_TEXT("(%P|%t) deleting entities2\n")));
// Delete any topics, publishers and subscribers owned by participant
participant2->delete_contained_entities();
ACE_DEBUG((LM_INFO, ACE_TEXT("(%P|%t) deleting participant2\n")));
// Delete participant itself
dpf->delete_participant(participant2);
}
ACE_DEBUG((LM_INFO, ACE_TEXT("(%P|%t) Subscriber shutting down svc part\n")));
// Shut down info repo connection
TheServiceParticipant->shutdown();
ACE_DEBUG((LM_INFO, ACE_TEXT("(%P|%t) Subscriber shutdown complete\n")));
}
catch (char const *ex)
{
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) Assertion failed.\n"), ex), -1);
}
catch (const CORBA::Exception &ex)
{
ex._tao_print_exception("Exception caught in main.cpp:");
return 1;
}
catch (const OpenDDS::DCPS::Transport::MiscProblem& )
{
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) Transport::MiscProblem caught.\n")), -1);
}
ACE_ERROR_RETURN((LM_INFO,
ACE_TEXT("(%P|%t) done.\n")), 0);
}
示例13: ACE_TMAIN
//.........这里部分代码省略.........
dw2_qos.liveliness.kind = ::DDS::MANUAL_BY_PARTICIPANT_LIVELINESS_QOS;
dw2_qos.liveliness.lease_duration.sec = LEASE_DURATION_SEC;
dw2_qos.liveliness.lease_duration.nanosec = 0;
// Create the datawriter
DDS::DataWriter_var dw1 =
pub->create_datawriter(topic.in (),
dw_qos,
dwl1.in(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (dw1.in ())) {
cerr << "create_datawriter failed." << endl;
exit(1);
}
// Create the datawriter
DDS::DataWriter_var dw2 =
pub2->create_datawriter(topic2.in (),
dw2_qos,
dwl2.in(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (dw2.in ())) {
cerr << "create_datawriter failed." << endl;
exit(1);
}
dw_qos.liveliness.kind = ::DDS::MANUAL_BY_TOPIC_LIVELINESS_QOS;
// Create the datawriter
DDS::DataWriter_var dw3 =
pub->create_datawriter(topic.in (),
dw_qos,
dwl3.in(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (dw3.in ())) {
cerr << "create_datawriter failed." << endl;
exit(1);
}
// Create the datawriter
DDS::DataWriter_var dw4 =
pub->create_datawriter(topic.in (),
dw_qos,
dwl4.in(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (dw4.in ())) {
cerr << "create_datawriter failed." << endl;
exit(1);
}
{
Write_Samples writer1(dw1, "Manual_By_Participant_Writer_1");
Assert_Participant_Liveliness writer2(dw2, "Manual_By_Participant_Writer_2");
Write_Samples writer3(dw3, "Manual_By_Topic_Writer_1");
Assert_Writer_Liveliness writer4(dw4, "Manual_By_Topic_Writer_2");
writer1.start();
writer2.start();
writer3.start();
writer4.start();
writer1.end();
writer2.end();
writer3.end();
writer4.end();
}
const unsigned long actual = dwl1_servant->num_liveliness_lost_callbacks() +
dwl2_servant->num_liveliness_lost_callbacks() +
dwl3_servant->num_liveliness_lost_callbacks() +
dwl4_servant->num_liveliness_lost_callbacks();
if (liveliness_lost_test
&& static_cast<int>(actual) != num_liveliness_lost_callbacks)
{
cerr << "ERROR: did not receive expected liveliness lost callbacks. "
<< actual << "/" <<
num_liveliness_lost_callbacks << endl;
status = 1;
}
ACE_OS::sleep(1);
ACE_DEBUG((LM_INFO, "publisher deleting entities\n"));
participant->delete_contained_entities();
dpf->delete_participant(participant.in ());
participant2->delete_contained_entities();
dpf->delete_participant(participant2.in ());
TheServiceParticipant->shutdown ();
}
catch (CORBA::Exception& e)
{
cerr << "PUB: Exception caught in main.cpp:" << endl
<< e << endl;
exit(1);
}
catch (const OpenDDS::DCPS::Transport::MiscProblem&)
{
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) Transport::MiscProblem caught.\n")), -1);
}
return status;
}
示例14: main
int main (int argc, char *argv[])
{
try {
// initialize the participant. the same as in the publisher
DDS::DomainParticipantFactory_var dpf =
TheParticipantFactoryWithArgs(argc, argv);
DDS::DomainParticipant_var participant =
dpf->create_participant(42, // Domain ID
PARTICIPANT_QOS_DEFAULT,
0, // No listener required
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (!participant)
{
std::cerr << "create_participant failed." << std::endl;
return 1 ;
}
Messenger::MessageTypeSupport_var mts =
new Messenger::MessageTypeSupportImpl();
if (DDS::RETCODE_OK != mts->register_type(participant, ""))
{
std::cerr << "Failed to register the MessageTypeSupport." << std::endl;
return 1;
}
CORBA::String_var type_name = mts->get_type_name ();
DDS::Topic_var topic =
participant->create_topic("Movie Discussion List",
type_name,
TOPIC_QOS_DEFAULT,
0, // No listener required
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (!topic)
{
std::cerr << "Failed to create_topic." << std::endl;
return 1;
}
// Create the subscriber
DDS::Subscriber_var sub =
participant->create_subscriber(SUBSCRIBER_QOS_DEFAULT,
0, // No listener required
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (!sub)
{
std::cerr << "Failed to create_subscriber." << std::endl;
return 1;
}
// Associate a listener object with the data reader we create,
// so we can use it to detect when data is available.
// The listener is allocated on the heap and assigned to a//
// DataReaderListener_var object. This type provides
// reference counting behavior so the listener is
// automatically cleaned up when the last reference to it is
// removed. This usage is typical for heap allocations in
// OpenDDS application code and frees the application
// developer from having to actively manage the lifespan of
// the allocated objects.
DDS::DataReaderListener_var listener(new DataReaderListenerImpl);
// Create the data reader
DDS::DataReader_var dr =
sub->create_datareader(topic,
DATAREADER_QOS_DEFAULT,
listener,
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (!dr) {
std::cerr << "create_datareader failed." << std::endl;
return 1;
}
// clean up
//1. delete all the topics, subscribers and publishers create
// with this participant
//2. when done, use the factory to delete the domain participant.
participant->delete_contained_entities();
dpf->delete_participant(participant);
TheServiceParticipant->shutdown ();
} catch(...)
{
std::cerr << "ERROR!!! exception caught" << std::endl;
}
}
示例15: TheParticipantFactoryWithArgs
//.........这里部分代码省略.........
// Create DataWriter
DDS::DataWriter_var writer =
publisher->create_datawriter(topic,
DATAWRITER_QOS_DEFAULT,
0,
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (!writer) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: main() -")
ACE_TEXT(" create_datawriter failed!\n")),
-1);
}
Messenger::MessageDataWriter_var message_writer =
Messenger::MessageDataWriter::_narrow(writer);
if (!message_writer) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: main() -")
ACE_TEXT(" _narrow failed!\n")),
-1);
}
// Block until Subscriber is available
DDS::StatusCondition_var condition = writer->get_statuscondition();
condition->set_enabled_statuses(DDS::PUBLICATION_MATCHED_STATUS);
DDS::WaitSet_var ws = new DDS::WaitSet;
ws->attach_condition(condition);
while (true) {
DDS::PublicationMatchedStatus matches;
if (writer->get_publication_matched_status(matches) != ::DDS::RETCODE_OK) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: main() -")
ACE_TEXT(" get_publication_matched_status failed!\n")),
-1);
}
if (matches.current_count >= 1) {
break;
}
DDS::ConditionSeq conditions;
DDS::Duration_t timeout = { 60, 0 };
if (ws->wait(conditions, timeout) != DDS::RETCODE_OK) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: main() -")
ACE_TEXT(" wait failed!\n")),
-1);
}
}
ws->detach_condition(condition);
// Write samples
Messenger::Message message;
message.subject_id = 99;
message.from = "Comic Book Guy";
message.subject = "Review";
message.text = "Worst. Movie. Ever.";
message.count = 0;
for (int i = 0; i < 10; ++i) {
DDS::ReturnCode_t error = message_writer->write(message, DDS::HANDLE_NIL);
++message.count;
++message.subject_id;
if (error != DDS::RETCODE_OK) {
ACE_ERROR((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: main() -")
ACE_TEXT(" write returned %d!\n"), error));
}
}
// Wait for samples to be acknowledged
DDS::Duration_t timeout = { 30, 0 };
if (message_writer->wait_for_acknowledgments(timeout) != DDS::RETCODE_OK) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: main() -")
ACE_TEXT(" wait_for_acknowledgments failed!\n")),
-1);
}
// Clean-up!
participant->delete_contained_entities();
dpf->delete_participant(participant);
TheServiceParticipant->shutdown();
} catch (const CORBA::Exception& e) {
e._tao_print_exception("Exception caught in main():");
return -1;
}
return 0;
}