Uranium
Application Framework
Loading...
Searching...
No Matches
UM.Settings.InstanceContainer.InstanceContainer Class Reference
Inheritance diagram for UM.Settings.InstanceContainer.InstanceContainer:
UM.Settings.Interfaces.ContainerInterface UM.PluginObject.PluginObject

Public Member Functions

None __init__ (self, str container_id, QObject parent=None, *Any args, **Any kwargs)
 
int __hash__ (self)
 
"InstanceContainer" __deepcopy__ (self, Dict[int, object] memo)
 
bool __eq__ (self, object other)
 
bool __ne__ (self, object other)
 
Tuple[str] __getnewargs__ (self)
 
Dict[str, Any] __getstate__ (self)
 
None __setstate__ (self, Dict[str, Any] state)
 
str getId (self)
 
None setCachedValues (self, Dict[str, Any] cached_values)
 
int getLoadingPriority (cls)
 
str getPath (self)
 
None setPath (self, str path)
 
str getName (self)
 
None setName (self, str name)
 
bool getReadOnly (self)
 
int getNumInstances (self)
 
Dict[str, Any] getMetaData (self)
 
None setMetaData (self, Dict[str, Any] metadata)
 
Any getMetaDataEntry (self, str entry, default=None)
 
None setMetaDataEntry (self, str key, Any value)
 
bool isDirty (self)
 Check if this container is dirty, that is, if it changed from deserialization.
 
None setDirty (self, bool dirty)
 
Any getProperty (self, str key, str property_name, PropertyEvaluationContext context=None)
 
bool hasProperty (self, str key, str property_name)
 
None setProperty (self, str key, str property_name, Any property_value, ContainerInterface container=None, bool set_from_cache=False)
 
None clear (self)
 
Set[str] getAllKeys (self)
 
"InstanceContainer" duplicate (self, str new_id, str new_name=None)
 
str serialize (self, Optional[Set[str]] ignored_metadata_keys=None)
 
Optional[str] getConfigurationTypeFromSerialized (cls, str serialized)
 
int getVersionFromSerialized (cls, str serialised)
 
str deserialize (self, str serialized, Optional[str] file_name=None)
 
List[Dict[str, Any]] deserializeMetadata (cls, str serialized, str container_id)
 Gets the metadata of an instance container from a serialised format.
 
List[SettingInstancefindInstances (self, **Any kwargs)
 
Optional[SettingInstancegetInstance (self, str key)
 Get an instance by key.
 
None addInstance (self, SettingInstance instance)
 Add a new instance to this container.
 
None removeInstance (self, str key, bool postpone_emit=False)
 
None update (self)
 Update all instances from this container.
 
DefinitionContainerInterface getDefinition (self)
 Get the DefinitionContainer used for new instance creation.
 
None setDefinition (self, str definition_id)
 
bool __lt__ (self, object other)
 
str __str__ (self)
 
str __repr__ (self)
 
None sendPostponedEmits (self)
 
- Public Member Functions inherited from UM.PluginObject.PluginObject
None setPluginId (self, str plugin_id)
 
str getPluginId (self)
 
None setVersion (self, str version)
 
str getVersion (self)
 

Public Attributes

 Version
 

Static Public Attributes

int Version = 4
 
 version_regex = re.compile(r"\nversion ?= ?(\d+)")
 
 setting_version_regex = re.compile(r"\nsetting_version ?= ?(\d+)")
 
 type_regex = re.compile(r"\ntype ?= ?(\w+)")
 
 id = pyqtProperty(str, fget = getId, constant = True)
 
 pyqtNameChanged = pyqtSignal()
 
 nameChanged = Signal()
 
 name = pyqtProperty(str, fget = getName, fset = setName, notify = pyqtNameChanged)
 
 readOnly = pyqtProperty(bool, fget = getReadOnly)
 
 metaDataChanged = pyqtSignal(QObject)
 
 metaData = pyqtProperty("QVariantMap", fget = getMetaData, fset = setMetaData, notify = metaDataChanged)
 
 propertyChanged = Signal()
 
- Static Public Attributes inherited from UM.Settings.Interfaces.ContainerInterface
 propertyChanged = None
 
 metaDataChanged = None
 

Protected Member Functions

None _instantiateMissingSettingInstancesInCache (self)
 
FastConfigParser _readAndValidateSerialized (cls, str serialized)
 
bool _trustHook (self, Optional[str] file_name)
 
None _instantiateCachedValues (self)
 
- Protected Member Functions inherited from UM.Settings.Interfaces.ContainerInterface
str _updateSerialized (cls, str serialized, Optional[str] file_name=None)
 

Protected Attributes

 _metadata
 
 _instances
 
 _read_only
 
 _dirty
 
 _path
 
 _postponed_emits
 
 _definition
 
 _cached_values
 
- Protected Attributes inherited from UM.PluginObject.PluginObject
 _plugin_id
 
 _version
 
 _metadata
 
 _name
 

Detailed Description

A container for SettingInstance objects.

Constructor & Destructor Documentation

◆ __init__()

None UM.Settings.InstanceContainer.InstanceContainer.__init__ ( self,
str container_id,
QObject parent = None,
*Any args,
**Any kwargs )
Constructor

:param container_id: A unique, machine readable/writable ID for this container.

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

Member Function Documentation

◆ __getnewargs__()

Tuple[str] UM.Settings.InstanceContainer.InstanceContainer.__getnewargs__ ( self)
For pickle support

◆ __getstate__()

Dict[str, Any] UM.Settings.InstanceContainer.InstanceContainer.__getstate__ ( self)
For pickle support

◆ __setstate__()

None UM.Settings.InstanceContainer.InstanceContainer.__setstate__ ( self,
Dict[str, Any] state )
For pickle support

◆ __str__()

str UM.Settings.InstanceContainer.InstanceContainer.__str__ ( self)
Simple string representation for debugging.

◆ _instantiateCachedValues()

None UM.Settings.InstanceContainer.InstanceContainer._instantiateCachedValues ( self)
protected
Instance containers are lazy loaded. This function ensures that it happened.

◆ _instantiateMissingSettingInstancesInCache()

None UM.Settings.InstanceContainer.InstanceContainer._instantiateMissingSettingInstancesInCache ( self)
protected
Creates SettingInstances that are missing in this InstanceContainer from the cache if any.
This function will **ONLY instantiate SettingInstances. The cached values will not be applied.**

◆ _trustHook()

bool UM.Settings.InstanceContainer.InstanceContainer._trustHook ( self,
Optional[str] file_name )
protected

◆ clear()

None UM.Settings.InstanceContainer.InstanceContainer.clear ( self)
Remove all instances from this container.

◆ deserialize()

str UM.Settings.InstanceContainer.InstanceContainer.deserialize ( self,
str serialized,
Optional[str] file_name = None )
:copydoc ContainerInterface::deserialize

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ deserializeMetadata()

List[Dict[str, Any]] UM.Settings.InstanceContainer.InstanceContainer.deserializeMetadata ( cls,
str serialized,
str container_id )

Gets the metadata of an instance container from a serialised format.

This parses the entire CFG document and only extracts the metadata from it.

Parameters
serializedA CFG document, serialised as a string.
container_idThe ID of the container to get the metadata of, as obtained from the file name.
Returns
A dictionary of metadata that was in the CFG document in a singleton list. If anything went wrong, this returns an empty list instead.

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ duplicate()

"InstanceContainer" UM.Settings.InstanceContainer.InstanceContainer.duplicate ( self,
str new_id,
str new_name = None )
Create a new InstanceContainer with the same contents as this container

:param new_id: The new ID of the container
:param new_name: The new name of the container. Defaults to None to indicate the name should not change.

:return: A new InstanceContainer with the same contents as this container.

◆ findInstances()

List[SettingInstance] UM.Settings.InstanceContainer.InstanceContainer.findInstances ( self,
**Any kwargs )
Find instances matching certain criteria.

:param kwargs: A dictionary of keyword arguments with key-value pairs that should match properties of the instances.

◆ getAllKeys()

Set[str] UM.Settings.InstanceContainer.InstanceContainer.getAllKeys ( self)
Get all the keys of the instances of this container
:returns: list of keys

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getConfigurationTypeFromSerialized()

Optional[str] UM.Settings.InstanceContainer.InstanceContainer.getConfigurationTypeFromSerialized ( cls,
str serialized )
Gets the configuration type of the given serialized data. (used by __updateSerialized())

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getId()

str UM.Settings.InstanceContainer.InstanceContainer.getId ( self)
:copydoc ContainerInterface::getId

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getLoadingPriority()

int UM.Settings.InstanceContainer.InstanceContainer.getLoadingPriority ( cls)

◆ getMetaData()

Dict[str, Any] UM.Settings.InstanceContainer.InstanceContainer.getMetaData ( self)
:copydoc ContainerInterface::getMetaData

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getMetaDataEntry()

Any UM.Settings.InstanceContainer.InstanceContainer.getMetaDataEntry ( self,
str entry,
default = None )
:copydoc ContainerInterface::getMetaDataEntry

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getName()

str UM.Settings.InstanceContainer.InstanceContainer.getName ( self)
:copydoc ContainerInterface::getName

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getPath()

str UM.Settings.InstanceContainer.InstanceContainer.getPath ( self)
:copydoc ContainerInterface::getPath.

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getProperty()

Any UM.Settings.InstanceContainer.InstanceContainer.getProperty ( self,
str key,
str property_name,
PropertyEvaluationContext context = None )
:copydoc ContainerInterface::getProperty

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getVersionFromSerialized()

int UM.Settings.InstanceContainer.InstanceContainer.getVersionFromSerialized ( cls,
str serialised )
Gets the version number from a config file.

In all config files that concern this version upgrade, the version number is stored in general/version, so get
the data from that key.

:param serialised: The contents of a config file.
:return: The version number of that config file.

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ hasProperty()

bool UM.Settings.InstanceContainer.InstanceContainer.hasProperty ( self,
str key,
str property_name )
:copydoc ContainerInterface::hasProperty

Reimplemented from ContainerInterface.

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ isDirty()

bool UM.Settings.InstanceContainer.InstanceContainer.isDirty ( self)

Check if this container is dirty, that is, if it changed from deserialization.

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ removeInstance()

None UM.Settings.InstanceContainer.InstanceContainer.removeInstance ( self,
str key,
bool postpone_emit = False )
Remove an instance from this container.

:param postpone_emit: postpone emit until calling sendPostponedEmits

◆ sendPostponedEmits()

None UM.Settings.InstanceContainer.InstanceContainer.sendPostponedEmits ( self)
Send the postponed emits

These emits are collected from the option postpone_emit.
Note: the option can be implemented for all functions modifying the container.

◆ serialize()

str UM.Settings.InstanceContainer.InstanceContainer.serialize ( self,
Optional[Set[str]] ignored_metadata_keys = None )
:copydoc ContainerInterface::serialize

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ setDefinition()

None UM.Settings.InstanceContainer.InstanceContainer.setDefinition ( self,
str definition_id )
Set the DefinitionContainer to use for new instance creation.

Since SettingInstance needs a SettingDefinition to work properly, we need some
way of figuring out what SettingDefinition to use when creating a new SettingInstance.

◆ setDirty()

None UM.Settings.InstanceContainer.InstanceContainer.setDirty ( self,
bool dirty )

◆ setMetaData()

None UM.Settings.InstanceContainer.InstanceContainer.setMetaData ( self,
Dict[str, Any] metadata )

Reimplemented from UM.PluginObject.PluginObject.

◆ setMetaDataEntry()

None UM.Settings.InstanceContainer.InstanceContainer.setMetaDataEntry ( self,
str key,
Any value )
Set a metadata entry to a certain value.

:param key: The key of the metadata entry to set.
:param value: The new value of the metadata.

:note This does nothing if the key is not already added to the metadata.

◆ setPath()

None UM.Settings.InstanceContainer.InstanceContainer.setPath ( self,
str path )
:copydoc ContainerInterface::setPath

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ setProperty()

None UM.Settings.InstanceContainer.InstanceContainer.setProperty ( self,
str key,
str property_name,
Any property_value,
ContainerInterface container = None,
bool set_from_cache = False )
Set the value of a property of a SettingInstance.

This will set the value of the specified property on the SettingInstance corresponding to key.
If no instance has been created for the specified key, a new one will be created and inserted
into this instance.

:param key: The key of the setting to set a property of.
:param property_name:  The name of the property to set.
:param property_value: The new value of the property.
:param container: The container to use for retrieving values when changing the property triggers property
updates. Defaults to None, which means use the current container.
:param set_from_cache: Flag to indicate that the property was set from cache. This triggers the behavior that
the read_only and setDirty are ignored.

:note If no definition container is set for this container, new instances cannot be created and this method
will do nothing.

Reimplemented from UM.Settings.Interfaces.ContainerInterface.


The documentation for this class was generated from the following file: