-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add function for checking QoS profile compatibility (#45)
* Add function for checking QoS profile compatibility Given QoS profiles for a publisher and a subscription, this function will return `true` if the profiles are compatible. Compatible profiles implies that the subscription and publisher will be able to communicate. Connected to ros2/rmw#299 Signed-off-by: Jacob Perron <[email protected]> * Refactor signature of _write_to_buffer Signed-off-by: Jacob Perron <[email protected]> * Set error message instead of setting reason Signed-off-by: Jacob Perron <[email protected]> * Error is null reason and non-zero reason_size Signed-off-by: Jacob Perron <[email protected]> * Do not set output parameter if an error occurs Signed-off-by: Jacob Perron <[email protected]> * Add test for reason buffer too small Signed-off-by: Jacob Perron <[email protected]> * Warn on unknown values instead of error Signed-off-by: Jacob Perron <[email protected]> * Fixes * Use vsnprintf over snprintf (or undefined things can happen) * Handle NULL return value from `*to_str()` functions * Add more tests Signed-off-by: Jacob Perron <[email protected]> * Guard against zero reason_size Add test case. Signed-off-by: Jacob Perron <[email protected]>
- Loading branch information
1 parent
37d16b8
commit f51dee1
Showing
5 changed files
with
1,203 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright 2021 Open Source Robotics Foundation, Inc. | ||
// | ||
// 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_DDS_COMMON__QOS_HPP_ | ||
#define RMW_DDS_COMMON__QOS_HPP_ | ||
|
||
#include "rmw/qos_profiles.h" | ||
#include "rmw/types.h" | ||
|
||
#include "rmw_dds_common/visibility_control.h" | ||
|
||
namespace rmw_dds_common | ||
{ | ||
|
||
/// Check if two QoS profiles are compatible | ||
/** | ||
* Two QoS profiles are compatible if a publisher and subcription | ||
* using the QoS policies can communicate with each other. | ||
* | ||
* This implements the rmw API \ref rmw_qos_profile_check_compatible(). | ||
* See \ref rmw_qos_profile_check_compatible() for more information. | ||
* | ||
* \param[in] publisher_profile: The QoS profile used for a publisher. | ||
* \param[in] subscription_profile: The QoS profile used for a subscription. | ||
* \param[out] compatibility: `RMW_QOS_COMPATIBILITY_OK` if the QoS profiles are compatible, or | ||
* `RMW_QOS_COMPATIBILITY_WARNING` if the QoS profiles might be compatible, or | ||
* `RMW_QOS_COMPATIBILITY_ERROR` if the QoS profiles are not compatible. | ||
* \param[out] reason: A detailed reason for a QoS incompatibility or potential incompatibility. | ||
* Must be pre-allocated by the caller. | ||
* This parameter is optional and may be set to `nullptr` if the reason information is not | ||
* desired. | ||
* \param[in] reason_size: Size of the string buffer `reason`, if one is provided. | ||
* If `reason` is `nullptr`, then this parameter must be zero. | ||
* \return `RMW_RET_OK` if the check was successful, or | ||
* \return `RMW_RET_INVALID_ARGUMENT` if `compatiblity` is `nullptr`, or | ||
* \return `RMW_RET_INVALID_ARGUMENT` if `reason` is `nullptr` and `reason_size` is not zero, or | ||
* \return `RMW_RET_ERROR` if there is an unexpected error. | ||
*/ | ||
RMW_DDS_COMMON_PUBLIC | ||
rmw_ret_t | ||
qos_profile_check_compatible( | ||
const rmw_qos_profile_t publisher_qos, | ||
const rmw_qos_profile_t subscription_qos, | ||
rmw_qos_compatibility_type_t * compatibility, | ||
char * reason, | ||
size_t reason_size); | ||
|
||
} // namespace rmw_dds_common | ||
|
||
#endif // RMW_DDS_COMMON__QOS_HPP_ |
Oops, something went wrong.