Uranium
Application Framework
Loading...
Searching...
No Matches
UM.Settings.InstanceContainer.InstanceContainer Class Reference

A container for SettingInstance objects. More...

Inheritance diagram for UM.Settings.InstanceContainer.InstanceContainer:
UM.Settings.Interfaces.ContainerInterface UM.PluginObject.PluginObject

Public Member Functions

 __init__ (self, str container_id, *args, **kwargs)
 Constructor.
 
 __hash__ (self)
 
 __deepcopy__ (self, memo)
 
 __eq__ (self, other)
 
 __ne__ (self, other)
 
 __getnewargs__ (self)
 For pickle support.
 
 __getstate__ (self)
 For pickle support.
 
 __setstate__ (self, state)
 For pickle support.
 
str getId (self)
 
 setCachedValues (self, cached_values)
 
int getLoadingPriority (cls)
 
 getPath (self)
 
 setPath (self, path)
 
str getName (self)
 
 setName (self, name)
 
bool getReadOnly (self)
 
 getMetaData (self)
 
 setMetaData (self, metadata)
 
 getMetaDataEntry (self, entry, default=None)
 
 addMetaDataEntry (self, key, value)
 Add a new entry to the metadata of this container.
 
 setMetaDataEntry (self, key, value)
 Set a metadata entry to a certain value.
 
 isDirty (self)
 Check if this container is dirty, that is, if it changed from deserialization.
 
 setDirty (self, dirty)
 
 getProperty (self, key, property_name, context=None)
 
 hasProperty (self, key, property_name)
 
 setProperty (self, key, property_name, property_value, container=None, set_from_cache=False)
 Set the value of a property of a SettingInstance.
 
 clear (self)
 Remove all instances from this container.
 
 getAllKeys (self)
 Get all the keys of the instances of this container.
 
 duplicate (self, str new_id, str new_name=None)
 Create a new InstanceContainer with the same contents as this container.
 
str serialize (self, Optional[set] ignored_metadata_keys=None)
 
Optional[str] getConfigurationTypeFromSerialized (cls, str serialized)
 Gets the configuration type of the given serialized data.
 
Optional[int] getVersionFromSerialized (cls, str serialized)
 Gets the version of the given serialized data.
 
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, **kwargs)
 Find instances matching certain criteria.
 
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)
 Remove an instance from this container.
 
 update (self)
 Update all instances from this container.
 
DefinitionContainerInterface getDefinition (self)
 Get the DefinitionContainer used for new instance creation.
 
 setDefinition (self, str definition_id)
 Set the DefinitionContainer to use for new instance creation.
 
 __lt__ (self, other)
 
 __str__ (self)
 Simple string representation for debugging.
 
 sendPostponedEmits (self)
 Send postponed emits These emits are collected from the option postpone_emit.
 
str getId (self)
 Get the ID of the container.
 
str getName (self)
 Get the human-readable name of this container.
 
Dict[str, Any] getMetaData (self)
 Get all metadata of this container.
 
Any getMetaDataEntry (self, str entry, Any default=None)
 Get the value of a single metadata entry.
 
Any getProperty (self, str key, str property_name, Optional[PropertyEvaluationContext] context=None)
 Get the value of a property of the container item.
 
bool hasProperty (self, str key, str property_name)
 Get whether the container item has a specific property.
 
str serialize (self, Optional[set] ignored_metadata_keys=None)
 Serialize this container to a string.
 
str deserialize (self, str serialized, Optional[str] file_name=None)
 Deserialize the container from a string representation.
 
List[Dict[str, Any]] deserializeMetadata (cls, str serialized, str container_id)
 Deserialize just the metadata from a string representation.
 
int getLoadingPriority (cls)
 
Optional[str] getConfigurationTypeFromSerialized (cls, str serialized)
 Gets the configuration type of the given serialized data.
 
Optional[int] getVersionFromSerialized (cls, str serialized)
 Gets the version of the given serialized data.
 
str getPath (self)
 Get the path used to create this InstanceContainer.
 
None setPath (self, str path)
 Set the path used to create this InstanceContainer.
 
- Public Member Functions inherited from UM.PluginObject.PluginObject
 __init__ (self)
 
 getPluginId (self)
 
 setPluginId (self, plugin_id)
 

Public Attributes

 Version
 

Static Public Attributes

int Version = 2
 
 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

 _instantiateMissingSettingInstancesInCache (self)
 Creates SettingInstances that are missing in this InstanceContainer from the cache if any.
 
configparser.ConfigParser _readAndValidateSerialized (self, str serialized)
 
 _instantiateCachedValues (self)
 Instance containers are lazy loaded.
 
- Protected Member Functions inherited from UM.Settings.Interfaces.ContainerInterface
str _updateSerialized (cls, str serialized, Optional[str] file_name=None)
 Updates the given serialized data to the latest version.
 

Protected Attributes

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

Detailed Description

A container for SettingInstance objects.

Constructor & Destructor Documentation

◆ __init__()

UM.Settings.InstanceContainer.InstanceContainer.__init__ (   self,
str  container_id,
args,
**  kwargs 
)

Constructor.

Parameters
container_idA unique, machine readable/writable ID for this container.

Reimplemented from UM.PluginObject.PluginObject.

Member Function Documentation

◆ _instantiateCachedValues()

UM.Settings.InstanceContainer.InstanceContainer._instantiateCachedValues (   self)
protected

Instance containers are lazy loaded.

This function ensures that it happened.

◆ _instantiateMissingSettingInstancesInCache()

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.

◆ addMetaDataEntry()

UM.Settings.InstanceContainer.InstanceContainer.addMetaDataEntry (   self,
  key,
  value 
)

Add a new entry to the metadata of this container.

Parameters
keystr The key of the new entry.
valueThe value of the new entry.
Note
This does nothing if the key already exists.

◆ deserialize()

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

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()

UM.Settings.InstanceContainer.InstanceContainer.duplicate (   self,
str  new_id,
str   new_name = None 
)

Create a new InstanceContainer with the same contents as this container.

Parameters
new_idstr The new ID of the container
new_namestr The new name of the container. Defaults to None to indicate the name should not change.
Returns
A new InstanceContainer with the same contents as this container.

◆ findInstances()

List[SettingInstance] UM.Settings.InstanceContainer.InstanceContainer.findInstances (   self,
**  kwargs 
)

Find instances matching certain criteria.

Parameters
kwargsdict A dictionary of keyword arguments with key-value pairs that should match properties of the instances.

◆ getAllKeys()

UM.Settings.InstanceContainer.InstanceContainer.getAllKeys (   self)

Get all the keys of the instances of this container.

Returns
list of keys

◆ 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)

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getLoadingPriority()

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

◆ getMetaData()

UM.Settings.InstanceContainer.InstanceContainer.getMetaData (   self)

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getMetaDataEntry()

UM.Settings.InstanceContainer.InstanceContainer.getMetaDataEntry (   self,
  entry,
  default = None 
)

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getName()

str UM.Settings.InstanceContainer.InstanceContainer.getName (   self)

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getPath()

UM.Settings.InstanceContainer.InstanceContainer.getPath (   self)

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getProperty()

UM.Settings.InstanceContainer.InstanceContainer.getProperty (   self,
  key,
  property_name,
  context = None 
)

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getVersionFromSerialized()

Optional[int] UM.Settings.InstanceContainer.InstanceContainer.getVersionFromSerialized (   cls,
str  serialized 
)

Gets the version of the given serialized data.

(used by __updateSerialized())

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ hasProperty()

UM.Settings.InstanceContainer.InstanceContainer.hasProperty (   self,
  key,
  property_name 
)

Reimplemented from ContainerInterface.

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()

UM.Settings.InstanceContainer.InstanceContainer.sendPostponedEmits (   self)

Send 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]   ignored_metadata_keys = None 
)

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ setDefinition()

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.

◆ setMetaDataEntry()

UM.Settings.InstanceContainer.InstanceContainer.setMetaDataEntry (   self,
  key,
  value 
)

Set a metadata entry to a certain value.

Parameters
keyThe key of the metadata entry to set.
valueThe new value of the metadata.
Note
This does nothing if the key is not already added to the metadata.

◆ setPath()

UM.Settings.InstanceContainer.InstanceContainer.setPath (   self,
  path 
)

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ setProperty()

UM.Settings.InstanceContainer.InstanceContainer.setProperty (   self,
  key,
  property_name,
  property_value,
  container = None,
  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.

Parameters
keystring The key of the setting to set a property of.
property_namestring The name of the property to set.
property_valueThe new value of the property.
containerThe container to use for retrieving values when changing the property triggers property updates. Defaults to None, which means use the current container.
set_from_cacheFlag 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.

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