OEMutableCoords

template<class T>
class OEMutableCoords : public detail::OECoordsBase<T, OEConfBase>

This class is used to provide convenient direct access to the memory storing coordinates for a OEConfBase through the OEConfBase::GetCoordsPtr methods. If the data type of T does not match the implementation of OEConfBase, this class makes a copy of the coordinates with OEConfBase::GetCoords instead. If a copy of the coordinates are made with OEConfBase::GetCoords, the destructor of this class will copy the changes made back into the conformer with OEConfBase::SetCoords.

Note

This class can incur unnecessary copies if T does not match the implementation of the OEConfBase and no modifications were actually made. Use OEConstCoords whenever read-only access to coordinates is acceptable.

Listing 1 demonstrates the quickest way to zero all the coordinates in a conformer using the memset function. OEMutableCoords it used to get direct access to the coordinates in an OEConfBase. This can provide large efficiency gains due to the reduced need for temporary memory and copies like the OEConfBase::SetCoords method.

Listing 1:

    for (OEIter<OEConfBase> conf = mol.GetConfs(); conf; ++conf)
    {
      OEMutableCoords<float> crds(conf);
      memset(crds, '\0', mol.GetMaxAtomIdx() * sizeof(float));
    }

Constructors

OEMutableCoords(OEConfBase *conf)

Construct a mutable view of the coordinates in the conformer conf.

operator T *

operator T *()

Allows implicitly casting this object into a pointer of type T to the coordinates of the conformer used in the constructor.

GetPtr

T *GetPtr()

Returns a pointer of type T to the coordinates of the conformer used in the constructor.