Skip to content

Commit 5a1b3e8

Browse files
committed
cleanup
1 parent f50f34b commit 5a1b3e8

File tree

2 files changed

+28
-21
lines changed

2 files changed

+28
-21
lines changed

hardware_interface/include/hardware_interface/handle.hpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ typedef std::variant<double> HANDLE_DATATYPE;
3333
class Handle
3434
{
3535
public:
36-
[[deprecated("Use InterfaceDescription for initializing the Command-/StateIntefaces.")]]
36+
[[deprecated("Use InterfaceDescription for initializing the Interface")]]
3737

3838
Handle(
3939
const std::string & prefix_name, const std::string & interface_name,
@@ -52,14 +52,14 @@ class Handle
5252
value_ptr_ = std::get_if<double>(&value_);
5353
}
5454

55-
[[deprecated("Use InterfaceDescription for initializing the Command-/StateIntefaces.")]]
55+
[[deprecated("Use InterfaceDescription for initializing the Interface")]]
5656

5757
explicit Handle(const std::string & interface_name)
5858
: interface_name_(interface_name), value_ptr_(nullptr)
5959
{
6060
}
6161

62-
[[deprecated("Use InterfaceDescription for initializing the Command-/StateIntefaces.")]]
62+
[[deprecated("Use InterfaceDescription for initializing the Interface")]]
6363

6464
explicit Handle(const char * interface_name)
6565
: interface_name_(interface_name), value_ptr_(nullptr)
@@ -93,23 +93,30 @@ class Handle
9393
const std::string & get_prefix_name() const { return prefix_name_; }
9494

9595
double get_value() const
96-
{
96+
{ // BEGIN (Handle export change): for backward compatibility
97+
// TODO(Manuel) return value_ if old functionality is removed
9798
THROW_ON_NULLPTR(value_ptr_);
9899
return *value_ptr_;
100+
// END
99101
}
100102

101103
void set_value(double value)
102104
{
105+
// BEGIN (Handle export change): for backward compatibility
106+
// TODO(Manuel) set value_ directly if old functionality is removed
103107
THROW_ON_NULLPTR(this->value_ptr_);
104108
*this->value_ptr_ = value;
109+
// END
105110
}
106111

107112
protected:
108113
std::string prefix_name_;
109114
std::string interface_name_;
110115
HANDLE_DATATYPE value_;
116+
// BEGIN (Handle export change): for backward compatibility
111117
// TODO(Manuel) redeclare as HANDLE_DATATYPE * value_ptr_ if old functionality is removed
112118
double * value_ptr_;
119+
// END
113120
};
114121

115122
class StateInterface : public Handle

hardware_interface/src/resource_manager.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,8 @@ class ResourceStorage
443443
}
444444
}
445445

446-
// TODO(Manuel) BEGIN: for backward compatibility, can be removed if export_state_interfaces()
447-
// method is removed
446+
// BEGIN (Handle export change): for backward compatibility, can be removed if
447+
// export_state_interfaces() method is removed
448448
void insert_state_interface(const StateInterface & state_interface)
449449
{
450450
const auto [it, success] = state_interface_map_.emplace(std::make_pair(
@@ -457,7 +457,7 @@ class ResourceStorage
457457
throw std::runtime_error(msg);
458458
}
459459
}
460-
// TODO(Manuel) END: for backward compatibility
460+
// END: for backward compatibility
461461

462462
template <class HardwareT>
463463
void import_state_interfaces(HardwareT & hardware)
@@ -468,7 +468,7 @@ class ResourceStorage
468468
// a) there is nothing to export -> on_export_state_interfaces() does return nothing as well
469469
// b) default implementation for export_state_interfaces() is used -> new functionality ->
470470
// Framework exports and creates everything
471-
if (interfaces.size() == 0)
471+
if (interfaces.empty())
472472
{
473473
std::vector<std::shared_ptr<StateInterface>> interface_ptrs =
474474
hardware.on_export_state_interfaces();
@@ -479,8 +479,8 @@ class ResourceStorage
479479
interface_names.push_back(interface->get_name());
480480
}
481481
}
482-
// TODO(Manuel) BEGIN: for backward compatibility, can be removed if export_state_interfaces()
483-
// method is removed
482+
// BEGIN (Handle export change): for backward compatibility, can be removed if
483+
// export_state_interfaces() method is removed
484484
else
485485
{
486486
interface_names.reserve(interfaces.size());
@@ -490,7 +490,7 @@ class ResourceStorage
490490
interface_names.push_back(interface.get_name());
491491
}
492492
}
493-
// TODO(Manuel) END: for backward compatibility
493+
// END: for backward compatibility
494494

495495
hardware_info_map_[hardware.get_name()].state_interfaces = interface_names;
496496
available_state_interfaces_.reserve(
@@ -510,8 +510,8 @@ class ResourceStorage
510510
}
511511
}
512512

513-
// TODO(Manuel) BEGIN: for backward compatibility, can be removed if export_command_interfaces()
514-
// method is removed
513+
// BEGIN (Handle export change): for backward compatibility, can be removed if
514+
// export_command_interfaces() method is removed
515515
void insert_command_interface(CommandInterface && command_interface)
516516
{
517517
std::string key = command_interface.get_name();
@@ -525,7 +525,7 @@ class ResourceStorage
525525
throw std::runtime_error(msg);
526526
}
527527
}
528-
// TODO(Manuel) END: for backward compatibility
528+
// END: for backward compatibility
529529

530530
template <class HardwareT>
531531
void import_command_interfaces(HardwareT & hardware)
@@ -535,21 +535,21 @@ class ResourceStorage
535535
// a) there is nothing to export -> on_export_command_interfaces() does return nothing as well
536536
// b) default implementation for export_command_interfaces() is used -> new functionality ->
537537
// Framework exports and creates everything
538-
if (interfaces.size() == 0)
538+
if (interfaces.empty())
539539
{
540540
std::vector<std::shared_ptr<CommandInterface>> interface_ptrs =
541541
hardware.on_export_command_interfaces();
542542
hardware_info_map_[hardware.get_name()].command_interfaces =
543543
add_command_interfaces(interface_ptrs);
544544
}
545-
// TODO(Manuel) BEGIN: for backward compatibility, can be removed if export_command_interfaces()
546-
// method is removed
545+
// BEGIN (Handle export change): for backward compatibility, can be removed if
546+
// export_command_interfaces() method is removed
547547
else
548548
{
549549
hardware_info_map_[hardware.get_name()].command_interfaces =
550550
add_command_interfaces(interfaces);
551551
}
552-
// TODO(Manuel) END: for backward compatibility
552+
// END: for backward compatibility
553553
}
554554

555555
/// Adds exported command interfaces into internal storage.
@@ -563,8 +563,8 @@ class ResourceStorage
563563
* \returns list of interface names that are added into internal storage. The output is used to
564564
* avoid additional iterations to cache interface names, e.g., for initializing info structures.
565565
*/
566-
// TODO(Manuel) BEGIN: for backward compatibility, can be removed if export_command_interfaces()
567-
// method is removed
566+
// BEGIN (Handle export change): for backward compatibility, can be removed if
567+
// export_command_interfaces() method is removed
568568
std::vector<std::string> add_command_interfaces(std::vector<CommandInterface> & interfaces)
569569
{
570570
std::vector<std::string> interface_names;
@@ -581,7 +581,7 @@ class ResourceStorage
581581

582582
return interface_names;
583583
}
584-
// TODO(Manuel) END: for backward compatibility
584+
// END: for backward compatibility
585585

586586
std::vector<std::string> add_command_interfaces(
587587
std::vector<std::shared_ptr<CommandInterface>> & interfaces)

0 commit comments

Comments
 (0)