libICEpost.src.base.BaseClass ============================= .. py:module:: libICEpost.src.base.BaseClass .. autoapi-nested-parse:: @author: F. Ramognino Last update: 12/06/2023 Attributes ---------- .. autoapisummary:: libICEpost.src.base.BaseClass.Class libICEpost.src.base.BaseClass.BaseClassType Classes ------- .. autoapisummary:: libICEpost.src.base.BaseClass.SelectionTable libICEpost.src.base.BaseClass.BaseClass Functions --------- .. autoapisummary:: libICEpost.src.base.BaseClass._add_TypeName Module Contents --------------- .. py:data:: Class .. py:data:: BaseClassType .. py:function:: _add_TypeName(cls: type) Function used to add the TypeName a class. .. py:class:: SelectionTable(cls: BaseClassType) Bases: :py:obj:`libICEpost.src.base.Utilities.Utilities` Table for storing classes for run-time selection. .. py:attribute:: __type :type: BaseClassType The base class to which the selection table is linked. .. py:attribute:: __db :type: dict[str, type] Database of available sub-classes in the selection table. Classes are stored through [str->type] map. .. py:property:: type :type: BaseClassType The base class to which the selection table is linked. .. py:property:: db :type: dict[str, BaseClassType] Database of available sub-classes in the selection table. Classes are stored through [str->type] map. .. py:method:: __str__() Printing selection table .. py:method:: __repr__() Representation of selection table .. py:method:: __contains__(typeName: str) -> bool typeName: str Name of the class to look-up Check if the selection table contains a selectable class called 'typeName'. .. py:method:: __getitem__(typeName: str) -> BaseClassType Get class from selection table. :param typeName: Name of the class to get :type typeName: str .. py:method:: add(cls: type, overwrite: bool = True) -> None Add class to selection table :param cls: Class to add to the selection table :type cls: type :param overwrite: Overwrite if present? Defaults to True. :type overwrite: bool, optional :raises TypeError: If the class is not derived from the base class of the selection table .. py:method:: check(typeName: str) -> bool Checks if a class name is in the selection table. :param typeName: Name of the class to check :type typeName: str :returns: True if the class is in the selection table :rtype: bool :raises ValueError: If the class is not in the selection table .. py:class:: BaseClass Bases: :py:obj:`libICEpost.src.base.Utilities.Utilities` Class wrapping useful methods for base virtual classes (e.g. run-time selector) .. py:method:: selectionTable() -> SelectionTable :classmethod: The run-time selection table associated to this class. .. py:method:: selector(typeName: str, dictionary: dict) -> BaseClassType :classmethod: Construct an instance of a subclass of this that was added to the selection table. :param typeName: Name of the subclass to instantiate :type typeName: str :param dictionary: Dictionary containing the data to construct the class. :type dictionary: dict :returns: Instance of the specific class. :rtype: BaseClassType .. py:method:: hasSelectionTable() -> bool :classmethod: Check if selection table was defined for this class. .. py:method:: fromDictionary(dictionary: dict) -> BaseClassType :classmethod: :abstractmethod: Construct an instance of this class from a dictionary. To be overwritten by derived class. :param dictionary: Dictionary containing the data to construct the class. :type dictionary: dict :returns: Instance of the specific class. :rtype: BaseClassType .. py:method:: addToRuntimeSelectionTable(childClass: BaseClassType, *, overwrite: bool = True) -> None :classmethod: Add the subclass to the database of available subclasses for runtime selection. :param childClass: Subclass to add to the selection table :type childClass: BaseClassType :param overwrite: Overwrite if present? Defaults to True. :type overwrite: bool, optional .. py:method:: createRuntimeSelectionTable() -> None :classmethod: Create the runtime selection table, initializing the property 'selectionTable' of the class. .. py:method:: showRuntimeSelectionTable() -> None :classmethod: Prints a list of the available classes in the selection table and if they are instantiable. .. rubric:: Example Available classes in selection table: ClassA (Abstract class) ClassB ClassC