const MetaStruct&
MultiTopicDataReaderBase::metaStructFor(DDS::DataReader_ptr reader)
{
  DDS::TopicDescription_var td = reader->get_topicdescription();
  TopicDescriptionImpl* tdi = dynamic_cast<TopicDescriptionImpl*>(td.in());
  TypeSupportImpl* ts = dynamic_cast<TypeSupportImpl*>(tdi->get_type_support());
  return ts->getMetaStructForType();
}
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) ;
  }
}
Example #4
0
DDS::DataReader_var
Factory::reader(const DDS::Subscriber_var& sub, const DDS::Topic_var& topic, const DDS::DataReaderListener_var& drl) const
{
  // Create the data readers
  DDS::DataReaderQos dr_qos;
  sub->get_default_datareader_qos(dr_qos);

  dr_qos.durability.kind = opts_.durability_kind;
  dr_qos.liveliness.kind = opts_.liveliness_kind;
  dr_qos.liveliness.lease_duration = opts_.LEASE_DURATION;
  dr_qos.reliability.kind = opts_.reliability_kind;

  DDS::DomainParticipant_var dp = sub->get_participant();
  CORBA::String_var tn = topic->get_name();
  DDS::TopicDescription_var description = dp->lookup_topicdescription(tn);
  TEST_ASSERT(!CORBA::is_nil(description.in()));

  DDS::DataReader_var rd(sub->create_datareader(description.in(),
                                                dr_qos,
                                                drl.in(),
                                                ::OpenDDS::DCPS::DEFAULT_STATUS_MASK));

  // Initialize the transport configuration for the appropriate entity
  TEST_ASSERT(!opts_.configuration_str.empty());
  if (opts_.configuration_str != "none" && opts_.entity_str == "rw")
    {

      OpenDDS::DCPS::TransportRegistry::instance()->bind_config(opts_.configuration_str,
                                                                rd.in());
      if (!opts_.entity_autoenable)
        {
          TEST_ASSERT(DDS::RETCODE_OK == rd->enable());
        }
    }

  return rd;
}
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();
}