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

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