Python YASMIN (Yet Another State MachINe)
|
Public Member Functions | |
None | __init__ (self, Dict[str, Any] init=None) |
Any | __getitem__ (self, str key) |
None | __setitem__ (self, str key, Any value) |
None | __delitem__ (self, str key) |
bool | __contains__ (self, str key) |
int | __len__ (self) |
str | __repr__ (self) |
Protected Attributes | |
dict | _data = {} |
A dictionary holding the data stored in the blackboard. | |
Private Attributes | |
Lock | __lock = Lock() |
A threading lock to ensure thread-safe access to the _data attribute. | |
A thread-safe blackboard for storing key-value pairs. The Blackboard class provides a mechanism to store data in a dictionary-like format, allowing for concurrent access and modification through thread-safe operations. Attributes: _data (Dict[str, Any]): A dictionary holding the data stored in the blackboard. __lock (Lock): A threading lock to ensure thread-safe access to the _data attribute. Methods: __getitem__(key): Retrieve a value associated with the given key. __setitem__(key, value): Set a value for the given key. __delitem__(key): Remove the value associated with the given key. __contains__(key): Check if a key exists in the blackboard. __len__(): Return the number of items in the blackboard. __repr__(): Return a string representation of the blackboard's data.
None yasmin.blackboard.Blackboard.__init__ | ( | self, | |
Dict[str, Any] | init = None ) |
Initializes the Blackboard with an optional initial dictionary. Args: init (Dict[str, Any], optional): A dictionary to initialize the blackboard with. If None, the blackboard starts empty. Raises: None
bool yasmin.blackboard.Blackboard.__contains__ | ( | self, | |
str | key ) |
Checks if a specified key exists in the blackboard. Args: key (str): The key to check for existence. Returns: bool: True if the key exists, False otherwise. Raises: None
None yasmin.blackboard.Blackboard.__delitem__ | ( | self, | |
str | key ) |
Removes the value associated with the specified key from the blackboard. Args: key (str): The key to be removed. Returns: None Raises: KeyError: If the key is not found in the blackboard.
Any yasmin.blackboard.Blackboard.__getitem__ | ( | self, | |
str | key ) |
Retrieves a value from the blackboard associated with the specified key. Args: key (str): The key whose value needs to be retrieved. Returns: Any: The value associated with the key. Raises: KeyError: If the key is not found in the blackboard.
int yasmin.blackboard.Blackboard.__len__ | ( | self | ) |
Returns the number of items stored in the blackboard. Returns: int: The count of items in the blackboard. Raises: None
str yasmin.blackboard.Blackboard.__repr__ | ( | self | ) |
Returns a string representation of the blackboard's data. Returns: str: A string representation of the current state of the blackboard. Raises: None
None yasmin.blackboard.Blackboard.__setitem__ | ( | self, | |
str | key, | ||
Any | value ) |
Sets a value in the blackboard for the specified key. Args: key (str): The key to associate with the value. value (Any): The value to be stored in the blackboard. Returns: None Raises: None
|
private |
A threading lock to ensure thread-safe access to the _data attribute.
|
protected |
A dictionary holding the data stored in the blackboard.