![]() |
Chemical Data Processing Library Python API - Version 1.4.0
|
Base class providing methods for the storage and lookup of object properties. More...
Inheritance diagram for CDPL.Base.PropertyContainer:Public Member Functions | |
| None | __init__ () |
Constructs an empty PropertyContainer instance. | |
| int | getObjectID () |
| Returns the numeric identifier (ID) of the wrapped C++ class instance. More... | |
| int | getNumProperties () |
| Returns the number of property entries. More... | |
| Any | getPropertyOrDefault (LookupKey key, Any def_val) |
| Returns the value of the property specified by key , or the default value def_val if an entry does not exist. More... | |
| list | getPropertyKeys () |
| Returns a list containing the keys of the current property entries. More... | |
| list | getPropertyValues () |
| Returns a list containing the values of the current property entries. More... | |
| list | getProperties () |
| Returns a reference to itself. More... | |
| None | setProperty (LookupKey key, Any val) |
| Sets the value of the property specified by key to val. More... | |
| bool | removeProperty (LookupKey key) |
| Removes the entry for the property specified by key. More... | |
| Any | getProperty (LookupKey key, bool throw_=False) |
| Returns the value of the property specified by key. More... | |
| bool | isPropertySet (LookupKey key) |
| Tells whether or not a value has been assigned to the property specified by key. More... | |
| None | clearProperties () |
| Erases all container entries. | |
| None | addProperties (PropertyContainer cntnr) |
Adds the property entries of the PropertyContainer instance cntnr. More... | |
| None | copyProperties (PropertyContainer cntnr) |
| Replaces the current property entries by a copy of the entries in cntnr. More... | |
| None | swap (PropertyContainer cntnr) |
| Exchanges the property entries of this container with the ones of cntnr. More... | |
| Any | __getitem__ (LookupKey key) |
| Returns the value of the property specified by key. More... | |
| bool | __contains__ (LookupKey key) |
| Tells whether or not a value has been assigned to the property specified by key. More... | |
| None | __setitem__ (LookupKey key, Any val) |
| Sets the value of the property specified by key to val. More... | |
| bool | __delitem__ (LookupKey key) |
| Removes the entry for the property specified by key. More... | |
| int | __len__ () |
| Returns the number of property entries. More... | |
Properties | |
| objectID = property(getObjectID) | |
| propertyKeys = property(getPropertyKeys) | |
| propertyValues = property(getPropertyValues) | |
| properties = property(getProperties) | |
| numProperties = property(getNumProperties) | |
Base class providing methods for the storage and lookup of object properties.
The purpose of PropertyContainer is to provide a common facility for the storage and lookup of dynamic object properties to subclasses and their clients.
PropertyContainer stores the properties in a map that associates unique property keys of type Base.LookupKey with corresponding property values of type Base.Any. The number of currently stored property entries is accessible via the method getNumProperties().
For the explicit assignment of property values the method setProperty() is provided which expects the key of the property as its first and the value to assign as the second argument. Whether the value of a particular property has been set can be tested by the method isPropertySet(). For the erasure of property entries the methods removeProperty() and clearProperties() are provided. The first method removes the entry for a single property while the latter method removes all entries.
To access the value of a property the method getProperty() is available which expects the key of the property as the first argument. If the requested property value does not exist, an additional argument decides whether to throw an exception or to return an empty Base.Any instance.
| int CDPL.Base.PropertyContainer.getObjectID | ( | ) |
Returns the numeric identifier (ID) of the wrapped C++ class instance.
Different Python PropertyContainer instances may reference the same underlying C++ class instance. The commonly used Python expression a is not b thus cannot tell reliably whether the two PropertyContainer instances a and b reference different C++ objects. The numeric identifier returned by this method allows to correctly implement such an identity test via the simple expression a.getObjectID() != b.getObjectID().
Reimplemented in CDPL.ConfGen.CanonicalFragment.
| int CDPL.Base.PropertyContainer.getNumProperties | ( | ) |
Returns the number of property entries.
Returns the value of the property specified by key , or the default value def_val if an entry does not exist.
If a value has been assigned to the specified property, the stored value will be returned. Otherwise the default value specified by def_val gets returned.
| key | The key of the property for which to return the stored (or specified default) value. |
| def_val | The default value that shall be returned if an entry for the specified property does not exist. |
| list CDPL.Base.PropertyContainer.getPropertyKeys | ( | ) |
Returns a list containing the keys of the current property entries.
| list CDPL.Base.PropertyContainer.getPropertyValues | ( | ) |
Returns a list containing the values of the current property entries.
| list CDPL.Base.PropertyContainer.getProperties | ( | ) |
Returns a reference to itself.
Sets the value of the property specified by key to val.
If val is None, and a property entry for key exists, the entry gets erased (equivalent to removeProperty() with key as argument).
| key | The key of the property value to assign or remove. |
| val | The value of the property. |
| bool CDPL.Base.PropertyContainer.removeProperty | ( | LookupKey | key | ) |
Removes the entry for the property specified by key.
| key | The key of the property entry to remove. |
True if an entry for key could be found and was removed, and False otherwise. Returns the value of the property specified by key.
If an entry for the specified property exists, the stored value will be returned. Otherwise an empty Base.Any instance gets returned if _throw is False, and a Base.ItemNotFound exception will be thrown if _throw is True.
| key | The key of the property value to return. |
| throw_ | Specifies whether to throw a Base.ItemNotFound exception or to return an empty Base.Any instance if the requested property value does not exist. |
| Base.ItemNotFound | if an entry for the requested property value does not exist and throw_ is True. |
| bool CDPL.Base.PropertyContainer.isPropertySet | ( | LookupKey | key | ) |
Tells whether or not a value has been assigned to the property specified by key.
| key | The key of the property. |
True if a value has been assigned to the specified property, and False otherwise. | None CDPL.Base.PropertyContainer.addProperties | ( | PropertyContainer | cntnr | ) |
Adds the property entries of the PropertyContainer instance cntnr.
Any properties which have no corresponding entry in cntnr are left unchanged. Otherwise the value of the local property gets overwritten by the value stored in cntnr.
| cntnr | The PropertyContainer instance providing the property entries to add. |
| None CDPL.Base.PropertyContainer.copyProperties | ( | PropertyContainer | cntnr | ) |
Replaces the current property entries by a copy of the entries in cntnr.
| cntnr | The PropertyContainer instance providing the property entries to copy. |
| None CDPL.Base.PropertyContainer.swap | ( | PropertyContainer | cntnr | ) |
Exchanges the property entries of this container with the ones of cntnr.
| cntnr | The other PropertyContainer instance. |
Returns the value of the property specified by key.
If an entry for the specified property exists, the stored value will be returned. Otherwise a Base.ItemNotFound exception will be thrown.
| key | The key of the property value to return. |
| Base.ItemNotFound | if an entry for the requested property value does not exist. |
| bool CDPL.Base.PropertyContainer.__contains__ | ( | LookupKey | key | ) |
Tells whether or not a value has been assigned to the property specified by key.
| key | The key of the property. |
True if a value has been assigned to the specified property, and False otherwise. Sets the value of the property specified by key to val.
If val is of type Base.Any and empty, i.e. the method Base.Any.isEmpty() returns True, and a property entry for key exists, the entry gets erased (equivalent to removeProperty() with key as argument).
| key | The key of the property value to assign or remove. |
| val | The value of the property. |
| bool CDPL.Base.PropertyContainer.__delitem__ | ( | LookupKey | key | ) |
Removes the entry for the property specified by key.
| key | The key of the property entry to remove. |
True if an entry for key could be found and was removed, and False otherwise. | int CDPL.Base.PropertyContainer.__len__ | ( | ) |
Returns the number of property entries.
Reimplemented in CDPL.Vis.Object3D, CDPL.Shape.GaussianShape, CDPL.Pharm.Pharmacophore, CDPL.Pharm.FeatureSet, CDPL.Pharm.FeatureContainer, CDPL.Pharm.Feature, CDPL.Grid.FSpatialGrid, CDPL.Grid.FRegularGrid, CDPL.Grid.DSpatialGrid, CDPL.Grid.DRegularGrid, CDPL.Grid.AttributedGrid, CDPL.Chem.Reaction, CDPL.Chem.Molecule, CDPL.Chem.MolecularGraph, CDPL.Chem.Fragment, CDPL.Chem.Entity3D, CDPL.Chem.Bond, CDPL.Biomol.HierarchyViewModel, and CDPL.Biomol.HierarchyViewChain.