Skip to content

Commit 626412b

Browse files
committed
cleanup
1 parent 6144b74 commit 626412b

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
@@ -442,8 +442,8 @@ class ResourceStorage
442442
}
443443
}
444444

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

461461
template <class HardwareT>
462462
void import_state_interfaces(HardwareT & hardware)
@@ -467,7 +467,7 @@ class ResourceStorage
467467
// a) there is nothing to export -> on_export_state_interfaces() does return nothing as well
468468
// b) default implementation for export_state_interfaces() is used -> new functionality ->
469469
// Framework exports and creates everything
470-
if (interfaces.size() == 0)
470+
if (interfaces.empty())
471471
{
472472
std::vector<std::shared_ptr<StateInterface>> interface_ptrs =
473473
hardware.on_export_state_interfaces();
@@ -478,8 +478,8 @@ class ResourceStorage
478478
interface_names.push_back(interface->get_name());
479479
}
480480
}
481-
// TODO(Manuel) BEGIN: for backward compatibility, can be removed if export_state_interfaces()
482-
// method is removed
481+
// BEGIN (Handle export change): for backward compatibility, can be removed if
482+
// export_state_interfaces() method is removed
483483
else
484484
{
485485
interface_names.reserve(interfaces.size());
@@ -489,7 +489,7 @@ class ResourceStorage
489489
interface_names.push_back(interface.get_name());
490490
}
491491
}
492-
// TODO(Manuel) END: for backward compatibility
492+
// END: for backward compatibility
493493

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

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

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

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

581581
return interface_names;
582582
}
583-
// TODO(Manuel) END: for backward compatibility
583+
// END: for backward compatibility
584584

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

0 commit comments

Comments
 (0)