Skip to content

Commit

Permalink
Implemented service is valid check.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hunter L. Allen committed Dec 26, 2016
1 parent 5f74a08 commit c5c6d7d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions rcl/include/rcl/service.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,9 @@ RCL_WARN_UNUSED
rmw_service_t *
rcl_service_get_rmw_handle(const rcl_service_t * service);

bool
rcl_service_is_valid(const rcl_service_t * service);

#if __cplusplus
}
#endif
Expand Down
21 changes: 21 additions & 0 deletions rcl/src/rcl/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,27 @@ rcl_send_response(
return RCL_RET_OK;
}

bool
rcl_service_is_valid(const rcl_service_t * service)
{
RCL_CHECK_FOR_NULL_WITH_MSG(service,
"service is invalid",
return false);
RCL_CHECK_FOR_NULL_WITH_MSG(service->impl,
"service is invalid",
return false);
RCL_CHECK_FOR_NULL_WITH_MSG(service->impl->rmw_handle,
"rmw handle is invalid",
return false);
RCL_CHECK_FOR_NULL_WITH_MSG(service->impl->rmw_handle->service_name,
"service name is invalid",
return false);
RCL_CHECK_FOR_NULL_WITH_MSG(*service->impl->rmw_handle->service_name,
"service name is invalid",
return false);
return true;
}

#if __cplusplus
}
#endif

0 comments on commit c5c6d7d

Please sign in to comment.