Open Babel
3.0
|
#include <openbabel/generic.h>
Public Member Functions | |
OBGenericData (const std::string attr="undefined", const unsigned int type=OBGenericDataType::UndefinedData, const DataOrigin source=any) | |
virtual OBGenericData * | Clone (OBBase *) const |
virtual | ~OBGenericData () |
void | SetAttribute (const std::string &v) |
void | SetOrigin (const DataOrigin s) |
virtual const std::string & | GetAttribute () const |
unsigned int | GetDataType () const |
virtual const std::string & | GetValue () const |
virtual DataOrigin | GetOrigin () const |
Protected Attributes | |
std::string | _attr |
unsigned int | _type |
DataOrigin | _source |
Base class for generic data.
OBGenericData is an abstract base class which defines an interface for storage, retrieval, and indexing of arbitrary generic data. Subclasses of OBGenericData can be used to store custom data on a per-atom, per-bond, per-molecule, or per-residue basis. Open Babel currently supports a small subset of chemical functionality as OBGenericData types, which will expand over time to support additional interconversion (e.g., spectroscopy, dynamics, surfaces...)
For more information on currently supported types, please see the developer wiki: http://openbabel.org/wiki/Generic_Data
For your own custom data, either define a custom subclass using an id from the OBGenericDataType::CustomData0 to OBGenericDataType::CustomData15 slots, or store your data as a string and use OBPairData for key/value access. The latter is highly recommended for various text descriptors e.g., in QSAR, atom or bond labels, or other textual data.
New in Open Babel, version 2.1 is the template-based OBPairTemplate, which can be used to store arbitrary data types. There are predefined types OBPairInteger and OBPairFloatingPoint for storing integers and floating-point values without converting to a string representation.
Also new is the "source" or "origin" of a data entry, enumerated by DataOrigin. This can be accessed by SetOrigin() and GetOrigin(), as well as via "filtering" methods in OBBase, allowing you to separate data read in from a file, added by a user, or assigned by Open Babel internally.
While the library and import routines will set DataOrigin correctly, you should try to annotate data added by your code. Typically this would either be userAdded or external. The former refers to something the user requested as an annotation, while the latter refers to annotations your code adds automatically.
Example code using OBGenericData:
Similar code also works for OBGenericData stored in an OBAtom or OBBond or OBResidue. These examples show use of DataOrigin outside of the Open Babel library.
When designing a class derived from OBGenericData you must add a Clone() function. For classes used with OBMol this is used when an OBMol object is copied. If your class member variables contain pointers to atoms or bonds then it will be necessary to ensure that these are updated in Clone() to refer to the new molecule. Without these and similar pointers it is more likely that the very simple clone function
and the compiler generated copy constructor would be sufficient.
It is recommended that, if possible, OBGenericData classes do not store atom and bond pointers. Using atom and bond indices instead would allow the simple version of Clone() above. See OBRotameterData::Clone for an example of a more complicated version. For classes which are not intended to support copying, Clone() can return NULL
Clone() is a pure virtual function so that you need to decide what kind of function you need and include it explicitly.
OBGenericData | ( | const std::string | attr = "undefined" , |
const unsigned int | type = OBGenericDataType::UndefinedData , |
||
const DataOrigin | source = any |
||
) |
|
inlinevirtual |
|
inlinevirtual |
Reimplemented in OBMatrixData, OBVectorData, OBRotationData, OBElectronicTransitionData, OBOrbitalData, OBDOSData, OBVibrationData, OBSerialNums, OBAngleData, OBTorsionData, OBSymmetryData, OBConformerData, OBUnitCell, OBCisTransStereo, OBRingData, OBVirtualBond, OBTetrahedralStereo, OBSquarePlanarStereo, OBSetData, OBNasaThermoData, OBPairTemplate< ValueT >, OBPairData, OBExternalBondData, AliasData, OBRotamerList, OBCommentData, and OBRateData.
Referenced by OBBase::CloneData(), OBAtom::Duplicate(), OBMoleculeFormat::MakeCombinedMolecule(), and OBMol::operator=().
|
inline |
Set the attribute (key), which can be used to retrieve this data.
Referenced by OBGastChrg::AssignPartialCharges(), OpenBabel::ComparePairSecond(), OBMol::DoTransformations(), OBMol::FindLSSR(), OBMol::FindSSSR(), OBForceField::GetAtomTypes(), OBMol::GetFormula(), OBMol::GetLSSR(), OBForceField::GetPartialCharges(), OBMol::GetSSSR(), OBDescriptor::PredictAndSave(), and OBMol::SetFormula().
|
inline |
Set the origin of this data, which can be used to filter the data.
Referenced by OBGastChrg::AssignPartialCharges(), OpenBabel::ComparePairSecond(), OBMol::DoTransformations(), OBMol::FindAngles(), OBMol::FindLSSR(), OBMol::FindSSSR(), OBMol::FindTorsions(), OBMol::GetFormula(), OBMol::GetLSSR(), OBMol::GetSSSR(), OBDescriptor::PredictAndSave(), and OBMol::SetFormula().
|
inlinevirtual |
Referenced by OpenBabel::extract_thermochemistry(), and OBMoleculeFormat::MakeCombinedMolecule().
|
inline |
|
inlinevirtual |
Base class returns a default value (the attribute type) but should never be called.
Reimplemented in OBPairData, and OBCommentData.
Referenced by OBDepict::AddAtomLabels(), OBDepict::DrawMolecule(), OBDescriptor::FilterCompare(), and OBDescriptor::GetValues().
|
inlinevirtual |
|
protected |
attribute tag (e.g., "UnitCell", "Comment" or "Author")
Referenced by OBRotamerList::Clone(), and OBNasaThermoData::OBNasaThermoData().
|
protected |
attribute type – declared for each subclass
Referenced by OBRotamerList::Clone(), and OBNasaThermoData::OBNasaThermoData().
|
protected |
source of data for accounting
Referenced by OBConformerData::operator=(), OBSymmetryData::operator=(), OBTorsionData::operator=(), and OBAngleData::operator=().