本文整理汇总了C++中dds::DataReader_var::enable方法的典型用法代码示例。如果您正苦于以下问题:C++ DataReader_var::enable方法的具体用法?C++ DataReader_var::enable怎么用?C++ DataReader_var::enable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dds::DataReader_var
的用法示例。
在下文中一共展示了DataReader_var::enable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ACE_TMAIN
int ACE_TMAIN(int argc, ACE_TCHAR** argv)
{
try {
OpenDDS::Model::Application application(argc, argv);
SubQos::DefaultSubQosType model(application, argc, argv);
using OpenDDS::Model::SubQos::Elements;
DDS::DataReader_var reader = model.reader( Elements::DataReaders::reader);
DDS::Subscriber_var subscriber = reader->get_subscriber();
ACE_SYNCH_MUTEX lock;
ACE_Condition<ACE_SYNCH_MUTEX> condition(lock);
OpenDDS::Model::ReaderCondSync rcs(reader, condition);
DDS::DataReaderListener_var listener(new ReaderListener(rcs));
reader->set_listener( listener.in(), OpenDDS::DCPS::DEFAULT_STATUS_MASK);
// Call on_data_available in case there are samples which are waiting
listener->on_data_available(reader);
// START OF EXISTING MESSENGER EXAMPLE CODE
MessageDataReader_var reader_i =
MessageDataReader::_narrow(reader);
if (CORBA::is_nil(reader_i.in())) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: main() -")
ACE_TEXT(" _narrow failed!\n")),
-1);
}
DDS::SubscriberQos sub_qos;
if (subscriber->get_qos(sub_qos) != 0) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) ERROR: %N:%l: main() -")
ACE_TEXT(" get_qos failed!\n")),
-1);
}
// was set to false for Sub
if (sub_qos.entity_factory.autoenable_created_entities) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) ERROR: %N:%l: main() -")
ACE_TEXT(" subscriber has wrong autoenable value!\n")),
-1);
} else {
if (subscriber->enable() != DDS::RETCODE_OK) {
std::cout << "bad return code enabling subscriber" << std::endl;
}
if (reader->enable() != DDS::RETCODE_OK) {
std::cout << "bad return code enabling reader" << std::endl;
}
}
char* buff = reinterpret_cast<char*>(sub_qos.group_data.value.get_buffer());
std::cout << "Group data is:" << buff << std::endl;
if (strcmp(buff, "eight is 8") != 0) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) ERROR: %N:%l: main() -")
ACE_TEXT(" subscriber has wrong group_data value\n")),
-1);
}
if (sub_qos.partition.name.length() != 1) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) ERROR: %N:%l: main() -")
ACE_TEXT(" subscriber has wrong # of partitions\n")),
-1);
}
if (strcmp(sub_qos.partition.name[0], "*") != 0) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) ERROR: %N:%l: main() -")
ACE_TEXT(" subscriber has wrong partition value\n")),
-1);
}
if (sub_qos.presentation.access_scope != DDS::TOPIC_PRESENTATION_QOS) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) ERROR: %N:%l: main() -")
ACE_TEXT(" subscriber has wrong access scope\n")),
-1);
}
if (sub_qos.presentation.coherent_access != true) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) ERROR: %N:%l: main() -")
ACE_TEXT(" subscriber has wrong choerent access\n")),
-1);
}
if (sub_qos.presentation.ordered_access != true) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%P|%t) ERROR: %N:%l: main() -")
ACE_TEXT(" subscriber has wrong ordered access\n")),
-1);
}
OpenDDS::Model::ReaderSync rs(reader);
//.........这里部分代码省略.........
示例2: 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);
}
//.........这里部分代码省略.........