Uranium
Application Framework
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

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

Static Public Attributes

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

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.

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

Member Function Documentation

◆ __str__()

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

Simple string representation for debugging.

◆ addInstance()

None UM.Settings.InstanceContainer.InstanceContainer.addInstance (   self,
SettingInstance  instance 
)

Add a new instance to this container.

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

Deserialize the container from a string representation.

This should replace the contents of this container with those in the serialized representation.

Parameters
serializedA serialized string containing a container that should be deserialized.

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.

Parameters
new_idThe new ID of the container
new_nameThe 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,
**Any  kwargs 
)

Find instances matching certain criteria.

Parameters
kwargsA 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.

◆ getDefinition()

DefinitionContainerInterface UM.Settings.InstanceContainer.InstanceContainer.getDefinition (   self)

Get the DefinitionContainer used for new instance creation.

◆ getId()

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

Get the ID of the container.

The ID should be unique, machine readable and machine writable. It is intended to be used for example when referencing the container in configuration files or when writing a file to disk.

Returns
The unique ID of this container.

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getMetaData()

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

Get all metadata of this container.

This returns a dictionary containing all the metadata for this container. How this metadata is used depends on the application.

Returns
The metadata for this container.

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getMetaDataEntry()

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

Get the value of a single metadata entry.

Parameters
entryThe key of the metadata to retrieve.
defaultThe default value to return if the entry cannot be found.
Returns
The value of the metadata corresponding to name, or default when the entry could not be found.

Reimplemented from ContainerInterface

◆ getName()

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

Get the human-readable name of this container.

This should return a human-readable name for the container, that can be used in the interface.

Returns
The name of this container.

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getPath()

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

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 
)

Get the value of a property of the container item.

Parameters
keyThe key of the item to retrieve a property from.
property_nameThe name of the property to retrieve.
Returns
The specified property value of the container item corresponding to key, or None if not found.

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

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

Get whether the container item has a specific property.

Parameters
keyThe key of the item to check the property from.
nameThe name of the property to check for.
Returns
True if the specified item has the property, or False if it doesn't.

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.

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

Serialize this container to a string.

The serialized representation of the container can be used to write the container to disk or send it over the network.

Parameters
ignored_metadata_keysA set of keys that should be ignored when it serializes the metadata.
Returns
A string representation of this container.

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.

◆ setMetaDataEntry()

None UM.Settings.InstanceContainer.InstanceContainer.setMetaDataEntry (   self,
str  key,
Any  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()

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

Set the path used to create this InstanceContainer.

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.

Parameters
keyThe key of the setting to set a property of.
property_nameThe 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.

◆ update()

None UM.Settings.InstanceContainer.InstanceContainer.update (   self)

Update all instances from this container.


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