本文整理汇总了C++中dds::DataReader_var::get_matched_publications方法的典型用法代码示例。如果您正苦于以下问题:C++ DataReader_var::get_matched_publications方法的具体用法?C++ DataReader_var::get_matched_publications怎么用?C++ DataReader_var::get_matched_publications使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dds::DataReader_var
的用法示例。
在下文中一共展示了DataReader_var::get_matched_publications方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: listener
int
ACE_TMAIN(int argc, ACE_TCHAR* argv[])
{
try {
DDS::DomainParticipantFactory_var dpf;
DDS::DomainParticipant_var participant;
dpf = TheParticipantFactoryWithArgs(argc, argv);
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 ;
}
MessageTypeSupportImpl* mts_servant = new MessageTypeSupportImpl;
if (DDS::RETCODE_OK != mts_servant->register_type(participant.in (),
"")) {
cerr << "Failed to register the MessageTypeTypeSupport." << endl;
exit(1);
}
CORBA::String_var type_name = mts_servant->get_type_name ();
DDS::TopicQos topic_qos;
participant->get_default_topic_qos(topic_qos);
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 << "Failed to create_topic." << endl;
exit(1);
}
// 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);
}
// activate the listener
DDS::DataReaderListener_var listener (new DataReaderListenerImpl);
if (CORBA::is_nil (listener.in ())) {
cerr << "listener is nil." << endl;
exit(1);
}
DataReaderListenerImpl* listener_servant =
dynamic_cast<DataReaderListenerImpl*>(listener.in());
// 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,
listener.in (),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (dr.in ())) {
cerr << "create_datareader failed." << endl;
exit(1);
}
while ( ! listener_servant->received_all ()) {
ACE_OS::sleep (1);
}
if (! listener_servant->passed ()) {
cerr << "test failed - see errors." << endl;
return 1;
}
if (!CORBA::is_nil (participant.in ())) {
participant->delete_contained_entities();
}
if (!CORBA::is_nil (dpf.in ())) {
dpf->delete_participant(participant.in ());
}
::DDS::InstanceHandleSeq handles;
while (1)
{
ACE_OS::sleep(1);
dr->get_matched_publications(handles);
if (handles.length() == 0)
break;
}
//.........这里部分代码省略.........
示例2: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
DDS::DomainParticipantFactory_var dpf;
DDS::DomainParticipant_var participant;
dpf = TheParticipantFactoryWithArgs(argc, argv);
if( parse_args(argc, argv) != 0)
return 1;
participant =
dpf->create_participant(411,
PARTICIPANT_QOS_DEFAULT,
DDS::DomainParticipantListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (participant.in ())) {
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) create_participant failed.\n")
, -1);
}
MessageTypeSupportImpl* mts_servant = new MessageTypeSupportImpl;
if (DDS::RETCODE_OK != mts_servant->register_type(participant.in (),
"")) {
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) Failed to register the MessageTypeTypeSupport.\n")
, -1);
}
CORBA::String_var type_name = mts_servant->get_type_name ();
DDS::TopicQos topic_qos;
participant->get_default_topic_qos(topic_qos);
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 ())) {
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) Failed to create_topic.\n")
, -1);
}
// Indicate that the subscriber is about to become ready
FILE* readers_ready = ACE_OS::fopen (sub_ready_filename, ACE_TEXT("w"));
if (readers_ready == 0) {
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) ERROR: Unable to create subscriber ready file.\n")
, -1);
}
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);
//.........这里部分代码省略.........
示例3: main
//.........这里部分代码省略.........
ACE_ERROR ((LM_ERROR,
ACE_TEXT("(%P|%t) ::main: ")
ACE_TEXT("Failed to configure the transport.\n")));
exit(1);
}
// jhoffert - End of transport configuration changes
// 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) {
cerr << "Failed to obtain subscriber servant\n" << endl;
exit(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;
}
cerr << "Failed to attach to the transport. Status == "
<< status_str.c_str() << endl;
exit(1);
}
// activate the listener
DataReaderListenerImpl listener_servant;
PortableServer::POA_var poa = TheServiceParticipant->the_poa ();
CORBA::Object_var obj = poa->servant_to_reference(&listener_servant);
DDS::DataReaderListener_var listener =
DDS::DataReaderListener::_narrow (obj.in ());
if (CORBA::is_nil (listener.in ())) {
cerr << "listener is nil." << endl;
exit(1);
}
// To Do: Get default data reader QoS and create the data reader.
DDS::DataReaderQos dr_qos;
sub->get_default_datareader_qos (dr_qos);
DDS::DataReader_var dr = sub->create_datareader(topic.in (),
dr_qos,
listener.in ());
if (CORBA::is_nil (dr.in ())) {
cerr << "create_datareader failed." << endl;
exit(1);
}
// End: Get default data reader QoS and create the data reader.
// To Do: Set up the constraints for when the subscriber is done
// receiving updates.
int expected = 10;
while ( listener_servant.num_reads() < expected) {
ACE_OS::sleep (1);
}
// End: Set up the constraints for how long the subscriber should
// receive updates.
// To Do: Delete the participant's contained entities
if (!CORBA::is_nil (participant.in ())) {
participant->delete_contained_entities();
}
// End: Delete the participant's contained entities
if (!CORBA::is_nil (dpf.in ())) {
dpf->delete_participant(participant.in ());
}
::DDS::InstanceHandleSeq handles;
while (1)
{
ACE_OS::sleep(1);
dr->get_matched_publications(handles);
if (handles.length() == 0)
break;
}
ACE_OS::sleep(2);
TheTransportFactory->release();
TheServiceParticipant->shutdown ();
} catch (CORBA::Exception& e) {
cerr << "Exception caught in main ():" << endl << e << endl;
return 1;
}
return 0;
}