# `SharedDataManager`

digraph inheritancef82b5e3fe4 { bgcolor=transparent; rankdir=UD; ratio=compress; size="8.0, 12.0"; "QObject" [color=dodgerblue1,fillcolor=white,fontcolor=black,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.5,shape=box,style=rounded,tooltip="QObject(parent: QObject|None = None)"]; "wrapper" -> "QObject" [arrowsize=0.5,style="setlinewidth(0.5)"]; "SharedDataManager" [URL="#taurus.qt.qtcore.communication.SharedDataManager",color=dodgerblue1,fillcolor=white,fontcolor=black,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.5,shape=box,style=rounded,target="_top",tooltip="A Factory of :class:`DataModel` objects. The :meth:`__getDataModel` method"]; "QObject" -> "SharedDataManager" [arrowsize=0.5,style="setlinewidth(0.5)"]; "simplewrapper" [color=dodgerblue1,fillcolor=white,fontcolor=black,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.5,shape=box,style=rounded]; "wrapper" [color=dodgerblue1,fillcolor=white,fontcolor=black,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.5,shape=box,style=rounded]; "simplewrapper" -> "wrapper" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

class SharedDataManager(parent)

  A Factory of `DataModel` objects. The `__getDataModel()` method ensures that the created DataModels are singletons. DataModels are not kept alive unless there at least some Reader or Writer registered to it (or another object referencing them)

  Import from `taurus.qt.qtcore.communication` as:

      from taurus.qt.qtcore.communication import SharedDataManager

  activeDataUIDs()

    Returns a list of currently shared data. Note that this list only reflects the situation at the moment of calling this method: a given DataModel may die at any moment if there are no references to it.

    Returns:

      UIDs of currently shared data.

    Return type:

      list<str>

  connectReader(dataUID, slot, readOnConnect=True)

    Registers the given slot method to receive notifications whenever the data identified by dataUID is changed.

    Note that it returns the `DataModel.getData()` method for the given data UID, which can be used for reading the data at any moment.

    Parameters:

      - dataUID (str) – the unique identifier of the data

      - slot (callable) – a method that will be called when the data changes this slot will be the receiver of a signal which has the data as its first argument.

      - readOnConnect (bool) – if True (default) the slot will be called immediately with the current value of the data if the data has been already initialized

    Returns:

      a callable that can be used for reading the data

    Return type:

      callable

    See also

    `connectWriter()`, `__getDataModel()`

  connectWriter(dataUID, writer, signalname)

    Registers the given writer object as a changer of the shared data identified by dataUID. The writer is then expected to emit a QtCore.SIGNAL(signalname) with the new data as the first parameter

    Note that it returns the `DataModel.setData()` method for the given data UID, which can be used for changing the data at any moment.

    Parameters:

      - dataUID (str) – the unique identifier of the data

      - writer (QObject) – object that will change the data

      - signalname (str) – the signal name that will notify changes of the data

    Returns:

      a callable that can be used for setting the data. When using it, one parameter has to be passed containing the new data

    Return type:

      callable

    See also

    `connectWriter()`, `__getDataModel()`

  debugReader(data)

    A slot which you can connect as a reader for debugging. It will print info to the stdout

  disconnectReader(dataUID, slot)

    Unregister the given method as data receiver

    Parameters:

      - dataUID (str) – the unique identifier of the data

      - slot (str) – the slot that was registered

    See also

    `DataModel.disconnectReader()`

  disconnectWriter(dataUID, writer, signalname)

    Unregister the given object as writer of the shared data

    Parameters:

      - dataUID (str) – the unique identifier of the data

      - writer (QObject) – object to unregister

      - signalname (str) – the signal that was registered

    See also

    `DataModel.disconnectWriter()`

  getDataModelProxy(dataUID, callback=None)

    Returns a `weakref.proxy` to a `DataModel` object for the given data UID or None if the UID is not registered.

    Note

    The underlying `DataModel` object may cease to exist if all its readers and writers are unregistered.

    Parameters:

      - dataUID (str) – the unique identifier of the data

      - callback (callable) – same as in `weakref.ref` callback parameter

    Returns:

    Return type:

      weakref.proxy or None

    See also

    `connectReader()`, `connectWriter()`, `DataModel`

  info()