本文整理汇总了C++中dds::Subscriber_var::delete_datareader方法的典型用法代码示例。如果您正苦于以下问题:C++ Subscriber_var::delete_datareader方法的具体用法?C++ Subscriber_var::delete_datareader怎么用?C++ Subscriber_var::delete_datareader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dds::Subscriber_var
的用法示例。
在下文中一共展示了Subscriber_var::delete_datareader方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cleanup
void MultiTopicDataReaderBase::cleanup()
{
DDS::Subscriber_var sub = resulting_reader_->get_subscriber();
for (std::map<std::string, QueryPlan>::iterator it = query_plans_.begin();
it != query_plans_.end(); ++it) {
sub->delete_datareader(it->second.data_reader_);
}
DataReaderImpl* dri = dynamic_cast<DataReaderImpl*>(resulting_reader_.in());
SubscriberImpl* si = dynamic_cast<SubscriberImpl*>(sub.in());
si->remove_from_datareader_set(dri);
dri->cleanup();
}
示例2: ACE_TMAIN
//.........这里部分代码省略.........
ACE_OS::fclose(readers_ready);
// Check if the publisher is up and running
ACE_stat stats;
while (ACE_OS::stat (pub_ready_filename, &stats) == -1)
{
ACE_Time_Value small_time(0,250000);
ACE_OS::sleep (small_time);
}
for (int count = 1; count <= sub_reinit_itr; count++)
{
if (verbose) {
ACE_DEBUG ((LM_DEBUG, "(%P|%t) Reinitializing subscriber.\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 ())) {
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) Failed to create_subscriber.\n")
, -1);
}
// 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,
DDS::DataReaderListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (dr.in ())) {
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) create_datareader failed.\n")
, -1);
}
// This is where a speed-bump should be.
while (true)
{
::DDS::InstanceHandleSeq handles;
dr->get_matched_publications (handles);
if (handles.length() > 0) {
break;
}
ACE_Time_Value small_time (0,250000);
ACE_OS::sleep (small_time);
}
// Add sleep to let the fully_associted message arrive datawriter
// before remove_associations is called upon delete_datareader,
// otherwise the datawriter will encounter bit lookup timeout upon
// fully associated.
ACE_Time_Value small_time (0,250000);
ACE_OS::sleep (small_time);
if (verbose) {
ACE_DEBUG ((LM_DEBUG, "(%P|%t) *** Destroying Subscriber\n"));
}
// Delete data reader
sub->delete_datareader(dr.in());
// Delete subscriber
participant->delete_subscriber(sub.in());
dr = DDS::DataReader::_nil ();
sub = DDS::Subscriber::_nil();
}
if (!CORBA::is_nil (participant.in ())) {
participant->delete_contained_entities();
}
if (!CORBA::is_nil (dpf.in ())) {
dpf->delete_participant(participant.in ());
}
TheServiceParticipant->shutdown ();
// Indicate that the subscriber is done
FILE* readers_completed = ACE_OS::fopen (sub_finished_filename, ACE_TEXT("w"));
if (readers_completed == 0) {
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) ERROR: Unable to create subscriber completed file.\n")
, -1);
}
ACE_OS::fclose(readers_completed);
}
catch (CORBA::Exception& e) {
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) Exception caught in main (): %C (%C).\n"
, e._name (), e._rep_id ())
, -1);
}
return 0;
}
示例3: do_reader
int do_reader(DDS::DomainParticipant_var participant, DDS::Topic_var topic, bool toggle)
{
// 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: do_reader() -")
ACE_TEXT(" create_subscriber failed!\n")), -1);
}
DDS::DataReaderQos qos;
subscriber->get_default_datareader_qos(qos);
qos.user_data.value.length(3);
qos.user_data.value[0] = 0;
qos.user_data.value[1] = 0;
qos.user_data.value[2] = 0;
qos.reliability.kind = DDS::RELIABLE_RELIABILITY_QOS;
if (toggle) {
ACE_DEBUG((LM_DEBUG, "Creating reader\n"));
DDS::DataReader_var reader =
subscriber->create_datareader(topic,
qos,
0,
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (!reader) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: do_reader() -")
ACE_TEXT(" create_datareader failed!\n")), -1);
}
ACE_OS::sleep(SLEEP_SHORT);
// Go away.
ACE_DEBUG((LM_DEBUG, "Deleting reader\n"));
subscriber->delete_datareader(reader);
ACE_OS::sleep(SLEEP_SHORT);
// Come back.
ACE_DEBUG((LM_DEBUG, "Creating reader\n"));
reader = subscriber->create_datareader(topic,
qos,
0,
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
ACE_OS::sleep(SLEEP_SHORT);
return 0;
} else {
struct Listener : public DDS::DataReaderListener {
size_t found, lost;
Listener() : found(0), lost(0) { }
virtual void
on_requested_deadline_missed (::DDS::DataReader_ptr,
const ::DDS::RequestedDeadlineMissedStatus &) { }
virtual void
on_requested_incompatible_qos (::DDS::DataReader_ptr,
const ::DDS::RequestedIncompatibleQosStatus &) { }
virtual void
on_sample_rejected (::DDS::DataReader_ptr,
const ::DDS::SampleRejectedStatus &) { }
virtual void
on_liveliness_changed (::DDS::DataReader_ptr,
const ::DDS::LivelinessChangedStatus &) { }
virtual void
on_data_available (::DDS::DataReader_ptr) { }
virtual void
on_subscription_matched (::DDS::DataReader_ptr,
const ::DDS::SubscriptionMatchedStatus & status) {
if (status.current_count_change > 0) {
ACE_DEBUG((LM_DEBUG, "Reader found writer\n"));
++found;
}
if (status.current_count_change < 0) {
ACE_DEBUG((LM_DEBUG, "Reader lost writer\n"));
++lost;
}
}
virtual void
on_sample_lost (::DDS::DataReader_ptr,
const ::DDS::SampleLostStatus &) { }
} listener;
// Create DataReader
DDS::DataReader_var reader =
subscriber->create_datareader(topic,
qos,
&listener,
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (!reader) {
//.........这里部分代码省略.........
示例4: 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;
}
示例5: main
//.........这里部分代码省略.........
DDS::SubscriberListener::_nil());
if (CORBA::is_nil (sub.in ())) {
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) Failed to create_subscriber.\n")
, -1);
}
// Attach the subscriber to the transport.
TAO::DCPS::SubscriberImpl* sub_impl =
::TAO::DCPS::reference_to_servant
< TAO::DCPS::SubscriberImpl, DDS::Subscriber_ptr> (sub.in ());
if (0 == sub_impl) {
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) Failed to obtain subscriber servant.\n")
, -1);
}
TAO::DCPS::AttachStatus status = sub_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;
}
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) Failed to attach to the transport. "
"Status == %s.\n"
, status_str.c_str())
, -1);
}
// 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,
DDS::DataReaderListener::_nil());
if (CORBA::is_nil (dr.in ())) {
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) create_datareader failed.\n")
, -1);
}
{
ACE_OS::sleep (2);
// This is where a speed-bump should be.
}
if (verbose) {
ACE_DEBUG ((LM_DEBUG, "(%P|%t) *** Destroying Subscriber\n"));
}
// Delete data reader
sub->delete_datareader(dr.in());
// Delete subscriber
participant->delete_subscriber(sub.in());
sub = DDS::Subscriber::_nil();
}
if (!CORBA::is_nil (participant.in ())) {
participant->delete_contained_entities();
}
if (!CORBA::is_nil (dpf.in ())) {
dpf->delete_participant(participant.in ());
}
TheTransportFactory->release();
TheServiceParticipant->shutdown ();
// Indicate that the subscriber is done
FILE* readers_completed = ACE_OS::fopen (sub_finished_filename, "w");
if (readers_completed == 0) {
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) ERROR Unable to create subscriber completed file.\n")
, -1);
}
ACE_OS::fclose(readers_completed);
}
catch (CORBA::Exception& e) {
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) Exception caught in main (): %s (%s).\n"
, e._name (), e._rep_id ())
, -1);
}
return 0;
}