本文整理汇总了C++中dds::Topic_var::enable方法的典型用法代码示例。如果您正苦于以下问题:C++ Topic_var::enable方法的具体用法?C++ Topic_var::enable怎么用?C++ Topic_var::enable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dds::Topic_var
的用法示例。
在下文中一共展示了Topic_var::enable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
DDS::DomainParticipantFactory_var dpf;
DDS::DomainParticipant_var participant;
dpf = TheParticipantFactoryWithArgs(argc, argv);
// Default DomainParticipantFactory qos is to auto enable.
::DDS::DomainParticipantFactoryQos fqos;
if (dpf->get_qos (fqos) != ::DDS::RETCODE_OK)
{
cerr << "DomainParticipantFactory get_qos failed." << endl;
return 1;
}
if (fqos.entity_factory.autoenable_created_entities == 0)
{
cerr << "The DomainParticipantFactory defaults to autoenable upon entities creation." << endl;
return 1;
}
// Now disable DomainParticipantFactory autoenable
fqos.entity_factory.autoenable_created_entities = 0;
if (dpf->set_qos (fqos) != ::DDS::RETCODE_OK)
{
cerr << "DomainParticipantFactory set_qos failed." << endl;
return 1;
}
participant = dpf->create_participant(411,
PARTICIPANT_QOS_DEFAULT,
DDS::DomainParticipantListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (participant.in ())) {
cerr << "create_participant failed." << endl;
return 1 ;
}
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 << "Failed to register the MessageTypeTypeSupport." << 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 << "Failed to create_topic." << 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;
}
// Initialize the transport
OpenDDS::DCPS::TransportImpl_rch transport_impl =
TheTransportFactory->create_transport_impl (transport_impl_id,
::OpenDDS::DCPS::AUTO_CONFIG);
// 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 (sub->enable () != ::DDS::RETCODE_PRECONDITION_NOT_MET)
{
cerr << "Publisher can not be enabled because DomainParticipant is not enabled." << endl;
return 1;
}
// Attach the subscriber to the transport.
OpenDDS::DCPS::SubscriberImpl* sub_impl =
dynamic_cast<OpenDDS::DCPS::SubscriberImpl*> (sub.in ());
if (0 == sub_impl) {
cerr << "Failed to obtain subscriber servant\n" << endl;
exit(1);
}
//.........这里部分代码省略.........
示例2: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) {
try
{
DDS::DomainParticipantFactory_var dpf =
TheParticipantFactoryWithArgs(argc, argv);
// Default DomainParticipantFactory qos is to auto enable.
::DDS::DomainParticipantFactoryQos fqos;
if (dpf->get_qos (fqos) != ::DDS::RETCODE_OK)
{
cerr << "DomainParticipantFactory get_qos failed." << endl;
return 1;
}
if (fqos.entity_factory.autoenable_created_entities == 0)
{
cerr << "The DomainParticipantFactory defaults to autoenable upon entities creation." << endl;
return 1;
}
// Now disable DomainParticipantFactory autoenable
fqos.entity_factory.autoenable_created_entities = 0;
if (dpf->set_qos (fqos) != ::DDS::RETCODE_OK)
{
cerr << "DomainParticipantFactory set_qos failed." << endl;
return 1;
}
DDS::DomainParticipant_var participant =
dpf->create_participant(411,
PARTICIPANT_QOS_DEFAULT,
DDS::DomainParticipantListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (participant.in ())) {
cerr << "create_participant failed." << endl;
return 1;
}
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;
//.........这里部分代码省略.........