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

getParameterValue(parameter_id)

Returns the value stored for the given parameter ID. Raises KeyError if the parameter is not defined.

getParameterRecord(parameter_id)

Returns the full BaseRecord object for the given parameter ID. Includes value, units, and original value. Raises KeyError if not defined.

getDefinedParametersKeys()

Returns a list of all parameter IDs that have been assigned a value in the container.

Validation Methods#

Method

Description

isParameterIDValid(parameter_id)

Returns True if the given parameter ID exists in parameters_classes. Raises KeyError if invalid.

isParameterDefined(parameter_id)

Returns True if a value has been assigned to the given parameter. Raises KeyError if the ID is not valid.


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.