fuzzy_dl_owl2.fuzzydl.concept.interface.has_value_interface
An abstract base class that extends role management capabilities by incorporating a generic value attribute protected by deep copy operations to ensure state isolation.
Description
Building upon the foundation of role management, this abstract class introduces a mechanism to associate an arbitrary value with a specific role. The design prioritizes data integrity by utilizing a deep copy operation whenever the value is modified, ensuring that the internal state remains isolated from any subsequent changes to the original input object. By combining role and value attributes into a single interface, it provides a consistent structure for representing complex data relationships within the broader system. This approach allows subclasses to leverage robust encapsulation, where the stored value is effectively shielded from external side effects, which is particularly important for maintaining consistency in fuzzy logic or description logic operations.
Classes
This abstract base class extends role management capabilities by introducing a mechanism to handle a generic value alongside a role. It provides concrete implementations for initializing and accessing the value, with the setter specifically utilizing a deep copy operation to ensure that the internal state remains isolated from external modifications. By combining role and value attributes, it offers a consistent interface for objects that need to represent or manipulate specific data within a defined context. |
Module Contents
UML Class Diagram for HasValueInterface
- class HasValueInterface(role: str, value: Any)[source]
Bases:
fuzzy_dl_owl2.fuzzydl.concept.interface.has_role_interface.HasRoleInterface,abc.ABC
This abstract base class extends role management capabilities by introducing a mechanism to handle a generic value alongside a role. It provides concrete implementations for initializing and accessing the value, with the setter specifically utilizing a deep copy operation to ensure that the internal state remains isolated from external modifications. By combining role and value attributes, it offers a consistent interface for objects that need to represent or manipulate specific data within a defined context.
- Parameters:
_value (Any) – Internal storage for the value represented by the class, managed via the public property and stored as a deep copy to prevent external mutation.
- _value: Any
- property value: Any
Updates the internal state of the instance by assigning a deep copy of the provided argument to the _value attribute. This setter accepts any Python object and ensures that subsequent modifications to the original input object do not affect the stored value. Because it relies on copy.deepcopy, the operation may be computationally expensive for complex objects and will raise an error if the input cannot be deep-copied.
- Parameters:
value (Any) – The value to set. A deep copy of this object is stored internally to prevent external mutations from affecting the internal state.