本文整理汇总了C++中dds::Publisher_var::delete_datawriter方法的典型用法代码示例。如果您正苦于以下问题:C++ Publisher_var::delete_datawriter方法的具体用法?C++ Publisher_var::delete_datawriter怎么用?C++ Publisher_var::delete_datawriter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dds::Publisher_var
的用法示例。
在下文中一共展示了Publisher_var::delete_datawriter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: delay_between_pubs
//.........这里部分代码省略.........
writer_qos.history.depth = samples_per_thread_;
if (deadline_.sec > 0 || deadline_.nanosec > 0)
{
writer_qos.deadline.period.sec = deadline_.sec;
writer_qos.deadline.period.nanosec = deadline_.nanosec;
}
DDS::DataWriter_var 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);
FooDataWriter_var 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
DDS::StatusCondition_var cond = writer->get_statuscondition();
cond->set_enabled_statuses(DDS::PUBLICATION_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::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;
ACE_OS::sleep(delay_between_pubs);
}
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);
}
publisher->delete_datawriter(writer);
// Clean-up!
participant->delete_contained_entities();
dpf->delete_participant(participant.in());
}
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: do_writer
int do_writer(DDS::DomainParticipant_var participant, DDS::Topic_var topic, bool toggle)
{
// Create Publisher
DDS::Publisher_var publisher =
participant->create_publisher(PUBLISHER_QOS_DEFAULT,
0,
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (!publisher) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: do_writer() -")
ACE_TEXT(" create_publisher failed!\n")),
-1);
}
DDS::DataWriterQos qos;
publisher->get_default_datawriter_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] = 1;
qos.reliability.kind = DDS::RELIABLE_RELIABILITY_QOS;
if (toggle) {
ACE_DEBUG((LM_DEBUG, "Creating writer\n"));
DDS::DataWriter_var writer =
publisher->create_datawriter(topic,
qos,
0,
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (!writer) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: do_writer() -")
ACE_TEXT(" create_datawriter failed!\n")), -1);
}
ACE_OS::sleep(SLEEP_SHORT);
// Go away.
ACE_DEBUG((LM_DEBUG, "Deleting writer\n"));
publisher->delete_datawriter(writer);
ACE_OS::sleep(SLEEP_SHORT);
// Come back.
ACE_DEBUG((LM_DEBUG, "Creating writer\n"));
writer = publisher->create_datawriter(topic,
qos,
0,
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
ACE_OS::sleep(SLEEP_SHORT);
return 0;
} else {
struct Listener : public DDS::DataWriterListener {
size_t found, lost;
Listener() : found(0), lost(0) { }
virtual void
on_offered_deadline_missed (::DDS::DataWriter_ptr,
const ::DDS::OfferedDeadlineMissedStatus &) { }
virtual void
on_offered_incompatible_qos (::DDS::DataWriter_ptr,
const ::DDS::OfferedIncompatibleQosStatus &) { }
virtual void
on_liveliness_lost (::DDS::DataWriter_ptr,
const ::DDS::LivelinessLostStatus &) { }
virtual void
on_publication_matched (::DDS::DataWriter_ptr,
const ::DDS::PublicationMatchedStatus & status) {
if (status.current_count_change > 0) {
ACE_DEBUG((LM_DEBUG, "Writer found reader\n"));
++found;
}
if (status.current_count_change < 0) {
ACE_DEBUG((LM_DEBUG, "Writer lost reader\n"));
++lost;
}
}
} listener;
// Create DataWriter
DDS::DataWriter_var writer =
publisher->create_datawriter(topic,
qos,
&listener,
OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (!writer) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: do_writer() -")
ACE_TEXT(" create_datawriter failed!\n")),
-1);
}
ACE_OS::sleep(SLEEP_LONG);
if (listener.found == 2 && listener.lost == 1) {
//.........这里部分代码省略.........
示例3: ACE_TMAIN
//.........这里部分代码省略.........
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: create_publisher failed!\n")),
-1);
}
// Create 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())) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: create_datawriter failed!\n")),
-1);
}
DDS::ReturnCode_t retcode = participant2->delete_topic (topic.in ());
if (retcode != DDS::RETCODE_PRECONDITION_NOT_MET) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: should not be able to delete topic, not part of this participant!\n")),
-1);
}
DDS::ReturnCode_t retcode5 = participant->delete_topic (topic.in ());
if (retcode5 != DDS::RETCODE_PRECONDITION_NOT_MET) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: should not be able to delete topic, still referenced by datawriter!\n")),
-1);
}
DDS::ReturnCode_t retcode2 = pub->delete_datawriter (dw.in ());
if (retcode2 != DDS::RETCODE_OK) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: should be able to delete datawriter\n")),
-1);
}
dw = DDS::DataWriter::_nil ();
DDS::Duration_t timeout;
timeout.sec = 0;
timeout.nanosec = 0;
// Doing a find_topic will require us to call delete topic twice, see
// 7.1.2.2.1.11 from the dds spec
DDS::Topic_var topic2 = participant->find_topic ("Movie Discussion List", timeout);
if (CORBA::is_nil (topic2.in ())) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: Not able to find topic\n")),
-1);
}
DDS::ReturnCode_t retcode4 = participant->delete_topic (topic.in ());
if (retcode4 != DDS::RETCODE_OK) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: should be able to delete topic\n")),
-1);
}
topic = DDS::Topic::_nil ();
DDS::ReturnCode_t retcode6 = participant->delete_topic (topic2.in ());
if (retcode6 != DDS::RETCODE_OK) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: should be able to delete topic\n")),
-1);
}
topic2 = DDS::Topic::_nil ();
DDS::ReturnCode_t retcode8 = participant->delete_publisher (pub.in ());
if (retcode8 != DDS::RETCODE_OK) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: should be able to delete publisher\n")),
-1);
}
pub = DDS::Publisher::_nil ();
dpf->delete_participant(participant.in ());
participant = DDS::DomainParticipant::_nil ();
dpf->delete_participant(participant2.in ());
participant2 = DDS::DomainParticipant::_nil ();
TheServiceParticipant->shutdown ();
}
catch (CORBA::Exception& e)
{
cerr << "dp: Exception caught in main.cpp:" << endl
<< e << endl;
exit(1);
}
return 0;
}
示例4: TheParticipantFactoryWithArgs
//.........这里部分代码省略.........
// Create a DataWriter.
// Upon exiting this scope, all unsent data should be
// transferred to OpenDDS's data durability cache since the
// run_test.pl script should not have started the subscriber
// until it detects the "Done writing" log text.
DDS::DataWriter_var dw =
pub->create_datawriter (topic.in (),
dw_qos,
dwl.in (),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (dw.in ()))
{
cerr << "create_datawriter failed." << endl;
exit (1);
}
// Only write samples if configured to do so. The expectation
// is to otherwise retrieve the data from the PERSISTENT data
// durability cache.
if (do_write)
{
// Write samples.
std::auto_ptr<Writer> writer (new Writer (dw.in ()));
if (!writer->start () || !writer->end ())
{
// Error logging performed in above method call.
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
示例5: ACE_TMAIN
//.........这里部分代码省略.........
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 Publisher
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_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: create_publisher failed!\n")),
-1);
}
// Create 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())) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: create_datawriter failed!\n")),
-1);
}
DDS::ReturnCode_t retcode2 = pub->delete_datawriter (dw.in ());
if (retcode2 != DDS::RETCODE_OK) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: should be able to delete datawriter\n")),
-1);
}
DDS::ReturnCode_t retcode5 = dpf->delete_participant(participant.in ());
if (retcode5 != DDS::RETCODE_PRECONDITION_NOT_MET) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: should not be able to delete participant\n")),
-1);
}
DDS::ReturnCode_t retcode3 = participant->delete_publisher (pub.in ());
if (retcode3 != DDS::RETCODE_OK) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: should be able to delete publisher\n")),
-1);
}
DDS::ReturnCode_t retcode4 = participant->delete_topic (topic.in ());
if (retcode4 != DDS::RETCODE_OK) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: should be able to delete topic\n")),
-1);
}
DDS::ReturnCode_t retcode6 = dpf->delete_participant(participant.in ());
if (retcode6 != DDS::RETCODE_OK) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%N:%l: main()")
ACE_TEXT(" ERROR: should be able to delete participant\n")),
-1);
}
// DDS::ReturnCode_t retcode7 = dpf->delete_participant(participant2.in ());
// if (retcode7 != DDS::RETCODE_OK) {
// ACE_ERROR_RETURN((LM_ERROR,
// ACE_TEXT("%N:%l: main()")
// ACE_TEXT(" ERROR: should be able to delete participant2\n")),
// -1);
// }
ACE_DEBUG ((LM_DEBUG, "Shutting down the service participant with one participant still registered\n"));
TheServiceParticipant->shutdown ();
}
catch (CORBA::Exception& e)
{
cerr << "dp: Exception caught in main.cpp:" << endl
<< e << endl;
exit(1);
}
return 0;
}