bec_widgets.cli.rpc.rpc_register#

Classes#

RPCRegister

A singleton class that keeps track of all the RPC objects registered in the system for CLI usage.

RPCRegisterBroadcast

Context manager for RPCRegister broadcast.

Functions#

broadcast_update(func)

Decorator to broadcast updates to the RPCRegister whenever a new RPC object is added or removed.

Module Contents#

class RPCRegister#

A singleton class that keeps track of all the RPC objects registered in the system for CLI usage.

add_callback(callback: Callable[[dict], None])#

Add a callback that will be called whenever the registry is updated.

Parameters:
  • callback (Callable[[dict], None]) – The callback to be added. It should accept a dictionary of all the

  • argument. (registered RPC objects as an)

add_rpc(rpc: bec_widgets.utils.bec_connector.BECConnector)#

Add an RPC object to the register.

Parameters:

rpc (QObject) – The RPC object to be added to the register.

broadcast()#

Broadcast the update to all the callbacks.

classmethod delayed_broadcast()#

Delay the broadcast of the update to all the callbacks.

get_names_of_rpc_by_class_type(cls: type[bec_widgets.utils.bec_widget.BECWidget] | type[bec_widgets.utils.bec_connector.BECConnector]) list[str]#

Get all the names of the widgets.

Parameters:

cls (BECWidget | BECConnector) – The class of the RPC object to be retrieved.

get_rpc_by_id(gui_id: str) qtpy.QtCore.QObject | None#

Get an RPC object by its ID.

Parameters:

gui_id (str) – The ID of the RPC object to be retrieved.

Returns:

The RPC object with the given ID or None

Return type:

QObject | None

list_all_connections() dict#

List all the registered RPC objects.

Returns:

A dictionary containing all the registered RPC objects.

Return type:

dict

object_is_registered(obj: bec_widgets.utils.bec_connector.BECConnector) bool#

Check if an object is registered in the RPC register.

Parameters:

obj (QObject) – The object to check.

Returns:

True if the object is registered, False otherwise.

Return type:

bool

remove_rpc(rpc: bec_widgets.utils.bec_connector.BECConnector)#

Remove an RPC object from the register.

Parameters:

rpc (str) – The RPC object to be removed from the register.

classmethod reset_singleton()#

Reset the singleton instance.

callbacks = []#
class RPCRegisterBroadcast(rpc_register: RPCRegister)#

Context manager for RPCRegister broadcast.

__enter__()#

Enter the context manager

__exit__(*exc)#

Exit the context manager

rpc_register#
broadcast_update(func)#

Decorator to broadcast updates to the RPCRegister whenever a new RPC object is added or removed. If class attribute _skip_broadcast is set to True, the broadcast will be skipped