Data Container#
A DataContainer object is a flexible container for geotechnical parameters. It ensures type-safe storage, single-definition enforcement, and observer notification for parameter values.
Each DataContainer supports only one record per parameter key.
The class is designed to be subclassed. Each subclass must define the parameters_classes dictionary, which maps string keys to their corresponding BaseParameter implementations:
parameters_classes: Dict[str, Type['BaseParameter']] = {}
Example subclass:
class ClassificationSystemDataContainer(DataContainer):
parameters_classes = {
"GSI": GSI,
"QBarton": QBarton,
"RMRB": RMRB,
"MRMR": MRMR,
}
def __init__(self):
super().__init__()
Upon subclassing, the container automatically builds its internal parameters_factories dictionary, which wraps each parameter class in a ClassRecordFactory. It also caches the available parameter keys.
Parameter Assignment#
To assign a parameter value to a container, use the setParameterValue() method:
def setParameterValue(self,
parameter_id: str,
value: Any,
notify: bool = True,
tags: Optional[List[ObserverTag]] = None) -> None
This method performs the following:
Verifies that the parameter ID is valid.
Creates a new BaseRecord using the corresponding factory.
Stores the record in parameters_values.
Notifies any observers if notify=True.
Retrieving Parameter Values#
Method |
Description |
---|---|
|
Returns the value stored for the given parameter ID. Raises |
|
Returns the full |
|
Returns a list of all parameter IDs that have been assigned a value in the container. |
Validation Methods#
Method |
Description |
---|---|
|
Returns |
|
Returns |
Design Notes#
The container implements the Observable pattern to enable reactive workflows.
Factory construction is handled during __init_subclass__, ensuring subclasses are immediately ready for use.
All parameter interaction is routed through factories to preserve consistency with BaseRecord semantics.