Fix C++ SendableRegistry::AddChild() (#2207)

Add a Sendable* overload so pointers to sendable objects work appropriately.
Otherwise an AddLW(this) in a child (which is a Sendable*) could be a
different pointer than a void* to the same object.

For example:
  AnalogInput constructor calls AddLW(this)
  AnalogPotentiometer constructor calls AddChild(analog input pointer)

Also add handling for the child object moving (if it's Sendable).
This commit is contained in:
Peter Johnson
2019-12-29 23:37:14 -06:00
committed by GitHub
parent d91796f8d2
commit 96348e835a
2 changed files with 23 additions and 0 deletions

View File

@@ -118,6 +118,15 @@ class SendableRegistry {
void AddLW(Sendable* sendable, const wpi::Twine& subsystem,
const wpi::Twine& name);
/**
* Adds a child object to an object. Adds the child object to the registry
* if it's not already present.
*
* @param parent parent object
* @param child child object
*/
void AddChild(Sendable* parent, Sendable* child);
/**
* Adds a child object to an object. Adds the child object to the registry
* if it's not already present.