1from __future__
import annotations
3from abc
import ABC, abstractmethod
4from typing
import List, Union, TypeVar, Type
10 Simplified interface for a hierarchical key-value archive system.
12 Provides dict-like access with restricted value types:
13 - bool, int, float, str
17 @ingroup ids_peak_common_python_serialization
19 @since ids_peak_common 1.1
23 bool, int, float, str,
24 List[bool], List[int], List[float], List[str], List[
"IArchive"]
27 T = TypeVar(
"T", bound=AllowedValue)
30 def set(self, key: str, value: AllowedValue | IArchive) ->
None:
33 Stores a value under the given key.
35 @param key: Key to store the value under.
36 @param value: The value to store (restricted types only).
38 @since ids_peak_common 1.1
43 def get(self, key: str, datatype: Type[T]) -> T:
46 Retrieves the value stored under the given key.
48 @param key: Key of the value to retrieve.
49 @param datatype: The expected datatype of the value.
50 @return The stored value.
52 @since ids_peak_common 1.1
60 Retrieves the archive stored under the given key.
62 @param key: Key of the archive to retrieve.
63 @return The stored archive.
65 @since ids_peak_common 1.1
70 def has(self, key: str) -> bool:
73 Checks whether a given key exists in the archive.
75 @param key: The key to check.
76 @return True if the key exists, False otherwise.
78 @since ids_peak_common 1.1
83 def keys(self) -> List[str]:
86 Returns all keys currently stored in the archive.
90 @since ids_peak_common 1.1
98 Creates a new, empty archive instance.
100 @since ids_peak_common 1.1
Simplified interface for a hierarchical key-value archive system.
IArchive create_archive(self)
Creates a new, empty archive instance.
IArchive get_archive(self, str key)
Retrieves the archive stored under the given key.
List[str] keys(self)
Returns all keys currently stored in the archive.
T get(self, str key, Type[T] datatype)
Retrieves the value stored under the given key.
None set(self, str key, AllowedValue|IArchive value)
Stores a value under the given key.
bool has(self, str key)
Checks whether a given key exists in the archive.