Chemical Data Processing Library Python API - Version 1.1.1
|
A class providing methods for the storage and lookup of object properties. More...
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_value) |
list | getPropertyKeys () |
list | getPropertyValues () |
list | getProperties () |
Returns a reference to itself. More... | |
None | setProperty (LookupKey key, Any value) |
bool | removeProperty (LookupKey key) |
Clears the value of 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 () |
Clears all property values. | |
None | addProperties (PropertyContainer cntnr) |
Adds the property value entries in the PropertyContainer instance cntnr. More... | |
None | copyProperties (PropertyContainer cntnr) |
Replaces the current set of properties by a copy of the entries in cntnr. More... | |
None | swap (PropertyContainer cntnr) |
Exchanges the properties of this container with the properties of the container cntnr. More... | |
Any | __getitem__ (LookupKey key) |
bool | __contains__ (LookupKey key) |
Returns the result of the membership test operation key in self . More... | |
None | __setitem__ (LookupKey key, Any value) |
bool | __delitem__ (LookupKey key) |
int | __len__ () |
Properties | |
objectID = property(getObjectID) | |
propertyKeys = property(getPropertyKeys) | |
propertyValues = property(getPropertyValues) | |
properties = property(getProperties) | |
numProperties = property(getNumProperties) | |
A 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. Iterators pointing to the beginning and end of the property key/value pairs (see PropertyContainer.PropertyEntry) can be retrieved by the methods getPropertiesBegin() and getPropertiesEnd(), respectively. The number of currently stored property value 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 values the methods removeProperty() and clearProperties() are provided. The first method clears the value of a single property while the latter method removes all assigned property values.
To access the value of a property, two types of getProperty() methods are available that both expect the key of the property as the first argument. The templated versions return the stored property value (or the specified default if not available) as a reference to an object of the specified template argument type. The non-template method returns the requested property value indirectly as a reference to the Base.Any instance storing the actual value. 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.
key | |
def_value |
list CDPL.Base.PropertyContainer.getPropertyKeys | ( | ) |
list CDPL.Base.PropertyContainer.getPropertyValues | ( | ) |
list CDPL.Base.PropertyContainer.getProperties | ( | ) |
Returns a reference to itself.
bool CDPL.Base.PropertyContainer.removeProperty | ( | LookupKey | key | ) |
Clears the value of the property specified by key.
key | The key of the property value to erase. |
True
if an entry for key could be found and was erased, 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 object 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 object 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 value entries in the PropertyContainer
instance cntnr.
Any property values which have no corresponding assigned value in cntnr are left unchanged. Otherwise the value of the local property gets overwritten by the value stored in cntnr.
cntnr | The PropertyContainer instance containing the property value entries to add. |
None CDPL.Base.PropertyContainer.copyProperties | ( | PropertyContainer | cntnr | ) |
Replaces the current set of properties by a copy of the entries in cntnr.
cntnr | The PropertyContainer instance containing the property value entries to add. |
None CDPL.Base.PropertyContainer.swap | ( | PropertyContainer | cntnr | ) |
Exchanges the properties of this container with the properties of the container cntnr.
cntnr | The container to exchange the properties with. |
bool CDPL.Base.PropertyContainer.__contains__ | ( | LookupKey | key | ) |
Returns the result of the membership test operation key in self
.
key | The value to test for membership. |
bool CDPL.Base.PropertyContainer.__delitem__ | ( | LookupKey | key | ) |
key |
int CDPL.Base.PropertyContainer.__len__ | ( | ) |
Reimplemented in 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.Chem.Atom, CDPL.Biomol.HierarchyViewModel, and CDPL.Biomol.HierarchyViewChain.