#include <openbabel/base.h>
Inheritance diagram for OBBase:
Public Member Functions | |
virtual | ~OBBase () |
virtual bool | Clear () |
virtual OBBase * | DoTransformations (const std::map< std::string, std::string > *) |
template<class T> | |
T * | CastAndClear (bool clear=true) |
Generic data handling methods (via OBGenericData) | |
bool | HasData (const std::string &) |
bool | HasData (const char *) |
bool | HasData (const unsigned int type) |
void | DeleteData (unsigned int type) |
void | DeleteData (OBGenericData *) |
void | DeleteData (std::vector< OBGenericData * > &) |
void | SetData (OBGenericData *d) |
unsigned int | DataSize () const |
OBGenericData * | GetData (const unsigned int type) |
OBGenericData * | GetData (const std::string &) |
OBGenericData * | GetData (const char *) |
std::vector< OBGenericData * > & | GetData () |
std::vector< OBGenericData * > | GetData (DataOrigin source) |
OBDataIterator | BeginData () |
OBDataIterator | EndData () |
Static Public Member Functions | |
static const char * | ClassDescription () |
Protected Attributes | |
std::vector< OBGenericData * > | _vdata |
The various classes (Atom, Bond, Molecule) inherit from base classes-- OBBase is largely a placeholder class. It also allows adding, deleting, and retrieving OBGenericData objects, which are ways to store arbitrary data for any atom, bond, molecule, or residue.
For example, a graphics program may want to allow users to add labels to individual atoms:
string atomLabel; // e.g., from the user adding annotation to an atom if (!atom.HasData("UserLabel")) // stored textual data as an OBPairData { OBPairData *label = new OBPairData; label->SetAttribute("UserLabel"); label->SetValue(atomLabel); label->SetOrigin(userInput); // set by user, not by Open Babel atom.SetData(label); }
This class is also important in the OBConversion class. Any derived class of OBBase can be supported in reading or writing data. While most OBFormat "translators" are designed around reading molecular data, the OBConversion framework can support any base object. For example OBReaction supports reading and writing reaction files, OBGrid supports reading and writing 2D or 3D "grids" of numeric data.
Therefore if you want to expand the range of input or output via the OBConversion and OBFormat classes, you will also need to make sure you define an appropriate derived class from OBBase.
virtual ~OBBase | ( | ) | [inline, virtual] |
bool Clear | ( | void | ) | [virtual] |
Clear any and all data associated with this object.
This method can be called by OBConversion::Read() before reading data. Derived classes should be sure to call OBBase::Clear() to remove inherited generic data.
virtual OBBase* DoTransformations | ( | const std::map< std::string, std::string > * | ) | [inline, virtual] |
Perform a set of transformations specified by the user
Typically these are program options to filter or modify an object For example, see OBMol::DoTransformations() and OBMol::ClassDescription()
Reimplemented in OBMol.
static const char* ClassDescription | ( | ) | [inline, static] |
Reimplemented in OBMol.
T* CastAndClear | ( | bool | clear = true |
) | [inline] |
By default clears the object. Called from ReadMolecule of most format classes.
bool HasData | ( | const std::string & | ) |
bool HasData | ( | const char * | ) |
bool HasData | ( | const unsigned int | type | ) |
void DeleteData | ( | unsigned int | type | ) |
Delete any data matching the given OBGenericDataType.
void DeleteData | ( | OBGenericData * | ) |
Delete the given generic data from this object.
void DeleteData | ( | std::vector< OBGenericData * > & | ) |
Delete all of the given generic data from this object.
void SetData | ( | OBGenericData * | d | ) | [inline] |
Adds a data object; does nothing if d==NULL.
unsigned int DataSize | ( | ) | const [inline] |
OBGenericData * GetData | ( | const unsigned int | type | ) |
OBGenericData * GetData | ( | const std::string & | ) |
OBGenericData * GetData | ( | const char * | ) |
std::vector<OBGenericData*>& GetData | ( | ) | [inline] |
std::vector< OBGenericData * > GetData | ( | DataOrigin | source | ) |
OBDataIterator BeginData | ( | ) | [inline] |
OBDataIterator EndData | ( | ) | [inline] |
std::vector<OBGenericData*> _vdata [protected] |
Custom data.