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

def __init__
 Constructor. More...
 
def __hash__ (self)
 
def __deepcopy__ (self, memo)
 
def __eq__ (self, other)
 
def __ne__ (self, other)
 
def __getnewargs__ (self)
 For pickle support.
 
def __getstate__ (self)
 For pickle support.
 
def __setstate__ (self, state)
 For pickle support.
 
def getId (self)
 Get the ID of the container. More...
 
def setCachedValues (self, cached_values)
 
def getLoadingPriority (cls)
 
def getPath (self)
 
def setPath (self, path)
 Set the path used to create this InstanceContainer. More...
 
def getName (self)
 Get the human-readable name of this container. More...
 
def setName (self, name)
 
def getReadOnly (self)
 
def getMetaData (self)
 Get all metadata of this container. More...
 
def setMetaData (self, metadata)
 
def getMetaDataEntry (self, entry, default=None)
 Get the value of a single metadata entry. More...
 
def addMetaDataEntry (self, key, value)
 Add a new entry to the metadata of this container. More...
 
def setMetaDataEntry (self, key, value)
 Set a metadata entry to a certain value. More...
 
def isDirty (self)
 Check if this container is dirty, that is, if it changed from deserialization. More...
 
def setDirty (self, dirty)
 
def getProperty (self, key, property_name, context=None)
 Get the value of a property of the container item. More...
 
def hasProperty (self, key, property_name)
 Get whether the container item has a specific property. More...
 
def setProperty (self, key, property_name, property_value, container=None, set_from_cache=False)
 Set the value of a property of a SettingInstance. More...
 
def clear (self)
 Remove all instances from this container. More...
 
def getAllKeys (self)
 Get all the keys of the instances of this container. More...
 
def duplicate
 Create a new InstanceContainer with the same contents as this container. More...
 
def serialize
 Serialize this container to a string. More...
 
def getConfigurationTypeFromSerialized
 
def getVersionFromSerialized
 
def deserialize
 Deserialize the container from a string representation. More...
 
def deserializeMetadata
 Gets the metadata of an instance container from a serialised format. More...
 
def findInstances (self, kwargs)
 Find instances matching certain criteria. More...
 
def getInstance
 Get an instance by key.
 
def addInstance
 Add a new instance to this container. More...
 
def removeInstance
 Remove an instance from this container. More...
 
def update (self)
 Update all instances from this container. More...
 
def getDefinition (self)
 Get the DefinitionContainer used for new instance creation. More...
 
def setDefinition
 Set the DefinitionContainer to use for new instance creation. More...
 
def __lt__ (self, other)
 
def __str__ (self)
 Simple string representation for debugging. More...
 
def sendPostponedEmits (self)
 Send postponed emits These emits are collected from the option postpone_emit. More...
 
- Public Member Functions inherited from UM.Settings.Interfaces.ContainerInterface
def getId (self)
 Get the ID of the container. More...
 
def getName (self)
 Get the human-readable name of this container. More...
 
def getMetaData (self)
 Get all metadata of this container. More...
 
def getMetaDataEntry
 Get the value of a single metadata entry. More...
 
def getProperty
 Get the value of a property of the container item. More...
 
def hasProperty
 Get whether the container item has a specific property. More...
 
def serialize
 Serialize this container to a string. More...
 
def deserialize
 Deserialize the container from a string representation. More...
 
def deserializeMetadata
 Deserialize just the metadata from a string representation. More...
 
def getLoadingPriority (cls)
 
def getConfigurationTypeFromSerialized
 Gets the configuration type of the given serialized data. More...
 
def getVersionFromSerialized
 Gets the version of the given serialized data. More...
 
def getPath (self)
 Get the path used to create this InstanceContainer. More...
 
def setPath
 Set the path used to create this InstanceContainer.
 
- Public Member Functions inherited from UM.PluginObject.PluginObject
def __init__ (self)
 
def getPluginId (self)
 
def setPluginId (self, plugin_id)
 

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
 

Detailed Description

A container for SettingInstance objects.

Constructor & Destructor Documentation

◆ __init__()

def UM.Settings.InstanceContainer.InstanceContainer.__init__ (   self,
  container_id 
)

Constructor.

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

Member Function Documentation

◆ __str__()

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

Simple string representation for debugging.

◆ addInstance()

def UM.Settings.InstanceContainer.InstanceContainer.addInstance (   self,
  instance 
)

Add a new instance to this container.

◆ addMetaDataEntry()

def 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.

◆ clear()

def UM.Settings.InstanceContainer.InstanceContainer.clear (   self)

Remove all instances from this container.

◆ deserialize()

def UM.Settings.InstanceContainer.InstanceContainer.deserialize (   self,
  serialized 
)

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

◆ deserializeMetadata()

def UM.Settings.InstanceContainer.InstanceContainer.deserializeMetadata (   cls,
  serialized 
)

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.

◆ duplicate()

def UM.Settings.InstanceContainer.InstanceContainer.duplicate (   self,
  new_id 
)

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

def UM.Settings.InstanceContainer.InstanceContainer.findInstances (   self,
  kwargs,
  List,
  SettingInstance 
)

Find instances matching certain criteria.

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

◆ getAllKeys()

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

Get all the keys of the instances of this container.

Returns
list of keys

◆ getDefinition()

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

Get the DefinitionContainer used for new instance creation.

◆ getId()

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

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
string The unique ID of this container.

Reimplemented from ContainerInterface

◆ getMetaData()

def 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
dict The metadata for this container.

Reimplemented from ContainerInterface

◆ getMetaDataEntry()

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

Get the value of a single metadata entry.

Parameters
entrystring The 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()

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

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
string The name of this container.

Reimplemented from ContainerInterface

◆ getPath()

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

Reimplemented from ContainerInterface

◆ getProperty()

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

Get the value of a property of the container item.

Parameters
keystring The key of the item to retrieve a property from.
namestring The 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

◆ hasProperty()

def UM.Settings.InstanceContainer.InstanceContainer.hasProperty (   self,
  key,
  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.

◆ isDirty()

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

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

◆ removeInstance()

def UM.Settings.InstanceContainer.InstanceContainer.removeInstance (   self,
  key 
)

Remove an instance from this container.

/param postpone_emit postpone emit until calling sendPostponedEmits

◆ sendPostponedEmits()

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

def UM.Settings.InstanceContainer.InstanceContainer.serialize (   self,
  ignored_metadata_keys 
)

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
string A string representation of this container.

Reimplemented from ContainerInterface

◆ setDefinition()

def UM.Settings.InstanceContainer.InstanceContainer.setDefinition (   self,
  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()

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

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

Set the path used to create this InstanceContainer.

Reimplemented from ContainerInterface

◆ setProperty()

def 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.

◆ update()

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

Update all instances from this container.


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