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({'get': <function Param.get at 0x7f0b92320488>, '__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 ", '__dict__': <attribute '__dict__' of 'Param' objects>, '__weakref__': <attribute '__weakref__' of 'Param' objects>, '__init__': <function Param.__init__ at 0x7f0b92320378>, 'set': <function Param.set at 0x7f0b92320510>, '__module__': 'xtd.core.param.manager', 'listen': <function Param.listen at 0x7f0b92320400>})
__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({'get': <function ParamManager.get at 0x7f0b92320a60>, 'get_names': <function ParamManager.get_names at 0x7f0b92320950>, 'register': <function ParamManager.register at 0x7f0b92320840>, '__init__': <function ParamManager.__init__ at 0x7f0b92320598>, '_load': <function ParamManager._load at 0x7f0b923207b8>, 'set': <function ParamManager.set at 0x7f0b92320ae8>, 'get_param': <function ParamManager.get_param at 0x7f0b923209d8>, 'listen': <function ParamManager.listen at 0x7f0b92320b70>, '__weakref__': <attribute '__weakref__' of 'ParamManager' objects>, '_create_dir': <staticmethod object at 0x7f0b92332518>, '__dict__': <attribute '__dict__' of 'ParamManager' objects>, '_write': <function ParamManager._write at 0x7f0b92320730>, '__module__': 'xtd.core.param.manager', '__doc__': 'Stores in memory global parameters\n ', 'register_param': <function ParamManager.register_param at 0x7f0b923208c8>})
__module__ = 'xtd.core.param.manager'
__weakref__

list of weak references to the object (if defined)

listen(p_name, p_listener)[source]