inline bool isDistinct(Home home, ViewArray<IntView>& x, ViewArray<Card>& k) { if (Card::propagate) { Region r(home); ViewRanges<IntView>* xrange = r.alloc<ViewRanges<IntView> >(x.size()); for (int i = x.size(); i--; ){ ViewRanges<IntView> iter(x[i]); xrange[i] = iter; } Iter::Ranges::NaryUnion drl(r, &xrange[0], x.size()); if (static_cast<unsigned int>(k.size()) == Iter::Ranges::size(drl)) { for (int i=k.size(); i--;) if (k[i].min() != 1 || k[i].max() != 1) return false; return true; } else { return false; } } else { for (int i=k.size(); i--;) if (k[i].min() != 0 || k[i].max() != 1) return false; return true; } }
void SubDriver::init(int& argc, ACE_TCHAR* argv[]) { ::DDS::DomainParticipantFactory_var dpf = TheParticipantFactoryWithArgs(argc, argv); parse_args(argc, argv); participant_ = dpf->create_participant(MY_DOMAIN, PARTICIPANT_QOS_DEFAULT, ::DDS::DomainParticipantListener::_nil(), ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); TEST_CHECK (! CORBA::is_nil (participant_.in ())); ::Xyz::SampleTypeTypeSupport_var fts (new ::Xyz::SampleTypeTypeSupportImpl); if (::DDS::RETCODE_OK != fts->register_type(participant_.in (), MY_TYPE)) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Failed to register the SampleTypeTypeSupport."))); } ::DDS::TopicQos default_topic_qos; participant_->get_default_topic_qos(default_topic_qos); ::DDS::TopicQos new_topic_qos = default_topic_qos; new_topic_qos.reliability.kind = ::DDS::RELIABLE_RELIABILITY_QOS; participant_->set_default_topic_qos(new_topic_qos); topic_ = participant_->create_topic (MY_TOPIC, MY_TYPE, TOPIC_QOS_DEFAULT, ::DDS::TopicListener::_nil(), ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); TEST_CHECK (! CORBA::is_nil (topic_.in ())); subscriber_ = participant_->create_subscriber(SUBSCRIBER_QOS_DEFAULT, ::DDS::SubscriberListener::_nil(), ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); TEST_CHECK (! CORBA::is_nil (subscriber_.in ())); std::cout << std::hex << "0x" << subscriber_->get_instance_handle() << std::endl; // Create datareader to test copy_from_topic_qos. listener_ = new DataReaderListenerImpl; ::DDS::DataReaderListener_var drl (listener_); datareader_ = subscriber_->create_datareader(topic_.in (), DATAREADER_QOS_USE_TOPIC_QOS, drl.in(), ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); TEST_CHECK (! CORBA::is_nil (datareader_.in ())); // And we are done with the init(). }
Reader::Reader(::DDS::DomainParticipant_ptr dp, int history_depth, int max_samples_per_instance) : max_samples_per_instance_(max_samples_per_instance), dp_(::DDS::DomainParticipant::_duplicate (dp)) { sub_ = dp->create_subscriber(SUBSCRIBER_QOS_DEFAULT, ::DDS::SubscriberListener::_nil(), ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (CORBA::is_nil (sub_.in ())) { ACE_ERROR ((LM_ERROR, ACE_TEXT("(%P|%t) create_subscriber failed.\n"))); throw TestException() ; } ::DDS::TopicDescription_var description = dp->lookup_topicdescription(MY_TOPIC); if (CORBA::is_nil (description.in ())) { ACE_ERROR ((LM_ERROR, ACE_TEXT("(%P|%t) lookup_topicdescription failed.\n"))); throw TestException() ; } ::DDS::DataReaderQos dr_qos; sub_->get_default_datareader_qos (dr_qos); dr_qos.history.depth = history_depth ; dr_qos.resource_limits.max_samples_per_instance = max_samples_per_instance ; dr_qos.liveliness.lease_duration.sec = static_cast<CORBA::Long> (max_blocking_time.sec ()); dr_qos.liveliness.lease_duration.nanosec = 0 ; ::DDS::DataReaderListener_var drl (new DataReaderListenerImpl); ::DDS::DataReader_var dr = sub_->create_datareader(description.in (), dr_qos, // ::DDS::DataReaderListener::_nil() drl.in (), ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (CORBA::is_nil (dr.in ())) { ACE_ERROR ((LM_ERROR, ACE_TEXT("(%P|%t) create_datareader failed.\n"))); throw TestException() ; } }
// Inserting a node void bstree::insert(int x,nodeptr &p) { if (p == NULL) { p = new node; p->element = x; p->left=NULL; p->right = NULL; p->height=0; if (p==NULL) cout<<"\nOut of Space"; } else { if (x<p->element) { insert(x,p->left); if ((bsheight(p->left) - bsheight(p->right))==2) { if (x < p->left->element) p=srl(p); else p = drl(p); } } else if (x>p->element) { insert(x,p->right); if ((bsheight(p->right) - bsheight(p->left))==2) { if (x > p->right->element) p=srr(p); else p = drr(p); } } else cout<<"\nElement Exists"; } int m,n,d; m=bsheight(p->left); n=bsheight(p->right); d=max(m,n); p->height = d + 1; }
void ResourceBuffer::update() { if ( m_isNativeBuffer) { return; } size_t bufferSize = m_buffer->getSize(); dp::sg::core::Buffer::DataReadLock drl( m_buffer ); assert( m_resourceManager ); assert( m_resourceManager->getRenderer() ); if( bufferSize != m_bufferSize ) { m_bufferSize = bufferSize; m_resourceManager->getRenderer()->bufferSetSize( m_bufferHandle, m_bufferSize ); } m_resourceManager->getRenderer()->bufferUpdateData( m_bufferHandle, 0, drl.getPtr(), bufferSize ); }
// Inserting a node void IntervallTree_bed::insert(long start, long stop, Leaf *&p) { if (p == NULL) { p = new Leaf(start, stop); if (p == NULL) { std::cout << "Out of Space\n" << std::endl; } } else { long score = p->overlap(start, stop); if (score > 0) { insert(start, stop, p->left); if ((bsheight(p->left) - bsheight(p->right)) == 2) { score = p->left->overlap(start, stop); if (score > 0) { p = srl(p); } else { p = drl(p); } } } else if (score < 0) { insert(start, stop, p->right); if ((bsheight(p->right) - bsheight(p->left)) == 2) { score = p->right->overlap(start, stop); if (score < 0) { p = srr(p); } else { p = drr(p); } } } else { //overlaps! std::cerr << "Two regions overlap and are thus ignored:" << std::endl; } } int m, n, d; m = bsheight(p->left); n = bsheight(p->right); d = max(m, n); p->set_height(d + 1); }
int main (int argc, char *argv[]) { int status = 0; try { ::DDS::DomainParticipantFactory_var dpf = TheParticipantFactoryWithArgs(argc, argv); // let the Service_Participant (in above line) strip out -DCPSxxx parameters // and then get application specific parameters. parse_args (argc, argv); ::Xyz::FooTypeSupport_var fts (new ::Xyz::FooTypeSupportImpl); ::DDS::DomainParticipant_var dp = dpf->create_participant(MY_DOMAIN, PARTICIPANT_QOS_DEFAULT, ::DDS::DomainParticipantListener::_nil()); if (CORBA::is_nil (dp.in ())) { ACE_ERROR ((LM_ERROR, ACE_TEXT("(%P|%t) create_participant failed.\n"))); return 1 ; } if (::DDS::RETCODE_OK != fts->register_type(dp.in (), MY_TYPE)) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Failed to register the FooTypeSupport."))); return 1; } ::DDS::TopicQos topic_qos; dp->get_default_topic_qos(topic_qos); ::DDS::Topic_var topic = dp->create_topic (MY_TOPIC, MY_TYPE, TOPIC_QOS_DEFAULT, ::DDS::TopicListener::_nil()); if (CORBA::is_nil (topic.in ())) { return 1 ; } ::DDS::TopicDescription_var description = dp->lookup_topicdescription(MY_TOPIC); if (CORBA::is_nil (description.in ())) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT("(%P|%t) lookup_topicdescription failed.\n")), 1); } // Create the subscriber ::DDS::Subscriber_var sub = dp->create_subscriber(SUBSCRIBER_QOS_DEFAULT, ::DDS::SubscriberListener::_nil()); if (CORBA::is_nil (sub.in ())) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT("(%P|%t) create_subscriber failed.\n")), 1); } // Initialize the transport OpenDDS::DCPS::TransportImpl_rch reader_transport_impl; if (0 != ::init_reader_tranport(reader_transport_impl) ) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT("(%P|%t) init_transport failed!\n")), 1); } // Attach the subscriber to the transport. OpenDDS::DCPS::SubscriberImpl* sub_impl = dynamic_cast<OpenDDS::DCPS::SubscriberImpl*> (sub.in ()); if (0 == sub_impl) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT("(%P|%t) Failed to obtain servant ::OpenDDS::DCPS::SubscriberImpl\n")), 1); } OpenDDS::DCPS::AttachStatus attach_status = sub_impl->attach_transport(reader_transport_impl.in()); if (attach_status != OpenDDS::DCPS::ATTACH_OK) { // We failed to attach to the transport for some reason. ACE_TString status_str; switch (attach_status) { case OpenDDS::DCPS::ATTACH_BAD_TRANSPORT: status_str = "ATTACH_BAD_TRANSPORT"; break; case OpenDDS::DCPS::ATTACH_ERROR: status_str = "ATTACH_ERROR"; break; case OpenDDS::DCPS::ATTACH_INCOMPATIBLE_QOS: status_str = "ATTACH_INCOMPATIBLE_QOS"; break; default: status_str = "Unknown Status"; break; } ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT("(%P|%t) Failed to attach to the transport. ") ACE_TEXT("AttachStatus == %s\n"), status_str.c_str()), 1); } // Create the Datareaders ::DDS::DataReaderQos dr_qos; sub->get_default_datareader_qos (dr_qos); dr_qos.liveliness.lease_duration.sec = LEASE_DURATION_SEC; dr_qos.liveliness.lease_duration.nanosec = 0; ::DDS::DataReaderListener_var drl (new DataReaderListenerImpl); DataReaderListenerImpl* drl_servant = dynamic_cast<DataReaderListenerImpl*>(drl.in()); ::DDS::DataReader_var dr ; dr = sub->create_datareader(description.in (), dr_qos, drl.in ()); ACE_OS::sleep(test_duration); // clean up subscriber objects sub->delete_contained_entities() ; dp->delete_subscriber(sub.in ()); dp->delete_topic(topic.in ()); dpf->delete_participant(dp.in ()); TheTransportFactory->release(); TheServiceParticipant->shutdown (); if (drl_servant->deadline_missed() < threshold_liveliness_lost) { ACE_ERROR ((LM_ERROR, ACE_TEXT("(%P|%t) The liviness deadline wasn't missed as many times as it should have." "threashold=%d, num missed=%d\n"), threshold_liveliness_lost, drl_servant->deadline_missed())); return 1; } } catch (const TestException&) { ACE_ERROR ((LM_ERROR, ACE_TEXT("(%P|%t) TestException caught in main.cpp. "))); return 1; } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught in main.cpp:"); return 1; } return status; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { int status = 0; try { ACE_DEBUG((LM_INFO,"(%P|%t) %T subscriber main\n")); ::DDS::DomainParticipantFactory_var dpf = TheParticipantFactoryWithArgs(argc, argv); // TheServiceParticipant->liveliness_factor(100) ; // let the Service_Participant (in above line) strip out -DCPSxxx parameters // and then get application specific parameters. parse_args (argc, argv); ::Xyz::FooTypeSupport_var fts (new ::Xyz::FooTypeSupportImpl); ::DDS::DomainParticipant_var dp = dpf->create_participant(MY_DOMAIN, PARTICIPANT_QOS_DEFAULT, ::DDS::DomainParticipantListener::_nil(), ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (CORBA::is_nil (dp.in ())) { ACE_ERROR ((LM_ERROR, ACE_TEXT("(%P|%t) create_participant failed.\n"))); return 1 ; } if (::DDS::RETCODE_OK != fts->register_type(dp.in (), MY_TYPE)) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Failed to register the FooTypeSupport."))); return 1; } ::DDS::TopicQos topic_qos; dp->get_default_topic_qos(topic_qos); topic_qos.resource_limits.max_samples_per_instance = max_samples_per_instance ; topic_qos.history.depth = history_depth; ::DDS::Topic_var topic = dp->create_topic (MY_TOPIC, MY_TYPE, topic_qos, ::DDS::TopicListener::_nil(), ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (CORBA::is_nil (topic.in ())) { return 1 ; } ::DDS::TopicDescription_var description = dp->lookup_topicdescription(MY_TOPIC); if (CORBA::is_nil (description.in ())) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT("(%P|%t) lookup_topicdescription failed.\n")), 1); } // Create the subscriber ::DDS::Subscriber_var sub = dp->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("(%P|%t) create_subscriber failed.\n")), 1); } // Create the Datareaders ::DDS::DataReaderQos dr_qos; sub->get_default_datareader_qos (dr_qos); dr_qos.history.depth = history_depth ; dr_qos.resource_limits.max_samples_per_instance = max_samples_per_instance ; dr_qos.liveliness.lease_duration.sec = LEASE_DURATION_SEC ; dr_qos.liveliness.lease_duration.nanosec = 0 ; ::DDS::DataReaderListener_var drl (new DataReaderListenerImpl); DataReaderListenerImpl* drl_servant = dynamic_cast<DataReaderListenerImpl*>(drl.in()); ::DDS::DataReader_var dr ; dr = sub->create_datareader(description.in (), dr_qos, drl.in (), ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); // Indicate that the subscriber is ready FILE* readers_ready = ACE_OS::fopen (sub_ready_filename.c_str (), ACE_TEXT("w")); if (readers_ready == 0) { ACE_ERROR ((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: Unable to create subscriber completed file\n"))); } ACE_DEBUG((LM_DEBUG,ACE_TEXT("(%P|%t) %T waiting for publisher to be ready\n") )); // 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.c_str (), ACE_TEXT("r")); } while (0 == writers_ready); ACE_OS::fclose(readers_ready); ACE_OS::fclose(writers_ready); ACE_DEBUG((LM_DEBUG,ACE_TEXT("(%P|%t) %T Publisher is ready\n") )); // Indicate that the subscriber is done // (((it is done when ever the publisher is done))) FILE* readers_completed = ACE_OS::fopen (sub_finished_filename.c_str (), ACE_TEXT("w")); if (readers_completed == 0) { ACE_ERROR ((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: Unable to create subscriber completed file\n"))); } ACE_DEBUG((LM_DEBUG,ACE_TEXT("(%P|%t) %T waiting for publisher to finish\n") )); // Wait for the publisher to finish FILE* writers_completed = 0; do { ACE_Time_Value small_time(0,250000); ACE_OS::sleep (small_time); writers_completed = ACE_OS::fopen (pub_finished_filename.c_str (), ACE_TEXT("r")); } while (0 == writers_completed); ACE_OS::fclose(readers_completed); ACE_OS::fclose(writers_completed); // // We need to wait for liveliness to go away here. // ACE_OS::sleep( 5); // // Determine the test status at this point. // ACE_OS::fprintf (stderr, "**********\n") ; ACE_OS::fprintf (stderr, "drl_servant->liveliness_changed_count() = %d\n", drl_servant->liveliness_changed_count()) ; ACE_OS::fprintf (stderr, "drl_servant->no_writers_generation_count() = %d\n", drl_servant->no_writers_generation_count()) ; ACE_OS::fprintf (stderr, "********** use_take=%d\n", use_take) ; if( drl_servant->liveliness_changed_count() < 2 + 2 * num_unlively_periods) { status = 1; // Some error condition. ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: subscriber - ") ACE_TEXT("test failed first condition.\n") )); } else if( drl_servant->verify_last_liveliness_status () == false) { status = 1; // Some other error condition. ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: subscriber - ") ACE_TEXT("test failed second condition.\n") )); } else if( drl_servant->no_writers_generation_count() != num_unlively_periods) { status = 1; // Yet another error condition. // Using take will remove the instance and instance state will be // reset for any subsequent samples sent. Since there are no // more samples sent, the information available from the listener // retains that from the last read sample rather than the reset // value for an (as yet unreceived) next sample. ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: subscriber - ") ACE_TEXT("test failed third condition.\n") )); } ACE_DEBUG((LM_DEBUG,ACE_TEXT("(%P|%t) %T publisher is finish - cleanup subscriber\n") )); // clean up subscriber objects sub->delete_contained_entities() ; dp->delete_subscriber(sub.in ()); dp->delete_topic(topic.in ()); dpf->delete_participant(dp.in ()); TheServiceParticipant->shutdown (); } catch (const TestException&) { ACE_ERROR ((LM_ERROR, ACE_TEXT("(%P|%t) TestException caught in main.cpp. "))); return 1; } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught in main.cpp:"); return 1; } return status; }
int ACE_TMAIN(int argc, ACE_TCHAR* argv[]) { int status = 0; try { ::DDS::DomainParticipantFactory_var dpf = TheParticipantFactoryWithArgs(argc, argv); // let the Service_Participant (in above line) strip out -DCPSxxx parameters // and then get application specific parameters. parse_args(argc, argv); ::Xyz::FooTypeSupport_var fts (new ::Xyz::FooTypeSupportImpl); ::DDS::DomainParticipant_var dp = dpf->create_participant(MY_DOMAIN, PARTICIPANT_QOS_DEFAULT, ::DDS::DomainParticipantListener::_nil(), ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (CORBA::is_nil (dp.in ())) { ACE_ERROR ((LM_ERROR, ACE_TEXT("(%P|%t) create_participant failed.\n"))); return 1 ; } if (::DDS::RETCODE_OK != fts->register_type(dp.in (), MY_TYPE)) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Failed to register the FooTypeSupport."))); return 1; } ::DDS::TopicQos topic_qos; dp->get_default_topic_qos(topic_qos); ::DDS::Topic_var topic = dp->create_topic (MY_TOPIC, MY_TYPE, TOPIC_QOS_DEFAULT, ::DDS::TopicListener::_nil(), ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (CORBA::is_nil (topic.in ())) { return 1 ; } ::DDS::TopicDescription_var description = dp->lookup_topicdescription(MY_TOPIC); if (CORBA::is_nil (description.in ())) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT("(%P|%t) lookup_topicdescription failed.\n")), 1); } // Create the subscriber ::DDS::Subscriber_var sub = dp->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("(%P|%t) create_subscriber failed.\n")), 1); } // Create the Datareaders ::DDS::DataReaderQos dr_qos; sub->get_default_datareader_qos (dr_qos); dr_qos.liveliness.lease_duration.sec = LEASE_DURATION_SEC; dr_qos.liveliness.lease_duration.nanosec = 0; ::DDS::DataReaderListener_var drl (new DataReaderListenerImpl); DataReaderListenerImpl* drl_servant = dynamic_cast<DataReaderListenerImpl*>(drl.in()); ::DDS::DataReader_var dr ; dr = sub->create_datareader(description.in (), dr_qos, drl.in (), ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); ACE_OS::sleep(test_duration); // clean up subscriber objects sub->delete_contained_entities() ; dp->delete_subscriber(sub.in ()); dp->delete_topic(topic.in ()); dpf->delete_participant(dp.in ()); TheServiceParticipant->shutdown (); if( drl_servant->deadline_missed() < threshold_liveliness_lost) { ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) subscriber: ") ACE_TEXT("liviness deadline not violated enough for test. ") ACE_TEXT("threshold( %d) < num missed( %d).\n"), threshold_liveliness_lost, drl_servant->deadline_missed() )); return 1; } else { ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) subscriber: ") ACE_TEXT("liviness deadline violated enough to pass test. ") ACE_TEXT("threshold( %d) < num missed( %d).\n"), threshold_liveliness_lost, drl_servant->deadline_missed() )); } } catch (const TestException&) { ACE_ERROR ((LM_ERROR, ACE_TEXT("(%P|%t) TestException caught in main.cpp. "))); return 1; } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught in main.cpp:"); return 1; } return status; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { int status = 0; try { ::DDS::DomainParticipantFactory_var dpf = TheParticipantFactoryWithArgs(argc, argv); // let the Service_Participant (in above line) strip out -DCPSxxx parameters // and then get application specific parameters. parse_args (argc, argv); ::Xyz::FooTypeSupport_var fts (new ::Xyz::FooTypeSupportImpl); ::DDS::DomainParticipant_var dp = dpf->create_participant(MY_DOMAIN, PARTICIPANT_QOS_DEFAULT, ::DDS::DomainParticipantListener::_nil(), ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (CORBA::is_nil (dp.in ())) { ACE_ERROR ((LM_ERROR, ACE_TEXT("(%P|%t) create_participant failed.\n"))); return 1 ; } if (::DDS::RETCODE_OK != fts->register_type(dp.in (), MY_TYPE)) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Failed to register the FooTypeSupport."))); return 1; } ::DDS::TopicQos topic_qos; dp->get_default_topic_qos(topic_qos); ::DDS::Topic_var topic = dp->create_topic (MY_TOPIC, MY_TYPE, TOPIC_QOS_DEFAULT, ::DDS::TopicListener::_nil(), ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (CORBA::is_nil (topic.in ())) { return 1 ; } ::DDS::TopicDescription_var description = dp->lookup_topicdescription(MY_TOPIC); if (CORBA::is_nil (description.in ())) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT("(%P|%t) lookup_topicdescription failed.\n")), 1); } // Create the subscriber ::DDS::Subscriber_var sub = dp->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("(%P|%t) create_subscriber failed.\n")), 1); } // Create the Datareaders ::DDS::DataReaderQos dr_qos; sub->get_default_datareader_qos (dr_qos); dr_qos.durability.kind = durability_kind; dr_qos.liveliness.kind = liveliness_kind; dr_qos.liveliness.lease_duration = LEASE_DURATION; dr_qos.reliability.kind = reliability_kind; ::DDS::DataReaderListener_var drl (new DataReaderListenerImpl); DataReaderListenerImpl* drl_servant = dynamic_cast<DataReaderListenerImpl*>(drl.in()); if (!drl_servant) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("%N:%l main()") ACE_TEXT(" ERROR: drl_servant is nil (dynamic_cast failed)!\n")), -1); } ::DDS::DataReader_var dr(sub->create_datareader(description.in (), dr_qos, drl.in (), ::OpenDDS::DCPS::DEFAULT_STATUS_MASK)); ACE_OS::sleep(test_duration); // clean up subscriber objects dp->delete_contained_entities() ; dpf->delete_participant(dp.in ()); TheServiceParticipant->shutdown (); // there is an error if we matched when not compatible (or vice-versa) if (drl_servant->subscription_matched() != compatible) { ACE_ERROR ((LM_ERROR, ACE_TEXT("(%P|%t) Expected subscription_matched to be %C, but it wasn't.") ACE_TEXT("durability_kind=%s,liveliness_kind=%s,liveliness_duration=%s,") ACE_TEXT("reliability_kind=%s\n"), (compatible) ? "true" : "false", durability_kind_str.c_str(), liveliness_kind_str.c_str(), LEASE_DURATION_STR.c_str(), reliability_kind_str.c_str())); return 1; } } catch (const TestException&) { ACE_ERROR ((LM_ERROR, ACE_TEXT("(%P|%t) TestException caught in main.cpp. "))); return 1; } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught in main.cpp:"); return 1; } catch (const std::exception& ex) { ACE_ERROR ((LM_ERROR, ACE_TEXT("(%P|%t) std::exception caught in main.cpp: %C\n"), ex.what())); return 1; } return status; }