本文整理汇总了C++中dds::Subscriber_var::lookup_datareader方法的典型用法代码示例。如果您正苦于以下问题:C++ Subscriber_var::lookup_datareader方法的具体用法?C++ Subscriber_var::lookup_datareader怎么用?C++ Subscriber_var::lookup_datareader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dds::Subscriber_var
的用法示例。
在下文中一共展示了Subscriber_var::lookup_datareader方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ACE_TMAIN
int ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
int result = 0;
ACE_DEBUG ((LM_DEBUG, "(%P|%t) subscriber main\n"));
try
{
DDS::DomainParticipantFactory_var dpf;
DDS::DomainParticipant_var participant;
dpf = TheParticipantFactoryWithArgs(argc, argv);
if (parse_args (argc, argv) == -1) {
return -1;
}
DDS::DomainParticipantQos partQos;
dpf->get_default_participant_qos(partQos);
// set up user data in DP qos
CORBA::ULong part_user_data_len
= static_cast<CORBA::ULong>(ACE_OS::strlen (PART_USER_DATA));
partQos.user_data.value.length (part_user_data_len);
partQos.user_data.value.replace (part_user_data_len,
part_user_data_len,
reinterpret_cast<CORBA::Octet*>(PART_USER_DATA));
participant = dpf->create_participant(411,
partQos,
DDS::DomainParticipantListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (participant.in ())) {
cerr << "subscriber: create_participant failed." << endl;
return 1 ;
}
::Messenger::MessageTypeSupport_var mts = new ::Messenger::MessageTypeSupportImpl();
if (DDS::RETCODE_OK != mts->register_type(participant.in (), "Messenger")) {
cerr << "subscriber: Failed to register the MessageTypeTypeSupport." << endl;
exit(1);
}
CORBA::String_var type_name = mts->get_type_name ();
DDS::TopicQos topic_qos;
participant->get_default_topic_qos(topic_qos);
// set up topic data in topic qos
CORBA::ULong topic_data_len = static_cast<CORBA::ULong>(ACE_OS::strlen (TOPIC_DATA));
topic_qos.topic_data.value.length (topic_data_len);
topic_qos.topic_data.value.replace (topic_data_len, topic_data_len, reinterpret_cast<CORBA::Octet*>(TOPIC_DATA));
DDS::Topic_var topic = participant->create_topic("Movie Discussion List",
type_name.in (),
topic_qos,
DDS::TopicListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (topic.in ())) {
cerr << "subscriber: Failed to create_topic." << endl;
exit(1);
}
// Create the subscriber
DDS::SubscriberQos sub_qos;
participant->get_default_subscriber_qos (sub_qos);
// set up group data in subscriber qos
CORBA::ULong group_data_len = static_cast<CORBA::ULong> (ACE_OS::strlen (GROUP_DATA));
sub_qos.group_data.value.length (group_data_len);
sub_qos.group_data.value.replace (group_data_len, group_data_len, reinterpret_cast<CORBA::Octet*>(GROUP_DATA));
DDS::Subscriber_var sub =
participant->create_subscriber(sub_qos,
DDS::SubscriberListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (sub.in ())) {
cerr << "subscriber: Failed to create_subscriber." << endl;
exit(1);
}
// activate the listener
DDS::DataReaderListener_var listener (new DataReaderListenerImpl);
DataReaderListenerImpl* listener_servant =
dynamic_cast<DataReaderListenerImpl*>(listener.in());
DDS::Subscriber_var builtin = participant->get_builtin_subscriber();
DDS::DataReader_var bitdr =
builtin->lookup_datareader(OpenDDS::DCPS::BUILT_IN_PUBLICATION_TOPIC);
listener_servant->set_builtin_datareader(bitdr.in());
if (CORBA::is_nil (listener.in ())) {
cerr << "subscriber: listener is nil." << endl;
exit(1);
}
// Create the Datareaders
DDS::DataReaderQos dr_qos;
sub->get_default_datareader_qos (dr_qos);
//.........这里部分代码省略.........