Struct Context

Struct Documentation

struct Context

Base data structure that a Context will need in any DDS-based RMW implementation mapping one Participant to Multiple Nodes.

Public Types

using publish_callback_t = std::function<rmw_ret_t(const rmw_publisher_t *pub, const void *msg)>

Public Functions

rmw_ret_t add_node_graph(const std::string &name, const std::string &namespace_)

Add graph for creating a node.

Parameters:
  • name – node name.

  • namespace_ – node namespace.

Returns:

RMW_RET_OK if successful, or

Returns:

RMW_RET_ERROR an unexpected error occurs.

rmw_ret_t remove_node_graph(const std::string &name, const std::string &namespace_)

Remove graph for destroying a node.

Parameters:
  • name – node name.

  • namespace_ – node namespace.

Returns:

RMW_RET_OK if successful, or

Returns:

RMW_RET_ERROR an unexpected error occurs.

rmw_ret_t add_subscriber_graph(const rmw_gid_t &subscription_gid, const std::string &name, const std::string &namespace_)

Add graph for creating a subscription.

Parameters:
  • subscription_gid – subscription gid.

  • name – node name.

  • namespace_ – node namespace.

Returns:

RMW_RET_OK if successful, or

Returns:

RMW_RET_ERROR an unexpected error occurs.

rmw_ret_t remove_subscriber_graph(const rmw_gid_t &subscription_gid, const std::string &name, const std::string &namespace_)

Remove graph for destroying a subscription.

Parameters:
  • subscription_gid – subscription gid.

  • name – node name.

  • namespace_ – node namespace.

Returns:

RMW_RET_OK if successful, or

Returns:

RMW_RET_ERROR an unexpected error occurs.

rmw_ret_t add_publisher_graph(const rmw_gid_t &publisher_gid, const std::string &name, const std::string &namespace_)

Add graph for creating a publisher.

Parameters:
  • publisher_gid – publisher gid.

  • name – node name.

  • namespace_ – node namespace.

Returns:

RMW_RET_OK if successful, or

Returns:

RMW_RET_ERROR an unexpected error occurs.

rmw_ret_t remove_publisher_graph(const rmw_gid_t &publisher_gid, const std::string &name, const std::string &namespace_)

Remove graph for destroying a publisher.

Parameters:
  • publisher_gid – publisher gid.

  • name – node name.

  • namespace_ – node namespace.

Returns:

RMW_RET_OK if successful, or

Returns:

RMW_RET_ERROR an unexpected error occurs.

rmw_ret_t add_client_graph(const rmw_gid_t &request_publisher_gid, const rmw_gid_t &response_subscriber_gid, const std::string &name, const std::string &namespace_)

Add graph for creating a client.

Parameters:
  • request_publisher_gid – request publisher gid of the client.

  • response_subscriber_gid – response subscriber gid of the client.

  • name – node name.

  • namespace_ – node namespace.

Returns:

RMW_RET_OK if successful, or

Returns:

RMW_RET_ERROR an unexpected error occurs.

rmw_ret_t remove_client_graph(const rmw_gid_t &request_publisher_gid, const rmw_gid_t &response_subscriber_gid, const std::string &name, const std::string &namespace_)

Remove graph for destroying a client.

Parameters:
  • request_publisher_gid – request publisher gid of the client.

  • response_subscriber_gid – response subscriber gid of the client.

  • name – node name.

  • namespace_ – node namespace.

Returns:

RMW_RET_OK if successful, or

Returns:

RMW_RET_ERROR an unexpected error occurs.

rmw_ret_t add_service_graph(const rmw_gid_t &request_subscriber_gid, const rmw_gid_t &response_publisher_gid, const std::string &name, const std::string &namespace_)

Add graph for creating a service.

Parameters:
  • request_subscriber_gid – request subscriber gid of the client.

  • response_publisher_gid – response publisher gid of the client.

  • name – node name.

  • namespace_ – node namespace.

Returns:

RMW_RET_OK if successful, or

Returns:

RMW_RET_ERROR an unexpected error occurs.

rmw_ret_t remove_service_graph(const rmw_gid_t &request_subscriber_gid, const rmw_gid_t &response_publisher_gid, const std::string &name, const std::string &namespace_)

Remove graph for destroying a service.

Parameters:
  • request_subscriber_gid – request subscriber gid of the client.

  • response_publisher_gid – response publisher gid of the client.

  • name – node name.

  • namespace_ – node namespace.

Returns:

RMW_RET_OK if successful, or

Returns:

RMW_RET_ERROR an unexpected error occurs.

Public Members

rmw_gid_t gid

Global ID of the Participant that the Context uses.

rmw_publisher_t *pub

Publisher used to publish ParticipantEntitiesInfo discovery data.

rmw_subscription_t *sub

Subscriber used to listen to ParticipantEntitiesInfo discovery data.

GraphCache graph_cache

Cached graph from discovery data.

std::thread listener_thread

Thread to listen to discovery data.

std::atomic_bool thread_is_running

Indicates if the listener thread is running.

rmw_guard_condition_t *listener_thread_gc

Awakes listener thread when finishing the context.

rmw_guard_condition_t *graph_guard_condition

Guard condition that should be triggered when the graph changes.

publish_callback_t publish_callback

Publish a graph message when updating or destroying graph cache.