示例#1
0
int ignore ()
{
#if !defined (DDS_HAS_MINIMUM_BIT)
  switch (ignore_kind)
  {
  case IGNORE_PARTICIPANT:
    {
      // Normally a client application would use some Qos like
      // the USER_DATA to find the Built-In Topic InstanceHandle_t
      // value for an entity (e.g. a DomainParticipant) but this
      // test knows everything and can use the discovery RepoID.
      ::OpenDDS::DCPS::RepoId part_id = participant_servant->get_id ();
      //SHH one of these should be the subscriber participant and the other should be the publisher participant.
      ::OpenDDS::DCPS::RepoId ignore_id = participant_servant->get_id ();

      std::stringstream participantBuffer;
      participantBuffer << part_id;
      std::stringstream ignoreBuffer;
      ignoreBuffer << ignore_id;
      ACE_DEBUG((LM_DEBUG,
                 ACE_TEXT("(%P|%t) IGNORE_PARTICIPANT,  participant %C ignore participant %C .\n"),
                 participantBuffer.str().c_str(), ignoreBuffer.str().c_str()));

      InstanceHandle_t handle = participant_servant->get_handle(ignore_id);

      ACE_DEBUG((LM_DEBUG,
        ACE_TEXT("(%P|%t) IGNORE_PARTICIPANT, ignored participant %C has handle 0x%x.\n"),
        ignoreBuffer.str().c_str(),
        handle
      ));

      DDS::ReturnCode_t ret = participant->ignore_participant(handle);

      if (ret != ::DDS::RETCODE_OK)
      {
        ACE_ERROR ((LM_ERROR,
                    ACE_TEXT("(%P|%t) IGNORE_PARTICIPANT, ")
                    ACE_TEXT(" participant %C ignore participant %C returned error %d\n"),
                    participantBuffer.str().c_str(), ignoreBuffer.str().c_str(), ret));
        return -1;
      }
    }
    break;

  case IGNORE_TOPIC:
    {
      ::OpenDDS::DCPS::RepoId part_id = participant_servant->get_id ();
      ::OpenDDS::DCPS::RepoId ignore_id = topic_servant->get_id ();

      std::stringstream participantBuffer;
      participantBuffer << part_id;
      std::stringstream ignoreBuffer;
      ignoreBuffer << ignore_id;
      ACE_DEBUG((LM_DEBUG,
                 ACE_TEXT("(%P|%t) IGNORE_TOPIC, participant %C ignore topic %C .\n"),
                 participantBuffer.str().c_str(), ignoreBuffer.str().c_str()));

      InstanceHandle_t handle = participant_servant->get_handle(ignore_id);
      ACE_DEBUG((LM_DEBUG,
        ACE_TEXT("(%P|%t) IGNORE_TOPIC,  ignored topic %C has handle 0x%x.\n"),
        ignoreBuffer.str().c_str(),
        handle
      ));

      DDS::ReturnCode_t ret = participant->ignore_topic(handle);

      if (ret != ::DDS::RETCODE_OK)
      {
        ACE_ERROR ((LM_ERROR,
                    ACE_TEXT("(%P|%t) IGNORE_TOPIC, ")
                    ACE_TEXT(" ignore_topic 0x%x return error %d\n"),
                    handle, ret));
        return -1;
      }
    }
    break;
  case IGNORE_PUBLICATION:
    {
      ::OpenDDS::DCPS::RepoId part_id = participant_servant->get_id ();
      ::OpenDDS::DCPS::RepoId ignore_id = datawriter_servant->get_publication_id ();

      std::stringstream participantBuffer;
      participantBuffer << part_id;
      std::stringstream ignoreBuffer;
      ignoreBuffer << ignore_id;
      ACE_DEBUG((LM_DEBUG,
                 ACE_TEXT("(%P|%t) IGNORE_PUBLICATION, participant %C ignore publication %C .\n"),
                 participantBuffer.str().c_str(), ignoreBuffer.str().c_str()));

      InstanceHandle_t handle = participant_servant->get_handle(ignore_id);
      ACE_DEBUG((LM_DEBUG,
        ACE_TEXT("(%P|%t) IGNORE_PUBLICATION,  ignored topic %C has handle 0x%x.\n"),
        ignoreBuffer.str().c_str(),
        handle
      ));

      DDS::ReturnCode_t ret = participant->ignore_publication(handle);

      if (ret != ::DDS::RETCODE_OK)
      {
        ACE_ERROR ((LM_ERROR,
                    ACE_TEXT("(%P|%t) IGNORE_PUBLICATION, ")
                    ACE_TEXT(" ignore_publication 0x%x return error %d\n"),
                    handle, ret));
        return -1;
      }
    }
    break;
  case IGNORE_SUBSCRIPTION:
    {
      ::OpenDDS::DCPS::RepoId part_id = participant_servant->get_id ();
      ::OpenDDS::DCPS::RepoId ignore_id = datareader_servant->get_subscription_id ();

      std::stringstream participantBuffer;
      participantBuffer << part_id;
      std::stringstream ignoreBuffer;
      ignoreBuffer << ignore_id;
      ACE_DEBUG((LM_DEBUG,
                 ACE_TEXT("(%P|%t) IGNORE_SUBSCRIPTION, participant %C ignore subscription %C .\n"),
                 participantBuffer.str().c_str(), ignoreBuffer.str().c_str()));

      InstanceHandle_t handle = participant_servant->get_handle(ignore_id);
      ACE_DEBUG((LM_DEBUG,
        ACE_TEXT("(%P|%t) IGNORE_SUBSCRIPTION,  ignored topic %C has handle 0x%x.\n"),
        ignoreBuffer.str().c_str(),
        handle
      ));

      DDS::ReturnCode_t ret = participant->ignore_subscription(handle);

      if (ret != ::DDS::RETCODE_OK)
      {
        ACE_ERROR ((LM_ERROR,
                    ACE_TEXT("(%P|%t) IGNORE_SUBSCRIPTION, ")
                    ACE_TEXT(" ignore_subscription 0x%x returned error %d\n"),
                    handle, ret));
        return -1;
      }
    }
    break;
  default:
    ACE_ERROR ((LM_ERROR,
      ACE_TEXT("(%P|%t) ignore, ")
      ACE_TEXT(" unknown ignore kind %d\n"), ignore_kind));
    return -1;
    break;
  }

  return 0;
#else

  return -1;
#endif // !defined (DDS_HAS_MINIMUM_BIT)
}
示例#2
0
int ignore ()
{
#if !defined (DDS_HAS_MINIMUM_BIT)
  switch (ignore_kind)
  {
  case IGNORE_PARTICIPANT:
    {
      // Normally a client application would use some Qos like
      // the USER_DATA to find the Built-In Topic InstanceHandle_t
      // value for an entity (e.g. a DomainParticipant) but this
      // test knows everything and can use the DCPSInfo RepoID.
      ::TAO::DCPS::RepoId part_id = participant_servant->get_id ();
      //SHH one of these should be the subscriber participant and the other should be the publisher participant.
      ::TAO::DCPS::RepoId ignore_id = participant_servant->get_id ();

      ACE_DEBUG((LM_DEBUG,
                 ACE_TEXT("(%P|%t) IGNORE_PARTICIPANT,  participant %d ignore participant %d .\n"),
                 part_id, ignore_id));

      ::DDS::InstanceHandleSeq handles;
      ::TAO::DCPS::ReaderIdSeq ignore_ids;
      ignore_ids.length (1);
      ignore_ids[0] = ignore_id;

      ::TAO::DCPS::BIT_Helper_2 < ::DDS::ParticipantBuiltinTopicDataDataReader,
                    ::DDS::ParticipantBuiltinTopicDataDataReader_var,
                    ::DDS::ParticipantBuiltinTopicDataSeq,
                    ::TAO::DCPS::ReaderIdSeq > hh;

      ::DDS::ReturnCode_t ret
        = hh.repo_ids_to_instance_handles(participant_servant,
          ::TAO::DCPS::BUILT_IN_PARTICIPANT_TOPIC,
          ignore_ids,
          handles);

      if (ret != ::DDS::RETCODE_OK)
      {
        ACE_ERROR ((LM_ERROR,
          ACE_TEXT("(%P|%t) IGNORE_PARTICIPANT, ")
          ACE_TEXT(" repo_ids_to_instance_handles returned error %d\n"),
          ret));
        return -1;
      }

      ret = participant->ignore_participant (handles[0]);

      if (ret != ::DDS::RETCODE_OK)
      {
        ACE_ERROR ((LM_ERROR,
                    ACE_TEXT("(%P|%t) IGNORE_PARTICIPANT, ")
                    ACE_TEXT(" participant %d ignore participant %d returned error %d\n"),
                    part_id, ignore_id, ret));
        return -1;
      }
    }
    break;

  case IGNORE_TOPIC:
    {
      ::TAO::DCPS::RepoId part_id = participant_servant->get_id ();
      ::TAO::DCPS::RepoId ignore_id = topic_servant->get_id ();

      ACE_DEBUG((LM_DEBUG,
                 ACE_TEXT("(%P|%t) IGNORE_TOPIC, participant %d ignore topic %d .\n"),
                 part_id, ignore_id));

      ::DDS::InstanceHandleSeq handles;
      ::TAO::DCPS::ReaderIdSeq ignore_ids;
      ignore_ids.length (1);
      ignore_ids[0] = ignore_id;

      ::TAO::DCPS::BIT_Helper_2 < ::DDS::TopicBuiltinTopicDataDataReader,
                    ::DDS::TopicBuiltinTopicDataDataReader_var,
                    ::DDS::TopicBuiltinTopicDataSeq,
                    ::TAO::DCPS::ReaderIdSeq > hh;

      ::DDS::ReturnCode_t ret
        = hh.repo_ids_to_instance_handles(participant_servant,
          ::TAO::DCPS::BUILT_IN_TOPIC_TOPIC,
          ignore_ids,
          handles);

      if (ret != ::DDS::RETCODE_OK)
      {
        ACE_ERROR ((LM_ERROR,
          ACE_TEXT("(%P|%t) IGNORE_TOPIC, ")
          ACE_TEXT(" repo_ids_to_instance_handles returned error %d.\n"),
          ret));
        return -1;
      }

      ret = participant->ignore_topic (handles[0]);

      if (ret != ::DDS::RETCODE_OK)
      {
        ACE_ERROR ((LM_ERROR,
                    ACE_TEXT("(%P|%t) IGNORE_TOPIC, ")
                    ACE_TEXT(" ignore_topic %d return error %d\n"),
                    handles[0], ret));
        return -1;
      }
    }
    break;
  case IGNORE_PUBLICATION:
    {
      ::TAO::DCPS::RepoId part_id = participant_servant->get_id ();
      ::TAO::DCPS::RepoId ignore_id = datawriter_servant->get_publication_id ();

      ACE_DEBUG((LM_DEBUG,
                 ACE_TEXT("(%P|%t) IGNORE_PUBLICATION, participant %d ignore publication %d .\n"),
                 part_id, ignore_id));

      ::DDS::InstanceHandleSeq handles;
      ::TAO::DCPS::ReaderIdSeq ignore_ids;
      ignore_ids.length (1);
      ignore_ids[0] = ignore_id;

      ::TAO::DCPS::BIT_Helper_2 <
                    ::DDS::PublicationBuiltinTopicDataDataReader,
                    ::DDS::PublicationBuiltinTopicDataDataReader_var,
                    ::DDS::PublicationBuiltinTopicDataSeq,
                    ::TAO::DCPS::ReaderIdSeq > hh;

      ::DDS::ReturnCode_t ret
        = hh.repo_ids_to_instance_handles(participant_servant,
          ::TAO::DCPS::BUILT_IN_PUBLICATION_TOPIC,
          ignore_ids,
          handles);

      if (ret != ::DDS::RETCODE_OK)
      {
        ACE_ERROR ((LM_ERROR,
          ACE_TEXT("(%P|%t) IGNORE_PUBLICATION, ")
          ACE_TEXT(" repo_ids_to_instance_handles returned error %d\n"),
          ret));
        return -1;
      }

      ret = participant->ignore_publication (handles[0]);

      if (ret != ::DDS::RETCODE_OK)
      {
        ACE_ERROR ((LM_ERROR,
                    ACE_TEXT("(%P|%t) IGNORE_PUBLICATION, ")
                    ACE_TEXT(" ignore_publication %d return error %d\n"),
                    handles[0], ret));
        return -1;
      }
    }
    break;
  case IGNORE_SUBSCRIPTION:
    {
      ::TAO::DCPS::RepoId part_id = participant_servant->get_id ();
      ::TAO::DCPS::RepoId ignore_id = datareader_servant->get_subscription_id ();

      ACE_DEBUG((LM_DEBUG,
                 ACE_TEXT("(%P|%t) IGNORE_SUBSCRIPTION, participant %d ignore subscription %d .\n"),
                 part_id, ignore_id));

      ::DDS::InstanceHandleSeq handles;
      ::TAO::DCPS::ReaderIdSeq ignore_ids;
      ignore_ids.length (1);
      ignore_ids[0] = ignore_id;

      ::TAO::DCPS::BIT_Helper_2 < ::DDS::SubscriptionBuiltinTopicDataDataReader,
                    ::DDS::SubscriptionBuiltinTopicDataDataReader_var,
                    ::DDS::SubscriptionBuiltinTopicDataSeq,
                    ::TAO::DCPS::ReaderIdSeq > hh;

      ::DDS::ReturnCode_t ret
        = hh.repo_ids_to_instance_handles(participant_servant,
          ::TAO::DCPS::BUILT_IN_SUBSCRIPTION_TOPIC,
          ignore_ids,
          handles);

      if (ret != ::DDS::RETCODE_OK)
      {
        ACE_ERROR ((LM_ERROR,
          ACE_TEXT("(%P|%t) IGNORE_SUBSCRIPTION, ")
          ACE_TEXT(" repo_ids_to_instance_handles returned error %d\n"),
          ret));
        return -1;
      }

      ret = participant->ignore_subscription (handles[0]);

      if (ret != ::DDS::RETCODE_OK)
      {
        ACE_ERROR ((LM_ERROR,
                    ACE_TEXT("(%P|%t) IGNORE_SUBSCRIPTION, ")
                    ACE_TEXT(" ignore_subscription %d returned error 5d\n"),
                    handles[0], ret));
        return -1;
      }
    }
    break;
  default:
    ACE_ERROR ((LM_ERROR,
      ACE_TEXT("(%P|%t) ignore, ")
      ACE_TEXT(" unknown ignore kind %d\n"), ignore_kind));
    return -1;
    break;
  }

  return 0;
#else

  return -1;
#endif // !defined (DDS_HAS_MINIMUM_BIT)
}