No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

interface.py 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. ## @package lodel.plugin.interface Handles the Interface type plugins
  2. from lodel.plugin.plugins import Plugin
  3. from lodel.plugin.exceptions import PluginError, PluginTypeError, LodelScriptError, DatasourcePluginError
  4. from lodel.validator.validator import Validator
  5. ## @brief Global type name used in the settings of Lodel for this type of plugins
  6. _glob_typename = 'ui'
  7. ##@brief A plugin Interface
  8. #@note It's a singleton class. Only 1 interface allowed by instance.
  9. class InterfacePlugin(Plugin):
  10. ## @brief Singleton instance storage
  11. _instance = None
  12. ## @brief Settings description
  13. _plist_confspecs = {
  14. 'section': 'lodel2',
  15. 'key': 'interface',
  16. 'default': None,
  17. 'validator': Validator(
  18. 'plugin', none_is_valid = True, ptype = _glob_typename)}
  19. ## @brief plugin type name
  20. _type_conf_name = _glob_typename
  21. ##
  22. # @param name str : Name of the interface plugin
  23. # @throw PluginError if there is already an interface plugin instanciated
  24. def __init__(self, name):
  25. if InterfacePlugin._instance is not None:
  26. raise PluginError("Maximum one interface allowed")
  27. super().__init__(name)
  28. self._instance = self
  29. ## @brief Clears the singleton from its active instance
  30. # @see plugins.Plugin::clear()
  31. @classmethod
  32. def clear_cls(cls):
  33. if cls._instance is not None:
  34. inst = cls._instance
  35. cls._instance = None
  36. del(inst)