xtd.core.param.manager module

module doc top

class xtd.core.param.manager.Param(p_name, p_value, p_callbacks=None)[source]

Bases: object

Object that holds an JSON-serializable value

Parameters:
  • p_name (str) – Name of the parameter
  • p_value (json-serializable) – Initial parameter value
  • p_callbacks (Optional[function]) – List of function to call whenever when the value changes Can be an array of functions or a single function

When changing value with the set() method, all registered listerners are called and if none of them raises an error, the value in stored.

New callbacks can be registered with listen

Note

Each callback must respect the following prototype : function(p_parameter, p_oldValue, p_newValue)

  • p_parameter (Param): the modified Param object
  • p_oldValue (json-serializable): parameter’s old value
  • p_newvalue (json-serializable): parameter’s new value

Callback must raise xtd.core.error.XtdError is new value is not acceptable

__init__(p_name, p_value, p_callbacks=None)[source]
listen(p_handler)[source]
get()[source]
set(p_value)[source]
__dict__ = mappingproxy({'set': <function Param.set at 0x7f20103b2510>, '__module__': 'xtd.core.param.manager', 'listen': <function Param.listen at 0x7f20103b2400>, '__weakref__': <attribute '__weakref__' of 'Param' objects>, 'get': <function Param.get at 0x7f20103b2488>, '__dict__': <attribute '__dict__' of 'Param' objects>, '__doc__': "Object that holds an JSON-serializable value\n\n Args:\n p_name (str) : Name of the parameter\n p_value (json-serializable) : Initial parameter value\n p_callbacks (Optional[function]) : List of function to call whenever when the value changes Can be an array of functions or a single function\n\n When changing value with the :meth:`set` method, all registered listerners are called\n and if none of them raises an error, the value in stored.\n\n New callbacks can be registered with :obj:`listen`\n\n Note:\n Each callback must respect the following prototype :\n ``function(p_parameter, p_oldValue, p_newValue)``\n\n - **p_parameter** (Param): the modified Param object\n - **p_oldValue** (json-serializable): parameter's old value\n - **p_newvalue** (json-serializable): parameter's new value\n\n Callback must raise :obj:`xtd.core.error.XtdError` is new value is not acceptable\n ", '__init__': <function Param.__init__ at 0x7f20103b2378>})
__module__ = 'xtd.core.param.manager'
__weakref__

list of weak references to the object (if defined)

class xtd.core.param.manager.ParamManager(p_adminDir)[source]

Bases: object

Constructor

Parameters:p_adminDir (str) – directory to dump-to/load-from synced parameters
Raises:xtd.core.error.XtdError – p_adminDir is not writable
__init__(p_adminDir)[source]

Constructor

Parameters:p_adminDir (str) – directory to dump-to/load-from synced parameters
Raises:xtd.core.error.XtdError – p_adminDir is not writable
register(p_name, p_value, p_callbacks=None, p_sync=False)[source]
register_param(p_param, p_sync=False)[source]
get_names()[source]
get_param(p_name)[source]
get(p_name)[source]
set(p_name, p_value)[source]
__dict__ = mappingproxy({'listen': <function ParamManager.listen at 0x7f20103b2b70>, '__dict__': <attribute '__dict__' of 'ParamManager' objects>, '__doc__': 'Stores in memory global parameters\n ', 'get_param': <function ParamManager.get_param at 0x7f20103b29d8>, '__init__': <function ParamManager.__init__ at 0x7f20103b2598>, 'get_names': <function ParamManager.get_names at 0x7f20103b2950>, '_write': <function ParamManager._write at 0x7f20103b2730>, 'set': <function ParamManager.set at 0x7f20103b2ae8>, '__module__': 'xtd.core.param.manager', 'register_param': <function ParamManager.register_param at 0x7f20103b28c8>, 'register': <function ParamManager.register at 0x7f20103b2840>, 'get': <function ParamManager.get at 0x7f20103b2a60>, '__weakref__': <attribute '__weakref__' of 'ParamManager' objects>, '_create_dir': <staticmethod object at 0x7f2010333550>, '_load': <function ParamManager._load at 0x7f20103b27b8>})
__module__ = 'xtd.core.param.manager'
__weakref__

list of weak references to the object (if defined)

listen(p_name, p_listener)[source]