libICEpost.src.base.BaseClass
@author: F. Ramognino <federico.ramognino@polimi.it> Last update: 12/06/2023
Attributes
Classes
Table for storing classes for run-time selection. |
|
Class wrapping useful methods for base virtual classes (e.g. run-time selector) |
Functions
|
Function used to add the TypeName a class. |
Module Contents
- libICEpost.src.base.BaseClass.Class
- libICEpost.src.base.BaseClass.BaseClassType
- libICEpost.src.base.BaseClass._add_TypeName(cls: type)[source]
Function used to add the TypeName a class.
- class libICEpost.src.base.BaseClass.SelectionTable(cls: BaseClassType)[source]
Bases:
libICEpost.src.base.Utilities.UtilitiesTable for storing classes for run-time selection.
- __type: BaseClassType
The base class to which the selection table is linked.
- __db: dict[str, type]
Database of available sub-classes in the selection table. Classes are stored through [str->type] map.
- property type: BaseClassType
The base class to which the selection table is linked.
- property db: dict[str, BaseClassType]
Database of available sub-classes in the selection table. Classes are stored through [str->type] map.
- __contains__(typeName: str) bool[source]
- typeName: str
Name of the class to look-up
Check if the selection table contains a selectable class called ‘typeName’.
- __getitem__(typeName: str) BaseClassType[source]
Get class from selection table.
- Parameters:
typeName (str) – Name of the class to get
- add(cls: type, overwrite: bool = True) None[source]
Add class to selection table
- Parameters:
cls (type) – Class to add to the selection table
overwrite (bool, optional) – Overwrite if present? Defaults to True.
- Raises:
TypeError – If the class is not derived from the base class of the selection table
- class libICEpost.src.base.BaseClass.BaseClass[source]
Bases:
libICEpost.src.base.Utilities.UtilitiesClass wrapping useful methods for base virtual classes (e.g. run-time selector)
- classmethod selectionTable() SelectionTable[source]
The run-time selection table associated to this class.
- classmethod selector(typeName: str, dictionary: dict) BaseClassType[source]
Construct an instance of a subclass of this that was added to the selection table.
- Parameters:
typeName (str) – Name of the subclass to instantiate
dictionary (dict) – Dictionary containing the data to construct the class.
- Returns:
Instance of the specific class.
- Return type:
- classmethod fromDictionary(dictionary: dict) BaseClassType[source]
- Abstractmethod:
Construct an instance of this class from a dictionary. To be overwritten by derived class.
- Parameters:
dictionary (dict) – Dictionary containing the data to construct the class.
- Returns:
Instance of the specific class.
- Return type:
- classmethod addToRuntimeSelectionTable(childClass: BaseClassType, *, overwrite: bool = True) None[source]
Add the subclass to the database of available subclasses for runtime selection.
- Parameters:
childClass (BaseClassType) – Subclass to add to the selection table
overwrite (bool, optional) – Overwrite if present? Defaults to True.