Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding required structs and methods to get a list of publishers or subscribers with their respective qos #186

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
cce521a
Added two structs:
jaisontj Sep 27, 2019
8fe5fd2
Added two functions to retrieve the list of all subscribers and publi…
jaisontj Sep 27, 2019
69744dd
Allocator and free functions for rmw_participant_qos_profile
jaisontj Sep 27, 2019
20bedc2
Fixed code indentation issues
jaisontj Sep 28, 2019
94b27b3
Tests to rmw_participant_qos_profile_t_allocator
jaisontj Oct 4, 2019
ed9651e
Modified tests to avoid memory leak
jaisontj Oct 4, 2019
5c5ccbf
- Updated rmw_participants_t to use rmw_participant_qos_profile_t *
jaisontj Oct 8, 2019
06c5d4c
Changed rmw_participants_t to use a pointer to an array.
jaisontj Oct 8, 2019
a5e113b
PR rework after design changes
jaisontj Oct 15, 2019
1714008
- Changed member variables from const type const to const type in
jaisontj Oct 25, 2019
583687e
- Added zero_init, check_zero, init_with_size and fini functions for
jaisontj Oct 29, 2019
91a5668
- More informative comments
jaisontj Nov 13, 2019
091988c
- Fixed warnings on deallocate by casting const char * to char *
jaisontj Nov 14, 2019
ad84fb3
Fixed code formatting issues
jaisontj Nov 15, 2019
9b22c98
- Using strncpy instead of strcpy
jaisontj Nov 16, 2019
383e4a6
Using memcpy instead of strncpy to prevent warnings on Windows
jaisontj Nov 20, 2019
5e0e27f
- Comment modification to be more explicit.
jaisontj Nov 22, 2019
1d9e1fe
- Fixed function comments
jaisontj Nov 26, 2019
cbd91b3
Using memcpy in topic_info_set_gid
jaisontj Nov 27, 2019
e24e1f4
Added init and fini functions for rmw_topic_info_t and tests for the
jaisontj Nov 27, 2019
272a2dc
change c-strings under topic_info to be non-const
mm318 Dec 11, 2019
c00ad69
revert the change that removed const qualifiers
mm318 Dec 12, 2019
3e8f892
address PR comments
mm318 Dec 12, 2019
a1c35de
address PR comments
mm318 Dec 18, 2019
747c4c9
add rmw_qos_profile_unknown
mm318 Jan 2, 2020
06bb093
use constant instead of literal for history depth
mm318 Jan 2, 2020
c82859b
address more PR comments
mm318 Jan 10, 2020
702aef2
rename *topic_info* to *topic_endpoint_info*
mm318 Jan 10, 2020
8ddb815
fix formatting
mm318 Jan 10, 2020
6d9675a
remove unused enum value from rmw_endpoint_type_t
mm318 Jan 10, 2020
2915b73
fix clang compiler warnings
mm318 Jan 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
- Comment modification to be more explicit.
- Changed topic_info* method signatures
- Moved topic_info_set* functions to a different file
- Tests for topic_info_set* functions
- Changed type of gid in rmw_topic_info_t to uint8_t[]
- Changed type of qos_profile in rmw_topic_info_t from pointer to
storing the structure.

Signed-off-by: Jaison Titus <jaisontj92@gmail.com>
  • Loading branch information
jaisontj committed Nov 23, 2019
commit 5e0e27f0cdb517321dc52ad1bab35ff7ebfa22fb
1 change: 1 addition & 0 deletions rmw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ set(rmw_sources
"src/sanity_checks.c"
"src/subscription_options.c"
"src/topic_info_array.c"
"src/topic_info.c"
"src/validate_full_topic_name.c"
"src/validate_namespace.c"
"src/validate_node_name.c"
Expand Down
4 changes: 2 additions & 2 deletions rmw/include/rmw/rmw.h
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@ rmw_set_log_severity(rmw_log_severity_t severity);
/// Retrieves the information for all publishers to a given topic.
/**
* The retrieved information will contain the publisher's node name, node namespace,
* associated topic type, gid and qos profile.
* associated topic type, publisher gid and qos profile.
*
* The node parameter must not be `NULL` and must point to a valid node.
*
Expand Down Expand Up @@ -1158,7 +1158,7 @@ rmw_get_publishers_info_by_topic(
/// Retrieves the information for all subscriptions to a given topic.
/**
* The retrieved information will contain the subscriptions's node name, node namespace,
* associated topic type, gid and qos profile.
* associated topic type, subscription gid and qos profile.
*
* The node parameter must not be `NULL` and must point to a valid node.
*
Expand Down
124 changes: 124 additions & 0 deletions rmw/include/rmw/topic_info.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef RMW__TOPIC_INFO_H_
#define RMW__TOPIC_INFO_H_

#ifdef __cplusplus
extern "C"
{
#endif

#include "rcutils/allocator.h"
#include "rmw/types.h"
#include "rmw/visibility_control.h"

/// Set the gid in rmw_topic_info_t.
/**
* Copies the values from gid into the gid member inside topic_info.
*
* \param[in] gid the gid value to set in rmw_topic_info_t
* \param[out] topic_info pointer to an initialized instance of rmw_topic_info_t
* \returns `RMW_RET_OK` on successfully setting the gid, or
* \returns `RMW_RET_INVALID_ARGUMENT` if any parameters are NULL, or
* \returns `RMW_RET_ERROR` when an unspecified error occurs.
*/
RMW_PUBLIC
RMW_WARN_UNUSED
rmw_ret_t
rmw_topic_info_set_gid(
rmw_topic_info_t * topic_info,
const uint8_t gid[],
size_t size);

/// Set the topic_type in rmw_topic_info_t.
/**
* rmw_topic_info_t has a member topic_type of type const char *;
* this function allocates memory and copies the value of param passed to it.
*
* \param[in] topic_type the topic_type value to set in rmw_topic_info_t
* \param[out] topic_info pointer to an initialized instance of rmw_topic_info_t
* \returns `RMW_RET_OK` on successfully setting the topic_type, or
* \returns `RMW_RET_INVALID_ARGUMENT` if any parameters are NULL, or
* \returns `RMW_RET_ERROR` when an unspecified error occurs.
*/
RMW_PUBLIC
RMW_WARN_UNUSED
rmw_ret_t
rmw_topic_info_set_topic_type(
rmw_topic_info_t * topic_info,
const char * topic_type,
rcutils_allocator_t * allocator);

/// Set the node_name in rmw_topic_info_t.
/**
* rmw_topic_info_t has a member node_name of type const char *;
* this function allocates memory and copies the value of param passed to it.
*
* \param[in] node_name the node_name value to set in rmw_topic_info_t
* \param[out] topic_info pointer to an initialized instance of rmw_topic_info_t
* \returns `RMW_RET_OK` on successfully setting the node_name, or
* \returns `RMW_RET_INVALID_ARGUMENT` if any parameters are NULL, or
* \returns `RMW_RET_ERROR` when an unspecified error occurs.
*/
RMW_PUBLIC
RMW_WARN_UNUSED
rmw_ret_t
rmw_topic_info_set_node_name(
rmw_topic_info_t * topic_info,
const char * node_name,
rcutils_allocator_t * allocator);

/// Set the node_namespace in rmw_topic_info_t.
/**
* rmw_topic_info_t has a member node_namespace of type const char *;
* this function allocates memory and copies the value of param passed to it.
*
* \param[in] node_namespace the node_namespace value to set in rmw_topic_info_t
* \param[out] topic_info pointer to an initialized instance of rmw_topic_info_t
* \returns `RMW_RET_OK` on successfully setting the node_namespace, or
* \returns `RMW_RET_INVALID_ARGUMENT` if any parameters are NULL, or
* \returns `RMW_RET_ERROR` when an unspecified error occurs.
*/
RMW_PUBLIC
RMW_WARN_UNUSED
rmw_ret_t
rmw_topic_info_set_node_namespace(
rmw_topic_info_t * topic_info,
const char * node_namespace,
rcutils_allocator_t * allocator);

/// Set the qos_profile in rmw_topic_info_t.
/**
* rmw_topic_info_t has a member qos_profile of type const rmw_qos_profile_t *.
* This function assigns the passed qos_profile pointer to the member.
*
* \param[in] qos_profile the qos_profile to set in rmw_topic_info_t
* \param[out] topic_info pointer to an initialized instance of rmw_topic_info_t
* \returns `RMW_RET_OK` on successfully setting the qos_profile, or
* \returns `RMW_RET_INVALID_ARGUMENT` if any parameters are NULL, or
* \returns `RMW_RET_ERROR` when an unspecified error occurs.
*/
RMW_PUBLIC
RMW_WARN_UNUSED
rmw_ret_t
rmw_topic_info_set_qos_profile(
rmw_topic_info_t * topic_info,
rmw_qos_profile_t * qos_profile);

#ifdef __cplusplus
}
#endif

#endif // RMW__TOPIC_INFO_H_
102 changes: 4 additions & 98 deletions rmw/include/rmw/topic_info_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ RMW_PUBLIC
RMW_WARN_UNUSED
rmw_ret_t
rmw_topic_info_array_init_with_size(
rcutils_allocator_t * allocator,
rmw_topic_info_array_t * topic_info_array,
size_t size,
rmw_topic_info_array_t * topic_info_array);
rcutils_allocator_t * allocator);

/// Finalize a rmw_topic_info_array_t object.
/**
Expand All @@ -75,102 +75,8 @@ RMW_PUBLIC
RMW_WARN_UNUSED
rmw_ret_t
rmw_topic_info_array_fini(
rcutils_allocator_t * allocator,
rmw_topic_info_array_t * topic_info_array);

/// Set the gid in rmw_topic_info_t.
/**
* rmw_topic_info_t has a member gid of type const char *;
* this function allocates memory and copies the value of param passed to it.
*
* \param[in] gid the gid value to set in rmw_topic_info_t
* \param[out] topic_info pointer to an initialized instance of rmw_topic_info_t
* \returns `RMW_RET_OK` on successfully setting the gid, or
* \returns `RMW_RET_INVALID_ARGUMENT` if any parameters are NULL, or
* \returns `RMW_RET_ERROR` when an unspecified error occurs.
*/
RMW_PUBLIC
RMW_WARN_UNUSED
rmw_ret_t
rmw_topic_info_set_gid(
rcutils_allocator_t * allocator,
const char * gid,
rmw_topic_info_t * topic_info);

/// Set the topic_type in rmw_topic_info_t.
/**
* rmw_topic_info_t has a member topic_type of type const char *;
* this function allocates memory and copies the value of param passed to it.
*
* \param[in] topic_type the topic_type value to set in rmw_topic_info_t
* \param[out] topic_info pointer to an initialized instance of rmw_topic_info_t
* \returns `RMW_RET_OK` on successfully setting the topic_type, or
* \returns `RMW_RET_INVALID_ARGUMENT` if any parameters are NULL, or
* \returns `RMW_RET_ERROR` when an unspecified error occurs.
*/
RMW_PUBLIC
RMW_WARN_UNUSED
rmw_ret_t
rmw_topic_info_set_topic_type(
rcutils_allocator_t * allocator,
const char * topic_type,
rmw_topic_info_t * topic_info);

/// Set the node_name in rmw_topic_info_t.
/**
* rmw_topic_info_t has a member node_name of type const char *;
* this function allocates memory and copies the value of param passed to it.
*
* \param[in] node_name the node_name value to set in rmw_topic_info_t
* \param[out] topic_info pointer to an initialized instance of rmw_topic_info_t
* \returns `RMW_RET_OK` on successfully setting the node_name, or
* \returns `RMW_RET_INVALID_ARGUMENT` if any parameters are NULL, or
* \returns `RMW_RET_ERROR` when an unspecified error occurs.
*/
RMW_PUBLIC
RMW_WARN_UNUSED
rmw_ret_t
rmw_topic_info_set_node_name(
rcutils_allocator_t * allocator,
const char * node_name,
rmw_topic_info_t * topic_info);

/// Set the node_namespace in rmw_topic_info_t.
/**
* rmw_topic_info_t has a member node_namespace of type const char *;
* this function allocates memory and copies the value of param passed to it.
*
* \param[in] node_namespace the node_namespace value to set in rmw_topic_info_t
* \param[out] topic_info pointer to an initialized instance of rmw_topic_info_t
* \returns `RMW_RET_OK` on successfully setting the node_namespace, or
* \returns `RMW_RET_INVALID_ARGUMENT` if any parameters are NULL, or
* \returns `RMW_RET_ERROR` when an unspecified error occurs.
*/
RMW_PUBLIC
RMW_WARN_UNUSED
rmw_ret_t
rmw_topic_info_set_node_namespace(
rcutils_allocator_t * allocator,
const char * node_namespace,
rmw_topic_info_t * topic_info);

/// Set the qos_profile in rmw_topic_info_t.
/**
* rmw_topic_info_t has a member qos_profile of type const rmw_qos_profile_t *.
* This function assigns the passed qos_profile pointer to the member.
*
* \param[in] qos_profile the qos_profile to set in rmw_topic_info_t
* \param[out] topic_info pointer to an initialized instance of rmw_topic_info_t
* \returns `RMW_RET_OK` on successfully setting the qos_profile, or
* \returns `RMW_RET_INVALID_ARGUMENT` if any parameters are NULL, or
* \returns `RMW_RET_ERROR` when an unspecified error occurs.
*/
RMW_PUBLIC
RMW_WARN_UNUSED
rmw_ret_t
rmw_topic_info_set_qos_profile(
rmw_qos_profile_t * qos_profile,
rmw_topic_info_t * topic_info);
rmw_topic_info_array_t * topic_info_array,
rcutils_allocator_t * allocator);

#ifdef __cplusplus
}
Expand Down
4 changes: 2 additions & 2 deletions rmw/include/rmw/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,9 @@ typedef struct RMW_PUBLIC_TYPE rmw_topic_info_t
/// The associated TopicType
const char * topic_type;
/// The GID of the node
const char * gid;
uint8_t gid[RMW_GID_STORAGE_SIZE];
/// Qos profile of the node
const rmw_qos_profile_t * qos_profile;
rmw_qos_profile_t qos_profile;
} rmw_topic_info_t;

/// Array of rmw_topic_info_t
Expand Down
Loading