WPILibC++ 2024.3.2
wpi::SendableRegistry Class Referencefinal

The SendableRegistry class is the public interface for registering sensors and actuators for use on dashboards and LiveWindow. More...

#include <wpi/sendable/SendableRegistry.h>

Classes

struct  CallbackData
 Data passed to ForeachLiveWindow() callback function. More...
 

Public Types

using UID = size_t
 

Public Member Functions

 SendableRegistry ()=delete
 

Static Public Member Functions

static void SetLiveWindowBuilderFactory (std::function< std::unique_ptr< SendableBuilder >()> factory)
 Sets the factory for LiveWindow builders. More...
 
static void Add (Sendable *sendable, std::string_view name)
 Adds an object to the registry. More...
 
static void Add (Sendable *sendable, std::string_view moduleType, int channel)
 Adds an object to the registry. More...
 
static void Add (Sendable *sendable, std::string_view moduleType, int moduleNumber, int channel)
 Adds an object to the registry. More...
 
static void Add (Sendable *sendable, std::string_view subsystem, std::string_view name)
 Adds an object to the registry. More...
 
static void AddLW (Sendable *sendable, std::string_view name)
 Adds an object to the registry and LiveWindow. More...
 
static void AddLW (Sendable *sendable, std::string_view moduleType, int channel)
 Adds an object to the registry and LiveWindow. More...
 
static void AddLW (Sendable *sendable, std::string_view moduleType, int moduleNumber, int channel)
 Adds an object to the registry and LiveWindow. More...
 
static void AddLW (Sendable *sendable, std::string_view subsystem, std::string_view name)
 Adds an object to the registry and LiveWindow. More...
 
static void AddChild (Sendable *parent, Sendable *child)
 Adds a child object to an object. More...
 
static void AddChild (Sendable *parent, void *child)
 Adds a child object to an object. More...
 
static bool Remove (Sendable *sendable)
 Removes an object from the registry. More...
 
static void Move (Sendable *to, Sendable *from)
 Moves an object in the registry (for use in move constructors/assignments). More...
 
static bool Contains (const Sendable *sendable)
 Determines if an object is in the registry. More...
 
static std::string GetName (const Sendable *sendable)
 Gets the name of an object. More...
 
static void SetName (Sendable *sendable, std::string_view name)
 Sets the name of an object. More...
 
static void SetName (Sendable *sendable, std::string_view moduleType, int channel)
 Sets the name of an object with a channel number. More...
 
static void SetName (Sendable *sendable, std::string_view moduleType, int moduleNumber, int channel)
 Sets the name of an object with a module and channel number. More...
 
static void SetName (Sendable *sendable, std::string_view subsystem, std::string_view name)
 Sets both the subsystem name and device name of an object. More...
 
static std::string GetSubsystem (const Sendable *sendable)
 Gets the subsystem name of an object. More...
 
static void SetSubsystem (Sendable *sendable, std::string_view subsystem)
 Sets the subsystem name of an object. More...
 
static int GetDataHandle ()
 Gets a unique handle for setting/getting data with SetData() and GetData(). More...
 
static std::shared_ptr< void > SetData (Sendable *sendable, int handle, std::shared_ptr< void > data)
 Associates arbitrary data with an object in the registry. More...
 
static std::shared_ptr< void > GetData (Sendable *sendable, int handle)
 Gets arbitrary data associated with an object in the registry. More...
 
static void EnableLiveWindow (Sendable *sendable)
 Enables LiveWindow for an object. More...
 
static void DisableLiveWindow (Sendable *sendable)
 Disables LiveWindow for an object. More...
 
static UID GetUniqueId (Sendable *sendable)
 Get unique id for an object. More...
 
static SendableGetSendable (UID uid)
 Get sendable object for a given unique id. More...
 
static void Publish (UID sendableUid, std::unique_ptr< SendableBuilder > builder)
 Publishes an object in the registry. More...
 
static void Update (UID sendableUid)
 Updates published information from an object. More...
 
static void ForeachLiveWindow (int dataHandle, wpi::function_ref< void(CallbackData &cbdata)> callback)
 Iterates over LiveWindow-enabled objects in the registry. More...
 

Detailed Description

The SendableRegistry class is the public interface for registering sensors and actuators for use on dashboards and LiveWindow.

Member Typedef Documentation

◆ UID

Constructor & Destructor Documentation

◆ SendableRegistry()

wpi::SendableRegistry::SendableRegistry ( )
delete

Member Function Documentation

◆ Add() [1/4]

static void wpi::SendableRegistry::Add ( Sendable sendable,
std::string_view  moduleType,
int  channel 
)
static

Adds an object to the registry.

Parameters
sendableobject to add
moduleTypeA string that defines the module name in the label for the value
channelThe channel number the device is plugged into

◆ Add() [2/4]

static void wpi::SendableRegistry::Add ( Sendable sendable,
std::string_view  moduleType,
int  moduleNumber,
int  channel 
)
static

Adds an object to the registry.

Parameters
sendableobject to add
moduleTypeA string that defines the module name in the label for the value
moduleNumberThe number of the particular module type
channelThe channel number the device is plugged into

◆ Add() [3/4]

static void wpi::SendableRegistry::Add ( Sendable sendable,
std::string_view  name 
)
static

Adds an object to the registry.

Parameters
sendableobject to add
namecomponent name

◆ Add() [4/4]

static void wpi::SendableRegistry::Add ( Sendable sendable,
std::string_view  subsystem,
std::string_view  name 
)
static

Adds an object to the registry.

Parameters
sendableobject to add
subsystemsubsystem name
namecomponent name

◆ AddChild() [1/2]

static void wpi::SendableRegistry::AddChild ( Sendable parent,
Sendable child 
)
static

Adds a child object to an object.

Adds the child object to the registry if it's not already present.

Parameters
parentparent object
childchild object

◆ AddChild() [2/2]

static void wpi::SendableRegistry::AddChild ( Sendable parent,
void *  child 
)
static

Adds a child object to an object.

Adds the child object to the registry if it's not already present.

Parameters
parentparent object
childchild object

◆ AddLW() [1/4]

static void wpi::SendableRegistry::AddLW ( Sendable sendable,
std::string_view  moduleType,
int  channel 
)
static

Adds an object to the registry and LiveWindow.

Parameters
sendableobject to add
moduleTypeA string that defines the module name in the label for the value
channelThe channel number the device is plugged into

◆ AddLW() [2/4]

static void wpi::SendableRegistry::AddLW ( Sendable sendable,
std::string_view  moduleType,
int  moduleNumber,
int  channel 
)
static

Adds an object to the registry and LiveWindow.

Parameters
sendableobject to add
moduleTypeA string that defines the module name in the label for the value
moduleNumberThe number of the particular module type
channelThe channel number the device is plugged into

◆ AddLW() [3/4]

static void wpi::SendableRegistry::AddLW ( Sendable sendable,
std::string_view  name 
)
static

Adds an object to the registry and LiveWindow.

Parameters
sendableobject to add
namecomponent name

◆ AddLW() [4/4]

static void wpi::SendableRegistry::AddLW ( Sendable sendable,
std::string_view  subsystem,
std::string_view  name 
)
static

Adds an object to the registry and LiveWindow.

Parameters
sendableobject to add
subsystemsubsystem name
namecomponent name

◆ Contains()

static bool wpi::SendableRegistry::Contains ( const Sendable sendable)
static

Determines if an object is in the registry.

Parameters
sendableobject to check
Returns
True if in registry, false if not.

◆ DisableLiveWindow()

static void wpi::SendableRegistry::DisableLiveWindow ( Sendable sendable)
static

Disables LiveWindow for an object.

Parameters
sendableobject

◆ EnableLiveWindow()

static void wpi::SendableRegistry::EnableLiveWindow ( Sendable sendable)
static

Enables LiveWindow for an object.

Parameters
sendableobject

◆ ForeachLiveWindow()

static void wpi::SendableRegistry::ForeachLiveWindow ( int  dataHandle,
wpi::function_ref< void(CallbackData &cbdata)>  callback 
)
static

Iterates over LiveWindow-enabled objects in the registry.

It is not safe to call other SendableRegistry functions from the callback (this will likely deadlock).

Parameters
dataHandledata handle to get data pointer passed to callback
callbackfunction to call for each object

◆ GetData()

static std::shared_ptr< void > wpi::SendableRegistry::GetData ( Sendable sendable,
int  handle 
)
static

Gets arbitrary data associated with an object in the registry.

Parameters
sendableobject
handledata handle returned by GetDataHandle()
Returns
data (may be null if none associated)

◆ GetDataHandle()

static int wpi::SendableRegistry::GetDataHandle ( )
static

Gets a unique handle for setting/getting data with SetData() and GetData().

Returns
Handle

◆ GetName()

static std::string wpi::SendableRegistry::GetName ( const Sendable sendable)
static

Gets the name of an object.

Parameters
sendableobject
Returns
Name (empty if object is not in registry)

◆ GetSendable()

static Sendable * wpi::SendableRegistry::GetSendable ( UID  uid)
static

Get sendable object for a given unique id.

Parameters
uidunique id
Returns
sendable object (may be null)

◆ GetSubsystem()

static std::string wpi::SendableRegistry::GetSubsystem ( const Sendable sendable)
static

Gets the subsystem name of an object.

Parameters
sendableobject
Returns
Subsystem name (empty if object is not in registry)

◆ GetUniqueId()

static UID wpi::SendableRegistry::GetUniqueId ( Sendable sendable)
static

Get unique id for an object.

Since objects can move, use this instead of storing Sendable* directly if ownership is in question.

Parameters
sendableobject
Returns
unique id

◆ Move()

static void wpi::SendableRegistry::Move ( Sendable to,
Sendable from 
)
static

Moves an object in the registry (for use in move constructors/assignments).

Parameters
tonew object
fromold object

◆ Publish()

static void wpi::SendableRegistry::Publish ( UID  sendableUid,
std::unique_ptr< SendableBuilder builder 
)
static

Publishes an object in the registry.

Parameters
sendableUidsendable unique id
builderpublisher backend

◆ Remove()

static bool wpi::SendableRegistry::Remove ( Sendable sendable)
static

Removes an object from the registry.

Parameters
sendableobject to remove
Returns
true if the object was removed; false if it was not present

◆ SetData()

static std::shared_ptr< void > wpi::SendableRegistry::SetData ( Sendable sendable,
int  handle,
std::shared_ptr< void >  data 
)
static

Associates arbitrary data with an object in the registry.

Parameters
sendableobject
handledata handle returned by GetDataHandle()
datadata to set
Returns
Previous data (may be null)

◆ SetLiveWindowBuilderFactory()

static void wpi::SendableRegistry::SetLiveWindowBuilderFactory ( std::function< std::unique_ptr< SendableBuilder >()>  factory)
static

Sets the factory for LiveWindow builders.

Parameters
factoryfactory function

◆ SetName() [1/4]

static void wpi::SendableRegistry::SetName ( Sendable sendable,
std::string_view  moduleType,
int  channel 
)
static

Sets the name of an object with a channel number.

Parameters
sendableobject
moduleTypeA string that defines the module name in the label for the value
channelThe channel number the device is plugged into

◆ SetName() [2/4]

static void wpi::SendableRegistry::SetName ( Sendable sendable,
std::string_view  moduleType,
int  moduleNumber,
int  channel 
)
static

Sets the name of an object with a module and channel number.

Parameters
sendableobject
moduleTypeA string that defines the module name in the label for the value
moduleNumberThe number of the particular module type
channelThe channel number the device is plugged into

◆ SetName() [3/4]

static void wpi::SendableRegistry::SetName ( Sendable sendable,
std::string_view  name 
)
static

Sets the name of an object.

Parameters
sendableobject
namename

◆ SetName() [4/4]

static void wpi::SendableRegistry::SetName ( Sendable sendable,
std::string_view  subsystem,
std::string_view  name 
)
static

Sets both the subsystem name and device name of an object.

Parameters
sendableobject
subsystemsubsystem name
namedevice name

◆ SetSubsystem()

static void wpi::SendableRegistry::SetSubsystem ( Sendable sendable,
std::string_view  subsystem 
)
static

Sets the subsystem name of an object.

Parameters
sendableobject
subsystemsubsystem name

◆ Update()

static void wpi::SendableRegistry::Update ( UID  sendableUid)
static

Updates published information from an object.

Parameters
sendableUidsendable unique id

The documentation for this class was generated from the following file: