Skip to content

Commit

Permalink
[Handle] Update get_value deprecation note (#2074)
Browse files Browse the repository at this point in the history
  • Loading branch information
saikishor authored Feb 27, 2025
1 parent e7457a7 commit a5a2e27
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
9 changes: 6 additions & 3 deletions hardware_interface/include/hardware_interface/handle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ class Handle
const std::string & get_prefix_name() const { return prefix_name_; }

[[deprecated(
"Use std::optional<T> get_optional() or bool get_value(double & "
"value) instead to retrieve the value.")]]
"Use std::optional<T> get_optional() instead to retrieve the value. This method will be "
"removed by the ROS 2 Kilted Kaiju release.")]]
double get_value() const
{
std::shared_lock<std::shared_mutex> lock(handle_mutex_, std::try_to_lock);
Expand Down Expand Up @@ -166,7 +166,10 @@ class Handle
* the value is updated and returns true.
*/
template <typename T>
[[nodiscard]] bool get_value(T & value) const
[[deprecated(
"Use std::optional<T> get_optional() instead to retrieve the value. This method will be "
"removed by the ROS 2 Kilted Kaiju release.")]] [[nodiscard]] bool
get_value(T & value) const
{
std::shared_lock<std::shared_mutex> lock(handle_mutex_, std::try_to_lock);
if (!lock.owns_lock())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ class LoanedCommandInterface
}

[[deprecated(
"Use std::optional<T> get_optional() or bool get_value(double & "
"value) instead to retrieve the value.")]]
"Use std::optional<T> get_optional() instead to retrieve the value. This method will be "
"removed by the ROS 2 Kilted Kaiju release.")]]
double get_value() const
{
double value = std::numeric_limits<double>::quiet_NaN();
Expand Down Expand Up @@ -195,7 +195,10 @@ class LoanedCommandInterface
* true immediately.
*/
template <typename T>
[[nodiscard]] bool get_value(T & value, unsigned int max_tries = 10) const
[[deprecated(
"Use std::optional<T> get_optional() instead to retrieve the value. This method will be "
"removed by the ROS 2 Kilted Kaiju release.")]] [[nodiscard]] bool
get_value(T & value, unsigned int max_tries = 10) const
{
unsigned int nr_tries = 0;
++get_value_statistics_.total_counter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ class LoanedStateInterface
const std::string & get_prefix_name() const { return state_interface_.get_prefix_name(); }

[[deprecated(
"Use std::optional<T> get_optional() or bool get_value(double & "
"value) instead to retrieve the value.")]]
"Use std::optional<T> get_optional() instead to retrieve the value. This method will be "
"removed by the ROS 2 Kilted Kaiju release.")]]
double get_value() const
{
double value = std::numeric_limits<double>::quiet_NaN();
Expand Down Expand Up @@ -155,7 +155,10 @@ class LoanedStateInterface
* the value and returns true immediately.
*/
template <typename T>
[[nodiscard]] bool get_value(T & value, unsigned int max_tries = 10) const
[[deprecated(
"Use std::optional<T> get_optional() instead to retrieve the value. This method will be "
"removed by the ROS 2 Kilted Kaiju release.")]] [[nodiscard]] bool
get_value(T & value, unsigned int max_tries = 10) const
{
unsigned int nr_tries = 0;
++get_value_statistics_.total_counter;
Expand Down

0 comments on commit a5a2e27

Please sign in to comment.