void DataReaderListenerImpl4::read(::DDS::DataReader_ptr reader)
{
    ::T4::Foo4DataReader_var foo_dr = ::T4::Foo4DataReader::_narrow(reader);

    if (CORBA::is_nil(foo_dr)) {
        ACE_ERROR((LM_ERROR,
                   ACE_TEXT("(%P|%t) ::T4::Foo4DataReader::_narrow failed.\n")));
        return;
    }

    DDS::TopicDescription_var td = reader->get_topicdescription();
    CORBA::String_var topic = td->get_name();

    ::T4::Foo4DataReaderImpl* dr_servant =
        dynamic_cast< ::T4::Foo4DataReaderImpl*>(foo_dr.in());

    ::T4::Foo4Seq foo(num_ops_per_thread_);
    ::DDS::SampleInfoSeq si(num_ops_per_thread_);

    DDS::ReturnCode_t status = dr_servant->read(foo, si,
                               num_ops_per_thread_,
                               ::DDS::NOT_READ_SAMPLE_STATE,
                               ::DDS::ANY_VIEW_STATE,
                               ::DDS::ANY_INSTANCE_STATE);

    if (status == ::DDS::RETCODE_OK) {

        for (CORBA::ULong i = 0; i < si.length(); ++i) {
            if (si[i].valid_data) {
                ++num_samples_;
                const CORBA::ULong len = foo[i].values.length();
                ACE_OS::printf("%s foo4[%u]: length = %u\n", topic.in(), i, len);

                for (CORBA::ULong j = 0; j < len; ++j) {
                    ACE_OS::printf("\tfoo4[%u][%u]: value = %f\n",
                                   i, j, foo[i].values[j]);
                }
            }
        }

    } else if (status == ::DDS::RETCODE_NO_DATA) {
        ACE_OS::printf("read returned ::DDS::RETCODE_NO_DATA\n") ;

    } else {
        ACE_OS::printf("read - Error: %d\n", status) ;
    }
}
void DataReaderListenerImpl1::read(::DDS::DataReader_ptr reader)
{
  ::T1::Foo1DataReader_var foo_dr = ::T1::Foo1DataReader::_narrow(reader);

  if (CORBA::is_nil(foo_dr)) {
    ACE_ERROR((LM_ERROR,
               ACE_TEXT("(%P|%t) ::T1::FooDataReader::_narrow failed.\n")));
    return;
  }

  DDS::TopicDescription_var td = reader->get_topicdescription();
  CORBA::String_var topic = td->get_name();

  ::T1::Foo1DataReaderImpl* dr_servant =
      dynamic_cast<T1::Foo1DataReaderImpl*>(foo_dr.in());

  ::T1::Foo1Seq foo(num_ops_per_thread_);
  ::DDS::SampleInfoSeq si(num_ops_per_thread_);

  DDS::ReturnCode_t status = dr_servant->read(foo, si,
                                              num_ops_per_thread_,
                                              ::DDS::NOT_READ_SAMPLE_STATE,
                                              ::DDS::ANY_VIEW_STATE,
                                              ::DDS::ANY_INSTANCE_STATE);
  if (status == ::DDS::RETCODE_OK) {

    for (CORBA::ULong i = 0; i < si.length(); ++i) {
      if (si[i].valid_data) {
          ++num_samples_;

          ACE_OS::printf("%s foo1[%d]: c = %c, x = %f y = %f, key = %d\n",
                         topic.in(), i, foo[i].c, foo[i].x, foo[i].y,
                         foo[i].key);
      }
    }

  } else if (status == ::DDS::RETCODE_NO_DATA) {
    ACE_OS::printf("read returned ::DDS::RETCODE_NO_DATA\n") ;

  } else {
    ACE_OS::printf("read - Error: %d\n", status) ;
  }
}
std::string MultiTopicDataReaderBase::topicNameFor(DDS::DataReader_ptr reader)
{
  DDS::TopicDescription_var td = reader->get_topicdescription();
  CORBA::String_var topic = td->get_name();
  return topic.in();
}