| 112 | // END OF EXISTING MESSENGER EXAMPLE LISTENER CODE |
| 113 | |
| 114 | int ACE_TMAIN(int argc, ACE_TCHAR** argv) |
| 115 | { |
| 116 | try { |
| 117 | std::cout << "sub running" << std::endl; |
| 118 | OpenDDS::Model::Application application(argc, argv); |
| 119 | RemoteInstHandlesLib::DefaultRemoteInstHandlesType model(application, argc, argv); |
| 120 | |
| 121 | using OpenDDS::Model::RemoteInstHandlesLib::Elements; |
| 122 | |
| 123 | DDS::DataReader_var reader = model.reader(Elements::DataReaders::reader); |
| 124 | DDS::DataReaderListener_var bit_listener(new BitSubscriptionListener()); |
| 125 | DDS::Subscriber_var subscriber = reader->get_subscriber(); |
| 126 | DDS::DomainParticipant_var reader_part = subscriber->get_participant(); |
| 127 | |
| 128 | DDS::Subscriber_var bit_sub(reader_part->get_builtin_subscriber()); |
| 129 | DDS::DataReader_var bit_dr(bit_sub->lookup_datareader(OpenDDS::DCPS::BUILT_IN_SUBSCRIPTION_TOPIC)); |
| 130 | bit_dr->set_listener(bit_listener.in(), OpenDDS::DCPS::DEFAULT_STATUS_MASK); |
| 131 | std::cout << "sub calling synthetic oda" << std::endl; |
| 132 | if (bit_dr->enable() != DDS::RETCODE_OK) { |
| 133 | std::cout << "bit enable failure" << std::endl; |
| 134 | } |
| 135 | bit_listener->on_data_available(bit_dr); |
| 136 | |
| 137 | ACE_SYNCH_MUTEX lock; |
| 138 | ACE_Condition<ACE_SYNCH_MUTEX> condition(lock); |
| 139 | OpenDDS::Model::ReaderCondSync rcs(reader, |
| 140 | condition); |
| 141 | DDS::DataReaderListener_var listener(new ReaderListener(rcs)); |
| 142 | reader->set_listener( listener.in(), OpenDDS::DCPS::DEFAULT_STATUS_MASK); |
| 143 | |
| 144 | // Call on_data_available in case there are samples which are waiting |
| 145 | if (reader->enable() != DDS::RETCODE_OK) { |
| 146 | std::cout << "reader enable failure" << std::endl; |
| 147 | } |
| 148 | listener->on_data_available(reader); |
| 149 | |
| 150 | // START OF EXISTING MESSENGER EXAMPLE CODE |
| 151 | |
| 152 | data1::MessageDataReader_var reader_i = |
| 153 | data1::MessageDataReader::_narrow(reader); |
| 154 | |
| 155 | if (CORBA::is_nil(reader_i.in())) { |
| 156 | ACE_ERROR_RETURN((LM_ERROR, |
| 157 | ACE_TEXT("ERROR: %N:%l: main() -") |
| 158 | ACE_TEXT(" _narrow failed!\n")), |
| 159 | -1); |
| 160 | } |
| 161 | |
| 162 | // END OF EXISTING MESSENGER EXAMPLE CODE |
| 163 | std::cout << "sub leaving scope" << std::endl; |
| 164 | |
| 165 | } catch (const CORBA::Exception& e) { |
| 166 | e._tao_print_exception("Exception caught in main():"); |
| 167 | return -1; |
| 168 | |
| 169 | } catch( const std::exception& ex) { |
| 170 | ACE_ERROR_RETURN((LM_ERROR, |
| 171 | ACE_TEXT("(%P|%t) ERROR: %N:%l: main() -") |
nothing calls this directly
no test coverage detected