OBBase Class Reference
Base Class. More...
#include <openbabel/base.h>

Public Member Functions | |
virtual | ~OBBase () |
virtual bool | Clear () |
virtual OBBase * | DoTransformations (const std::map< std::string, std::string > *, OBConversion *) |
template<class T > | |
T * | CastAndClear (bool clear=true) |
virtual const char * | GetTitle (bool replaceNewlines=true) const |
virtual void | SetTitle (const char *) |
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 * > &) |
bool | DeleteData (const std::string &s) |
void | SetData (OBGenericData *d) |
void | CloneData (OBGenericData *d) |
size_t | DataSize () const |
OBGenericData * | GetData (const unsigned int type) |
OBGenericData * | GetData (const std::string &) |
OBGenericData * | GetData (const char *) |
std::vector< OBGenericData * > | GetAllData (const unsigned int type) |
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 |
Detailed Description
Base Class.
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.
Constructor & Destructor Documentation
virtual ~OBBase | ( | ) | [inline, virtual] |
Member Function Documentation
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.
- Returns:
- Whether the call was successful.
- Since:
- version 2.1.
Reimplemented in OBAtom, OBMol, OBReaction, and OBResidue.
Referenced by OBResidue::Clear(), OBMol::Clear(), and OBAtom::Clear().
virtual OBBase* DoTransformations | ( | const std::map< std::string, std::string > * | , | |
OBConversion * | ||||
) | [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() Base type does nothing
Reimplemented in OBMol.
static const char* ClassDescription | ( | ) | [inline, static] |
- Returns:
- A list of descriptions of command-line options for DoTransformations()
Reimplemented in OBMol, and OBReaction.
T* CastAndClear | ( | bool | clear = true |
) | [inline] |
By default clears the object. Called from ReadMolecule of most format classes.
virtual const char* GetTitle | ( | bool | replaceNewlines = true |
) | const [inline, virtual] |
Base type does nothing Made virtual around r3535 to simplify code which passes around OBBase*.
Reimplemented in OBMol.
Referenced by OBMoleculeFormat::DoOutputOptions().
virtual void SetTitle | ( | const char * | ) | [inline, virtual] |
Reimplemented in OBMol.
Referenced by OBMoleculeFormat::DoOutputOptions().
bool HasData | ( | const std::string & | s | ) |
- Returns:
- whether the generic attribute/value pair exists
Referenced by OBMol::AddAtom(), OBDepict::DrawMolecule(), OBMol::FindAngles(), OBMol::FindLSSR(), OBMol::FindSSSR(), OBMol::FindTorsions(), OBForceField::GetAtomTypes(), OBForceField::GetConformers(), OBForceField::GetCoordinates(), OBMol::GetEnergies(), OBMol::GetEnergy(), OBMol::GetLSSR(), OBForceField::GetPartialCharges(), OBMol::GetSSSR(), OBBase::HasData(), OBDescriptor::MatchPairData(), OBMol::NewAtom(), OBMol::operator=(), OBMoleculeFormat::ReadChemObjectImpl(), and OBMol::SetEnergies().
bool HasData | ( | const char * | s | ) |
- Returns:
- whether the generic attribute/value pair exists
bool HasData | ( | const unsigned int | type | ) |
- Returns:
- whether the generic attribute/value pair exists, for a given OBGenericDataType
void DeleteData | ( | unsigned int | type | ) |
Delete any data matching the given OBGenericDataType.
Referenced by OBMol::AddAtom(), OBMol::BeginModify(), OpenBabel::CanonicalLabels(), OBDescriptor::DeleteProperties(), OBMol::EndModify(), OBMol::FindLSSR(), OBMol::FindSSSR(), OBMol::NewAtom(), OBMol::RenumberAtoms(), and OBForceField::Setup().
void DeleteData | ( | OBGenericData * | gd | ) |
Delete the given generic data from this object.
void DeleteData | ( | std::vector< OBGenericData * > & | vg | ) |
Delete all of the given generic data from this object.
bool DeleteData | ( | const std::string & | s | ) |
Deletes the generic data with the specified attribute, returning false if not found.
void SetData | ( | OBGenericData * | d | ) | [inline] |
Adds a data object; does nothing if d==NULL.
Referenced by OBMol::AddBond(), OBGastChrg::AssignPartialCharges(), OpenBabel::CalcSignedVolume(), OBMol::DoTransformations(), OBAtom::Duplicate(), AliasData::Expand(), OBMol::FindAngles(), OBMol::FindLSSR(), OBMol::FindSSSR(), OBMol::FindTorsions(), OBForceField::GetAtomTypes(), OBForceField::GetConformers(), OBForceField::GetCoordinates(), OBMol::GetEnergies(), OBMol::GetEnergy(), OBMol::GetFormula(), OBMol::GetLSSR(), OBMol::GetNextFragment(), OBForceField::GetPartialCharges(), OBMol::GetSSSR(), OBMoleculeFormat::MakeCombinedMolecule(), OBMol::operator=(), OBDescriptor::PredictAndSave(), OBMol::SetEnergies(), and OBMol::SetFormula().
void CloneData | ( | OBGenericData * | d | ) |
Adds a copy of a data object; does nothing if d == NULL
- Since:
- version 2.2
Referenced by OBMol::AddBond().
size_t DataSize | ( | ) | const [inline] |
- Returns:
- the number of OBGenericData items attached to this molecule.
OBGenericData * GetData | ( | const unsigned int | type | ) |
- Returns:
- the first matching data for a given type from OBGenericDataType or NULL if nothing matches
Referenced by OpenBabel::CalcSignedVolume(), OpenBabel::CorrectChirality(), OBDepict::DrawMolecule(), AliasData::Expand(), OBDescriptor::FilterCompare(), OpenBabel::GetAtomSymClass(), OBForceField::GetAtomTypes(), OBForceField::GetConformers(), OBForceField::GetCoordinates(), OBMol::GetNextFragment(), OBForceField::GetPartialCharges(), OBDescriptor::GetValues(), OBMoleculeFormat::MakeCombinedMolecule(), OBMolAngleIter::OBMolAngleIter(), OBMolRingIter::OBMolRingIter(), OBMolTorsionIter::OBMolTorsionIter(), OBMol::operator=(), and OBDescriptor::PredictAndSave().
OBGenericData * GetData | ( | const std::string & | s | ) |
- Returns:
- any data matching the given attribute name or NULL if nothing matches
- the value given an attribute name
OBGenericData * GetData | ( | const char * | s | ) |
- Returns:
- any data matching the given attribute name or NULL if nothing matches
- the value given an attribute name
std::vector< OBGenericData * > GetAllData | ( | const unsigned int | type | ) |
- Returns:
- the all matching data for a given type from OBGenericDataType or an empty vector if nothing matches
- Since:
- version 2.2
Referenced by OpenBabel::CanonicalLabels(), OBBuilder::CorrectStereoAtoms(), and OBBuilder::CorrectStereoBonds().
std::vector<OBGenericData*>& GetData | ( | ) | [inline] |
- Returns:
- all data, suitable for iterating
Referenced by OBMol::BeginModify(), OBMol::DoTransformations(), OBBase::GetData(), OBMol::GetEnergies(), OBMol::GetEnergy(), OBMol::GetFormula(), OBMol::GetLSSR(), OBMol::GetSSSR(), OBMol::SetEnergies(), and OBMol::SetFormula().
std::vector< OBGenericData * > GetData | ( | DataOrigin | source | ) |
- Returns:
- all data with a specific origin, suitable for iterating
OBDataIterator BeginData | ( | ) | [inline] |
- Returns:
- An iterator pointing to the beginning of the data
Referenced by OBMol::AddAtom(), OBMol::AddBond(), OBAtom::Duplicate(), OBMoleculeFormat::MakeCombinedMolecule(), OBMol::NewAtom(), and OBMol::operator=().
OBDataIterator EndData | ( | ) | [inline] |
- Returns:
- An iterator pointing to the end of the data
Referenced by OBMol::AddAtom(), OBMol::AddBond(), OBAtom::Duplicate(), OBMoleculeFormat::MakeCombinedMolecule(), OBMol::NewAtom(), and OBMol::operator=().
Member Data Documentation
std::vector<OBGenericData*> _vdata [protected] |
Custom data.
Referenced by OBBase::Clear(), OBBase::CloneData(), OBBase::DeleteData(), OBAtom::Duplicate(), OBBase::GetAllData(), OBBase::GetData(), OBBase::HasData(), OBBond::OBBond(), OBMol::OBMol(), and OBResidue::OBResidue().
The documentation for this class was generated from the following files: