Beispiel #1
0
    ::DDS::InstanceHandle_t
    DDS_WaitSet_i::check_handle (
      const ::DDS::InstanceHandle_t & instance_handle,
      const ::DDS::InstanceHandle_t & lookup_handle,
      bool & error,
      bool & non_existent)
    {
      ::DDS_InstanceHandle_t hnd = ::DDS_HANDLE_NIL;
      hnd <<= instance_handle;

      ::DDS_InstanceHandle_t lookup_hnd = ::DDS_HANDLE_NIL;
      lookup_hnd <<= lookup_handle;

      ::DDS::InstanceHandle_t ret = ::DDS::HANDLE_NIL;

      if (!DDS_InstanceHandle_equals (&hnd, &::DDS_HANDLE_NIL) &&
          !DDS_InstanceHandle_equals (&hnd, &lookup_hnd))
        {
          error = true;
        }
      else if (DDS_InstanceHandle_equals (&lookup_hnd, &::DDS_HANDLE_NIL))
        {
          non_existent = true;
        }
      else
        {
          ret <<= lookup_hnd;
        }
      return ret;
    }
Beispiel #2
0
void CustomDataReaderListener::remove_information(
  const DDS_InstanceHandle_t & instance_handle,
  EntityType entity_type)
{
  (void)entity_type;
  std::lock_guard<std::mutex> topic_descriptor_lock(topic_descriptor_mutex_);
  // find entry by instance handle
  for (auto it = topic_descriptors.begin(); it != topic_descriptors.end(); ++it) {
    if (DDS_InstanceHandle_equals(&it->instance_handle, &instance_handle)) {
      // remove entries
#ifdef DISCOVERY_DEBUG_LOGGING
      printf("-%s %s <%s>\n",
        entity_type == EntityType::Publisher ? "P" : "S",
        it->name.c_str(),
        it->type.c_str());
#endif
      auto & topic_types = topic_names_and_types[it->name];
      topic_types.erase(topic_types.find(it->type));
      if (topic_types.empty()) {
        topic_names_and_types.erase(it->name);
      }
      topic_descriptors.erase(it);
      break;
    }
  }
}
bool
operator== (const ::DDS::InstanceHandle_t & instancehandle1, const ::DDS::InstanceHandle_t & instancehandle2)
{
  DDS_InstanceHandle_t i1 = DDS_HANDLE_NIL;
  DDS_InstanceHandle_t i2 = DDS_HANDLE_NIL;
  i1 <<= instancehandle1;
  i2 <<= instancehandle2;
  if (DDS_InstanceHandle_is_nil(&instancehandle1))
    {
      return DDS_InstanceHandle_is_nil (&instancehandle2);
    }
  else if (DDS_InstanceHandle_is_nil(&instancehandle2))
    {
      return DDS_InstanceHandle_is_nil (&instancehandle1);
    }
  else
    {
      return DDS_InstanceHandle_equals (&i1, &i2);
    }
}
rmw_ret_t
rmw_compare_gids_equal(const rmw_gid_t * gid1, const rmw_gid_t * gid2, bool * result)
{
  if (!gid1) {
    RMW_SET_ERROR_MSG("gid1 is null");
    return RMW_RET_ERROR;
  }
  RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
    gid1,
    gid1->implementation_identifier,
    rti_connext_identifier,
    return RMW_RET_ERROR)
  if (!gid2) {
    RMW_SET_ERROR_MSG("gid2 is null");
    return RMW_RET_ERROR;
  }
  RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
    gid2,
    gid2->implementation_identifier,
    rti_connext_identifier,
    return RMW_RET_ERROR)
  if (!result) {
    RMW_SET_ERROR_MSG("result is null");
    return RMW_RET_ERROR;
  }
  auto detail1 = reinterpret_cast<const ConnextPublisherGID *>(gid1->data);
  if (!detail1) {
    RMW_SET_ERROR_MSG("gid1 is invalid");
    return RMW_RET_ERROR;
  }
  auto detail2 = reinterpret_cast<const ConnextPublisherGID *>(gid2->data);
  if (!detail2) {
    RMW_SET_ERROR_MSG("gid2 is invalid");
    return RMW_RET_ERROR;
  }
  auto matches =
    DDS_InstanceHandle_equals(&detail1->publication_handle, &detail2->publication_handle);
  *result = (matches == DDS::BOOLEAN_TRUE);
  return RMW_RET_OK;
}