#include <openbabel/obmolecformat.h>
Public Types | |
typedef std::map< std::string, unsigned > | NameIndexType |
typedef std::map< const char *, OBPlugin *, CharPtrLess > | PluginMapType |
typedef PluginMapType::const_iterator | PluginIterator |
Public Member Functions | |
OBMoleculeFormat () | |
virtual bool | ReadChemObject (OBConversion *pConv) |
virtual bool | WriteChemObject (OBConversion *pConv) |
const std::type_info & | GetType () |
const char * | TypeID () |
virtual bool | ReadMolecule (OBBase *, OBConversion *) |
virtual bool | WriteMolecule (OBBase *, OBConversion *) |
virtual const char * | Description ()=0 |
virtual const char * | TargetClassDescription () |
virtual const char * | SpecificationURL () |
const char * | GetMIMEType () |
virtual unsigned int | Flags () |
virtual int | SkipObjects (int, OBConversion *) |
virtual OBFormat * | MakeNewInstance () |
int | RegisterFormat (const char *ID, const char *MIME=NULL) |
virtual bool | Display (std::string &txt, const char *param, const char *ID=NULL) |
virtual OBPlugin * | MakeInstance (const std::vector< std::string > &) |
const char * | GetID () const |
virtual PluginMapType & | GetMap () const =0 |
Static Public Member Functions | |
static bool | ReadChemObjectImpl (OBConversion *pConv, OBFormat *) |
static bool | WriteChemObjectImpl (OBConversion *pConv, OBFormat *) |
static bool | ReadNameIndex (NameIndexType &index, const std::string &datafilename, OBFormat *pInFormat) |
static OBFormat * | FormatFromMIME (const char *MIME) |
static OBPlugin * | GetPlugin (const char *Type, const char *ID) |
static bool | ListAsVector (const char *PluginID, const char *param, std::vector< std::string > &vlist) |
static void | List (const char *PluginID, const char *param=NULL, std::ostream *os=&std::cout) |
static std::string | ListAsString (const char *PluginID, const char *param=NULL) |
static std::string | FirstLine (const char *txt) |
static PluginIterator | Begin (const char *PluginID) |
static PluginIterator | End (const char *PluginID) |
Routines to handle the -C option for combining data from several OBMols | |
static bool | DeferMolOutput (OBMol *pmol, OBConversion *pConv, OBFormat *pF) |
static bool | OutputDeferredMols (OBConversion *pConv) |
static bool | DeleteDeferredMols () |
static OBMol * | MakeCombinedMolecule (OBMol *pFirst, OBMol *pSecond) |
Static Protected Member Functions | |
static PluginMapType & | PluginMap () |
static PluginMapType & | GetTypeMap (const char *PluginID) |
static OBPlugin * | BaseFindType (PluginMapType &Map, const char *ID) |
Protected Attributes | |
const char * | _id |
This class is not intended for direct use outside of Open Babel, unless you're writing a new format converting to or from an OBMol molecule. (e.g., see http://openbabel.sourceforge.net/wiki/HowTo:Add_A_New_File_Format).
An OBFormat which converts to and/or from OBMol can derive from this class to save duplicating the ReadChemObject() and/or WriteChemObject() methods. Derive directly from OBFormat if the object converted is not OBMol or if interaction with the framework is required during the execution of ReadMolecule() or WriteMolecule(), as for example in CMLFormat
typedef std::map<std::string, unsigned> NameIndexType |
typedef std::map<const char*, OBPlugin*, CharPtrLess> PluginMapType [inherited] |
typedef PluginMapType::const_iterator PluginIterator [inherited] |
OBMoleculeFormat | ( | ) | [inline] |
bool ReadChemObjectImpl | ( | OBConversion * | pConv, | |
OBFormat * | pFormat | |||
) | [static] |
Static routine, which can be called from elsewhere.
Referenced by XMLMoleculeFormat::ReadChemObject().
bool WriteChemObjectImpl | ( | OBConversion * | pConv, | |
OBFormat * | pFormat | |||
) | [static] |
Static routine, which can be called from elsewhere.
Referenced by XMLMoleculeFormat::WriteChemObject().
virtual bool ReadChemObject | ( | OBConversion * | pConv | ) | [inline, virtual] |
virtual bool WriteChemObject | ( | OBConversion * | pConv | ) | [inline, virtual] |
bool DeferMolOutput | ( | OBMol * | pmol, | |
OBConversion * | pConv, | |||
OBFormat * | pF | |||
) | [static] |
Defer output of a molecule until later, so it can be combined with others
Is a static function with *this as parameter so that it can be called from other format classes like XMLMoleculeFormat which are not derived from OBMoleculeFormat.
Referenced by OBMoleculeFormat::ReadChemObjectImpl().
bool OutputDeferredMols | ( | OBConversion * | pConv | ) | [static] |
Write out all molecules queued with DeferMolOutput.
Referenced by OBMoleculeFormat::WriteChemObjectImpl().
bool DeleteDeferredMols | ( | ) | [static] |
Delete the list of queued molecules from DeferMolOutput.
Referenced by OBMoleculeFormat::DeferMolOutput(), and OBMoleculeFormat::OutputDeferredMols().
pFirst
and pSecond
(i.e.)pFirst and pSecond and the objects they point to are not changed. (const modifiers difficult because class OBMol not designed appropriately)
Combining molecules: rules for each of the three parts Title: Use the title of pFirst unless it has none, when use that of pSecond. Warning if neither molecule has a title.
Structure
Referenced by OBMoleculeFormat::DeferMolOutput().
bool ReadNameIndex | ( | NameIndexType & | index, | |
const std::string & | datafilename, | |||
OBFormat * | pInFormat | |||
) | [static] |
Attempts to read the index file datafilename.obindx successively from the following directories:
NameIndexType::iterator itr = index.find(molecule_name); if(itr!=index.end()) unsigned pos_in_datafile = itr->second;
If no index is found, it is constructed from the datafile by reading all of it using the format pInFormat, and written to the directory containing the datafile. This means that this function can be used without worrying whether there is an index. It will be slow to execute the first time, but subsequent uses get the speed benefit of indexed access to the datafile.
The serialization and de-serialization of the NameIndexType is entirely in this routine and could possibly be improved. Currently re-hashing is done every time the index is read.
const std::type_info& GetType | ( | void | ) | [inline, virtual] |
const char* TypeID | ( | ) | [inline, inherited] |
Referenced by OBFormat::RegisterFormat().
virtual bool ReadMolecule | ( | OBBase * | , | |
OBConversion * | ||||
) | [inline, virtual, inherited] |
The "API" interface Read function.
Reads a single object. Does not make a new object on the heap; can be used with a pointer to an chem object on the heap or the stack.
Reimplemented in XMLMoleculeFormat.
Referenced by OBMoleculeFormat::DeferMolOutput(), OBConversion::Read(), and OBMoleculeFormat::ReadChemObjectImpl().
virtual bool WriteMolecule | ( | OBBase * | , | |
OBConversion * | ||||
) | [inline, virtual, inherited] |
The "API" interface Write function.
Writes a single object Does not delete the object; can be used with a pointer to an chem object on the heap or the stack.
Referenced by OBMoleculeFormat::OutputDeferredMols(), OBConversion::Write(), and OBMoleculeFormat::WriteChemObjectImpl().
virtual const char* Description | ( | ) | [pure virtual, inherited] |
Information on this format. Printed out in response to -Hxxx option where xxx id the id of the format.
Must be provided by each format class. Can include a list of command line Options. These may be used to construction check boxes, radio buttons etc for GUI interface.
Reimplemented from OBPlugin.
Referenced by OBFormat::Display(), OBConversion::GetNextFormat(), OBMoleculeFormat::OutputDeferredMols(), OBMoleculeFormat::ReadChemObjectImpl(), OBConversion::RegisterOptionParam(), and OBMoleculeFormat::WriteChemObjectImpl().
const char * TargetClassDescription | ( | ) | [virtual, inherited] |
A decription of the chemical object converted by this format.
If not provided, the object type used by the default format is used (usually OBMol).
Referenced by OBConversion::ReportNumberConverted().
virtual const char* SpecificationURL | ( | ) | [inline, virtual, inherited] |
const char* GetMIMEType | ( | ) | [inline, inherited] |
Chemical MIME type associated with this file type (if any).
virtual unsigned int Flags | ( | ) | [inline, virtual, inherited] |
Decribes the capabilities of the format (Read only etc.).
Currently, can be a bitwise OR of any of the following NOTREADABLE READONEONLY NOTWRITABLE WRITEONEONLY DEFAULTFORMAT READBINARY WRITEBINARY READXML
Referenced by OBConversion::AddChemObject(), OBConversion::Convert(), OBFormat::Display(), OBConversion::FullConvert(), OBConversion::GetNextFormat(), OBConversion::InstallStreamFilter(), OBConversion::OpenAndSetFormat(), OBMoleculeFormat::ReadChemObjectImpl(), OBConversion::ReadFile(), OBFormat::RegisterFormat(), OBConversion::SetInFormat(), OBConversion::SetOutFormat(), and OBConversion::WriteFile().
virtual int SkipObjects | ( | int | , | |
OBConversion * | ||||
) | [inline, virtual, inherited] |
Skip past first n objects in input stream (or current one with n=0).
Reimplemented in XMLBaseFormat.
Referenced by OBConversion::Convert(), and OBConversion::SetStartAndEnd().
virtual OBFormat* MakeNewInstance | ( | ) | [inline, virtual, inherited] |
int RegisterFormat | ( | const char * | ID, | |
const char * | MIME = NULL | |||
) | [inherited] |
Referenced by OBConversion::RegisterFormat().
bool Display | ( | std::string & | txt, | |
const char * | param, | |||
const char * | ID = NULL | |||
) | [virtual, inherited] |
Provides a description in txt of the format specified by itr. If param starts with "in", read", "out" or "write" only the appropriate formats are output. The others return false. If param contains "verbose", the whole description is output.
Reimplemented from OBPlugin.
OBFormat * FormatFromMIME | ( | const char * | MIME | ) | [static, inherited] |
Referenced by OBConversion::FormatFromMIME().
virtual OBPlugin* MakeInstance | ( | const std::vector< std::string > & | ) | [inline, virtual, inherited] |
Make a new instance of the class. See OpTransform, OBGroupContrib, SmartsDescriptor classes for derived versions. Usually, the first parameter is the classname, the next three are parameters(ID, filename, description) for a constructor, and the rest data.
Reimplemented in OBGroupContrib, and OpTransform.
Referenced by OBConversion::LoadFormatFiles().
static OBPlugin* GetPlugin | ( | const char * | Type, | |
const char * | ID | |||
) | [inline, static, inherited] |
Get a pointer to a plugin from its type and ID. Return NULL if not found. Not cast to Type*.
Referenced by OBConversion::LoadFormatFiles().
const char* GetID | ( | ) | const [inline, inherited] |
Return the ID of the sub-type instance.
Referenced by OBPlugin::Display(), OBFormat::Display(), and OBDescriptor::PredictAndSave().
bool ListAsVector | ( | const char * | PluginID, | |
const char * | param, | |||
std::vector< std::string > & | vlist | |||
) | [static, inherited] |
Output a list of sub-type classes of the the type PluginID, or, if PluginID is "plugins" or empty, a list of the base types. If PluginID is not recognized or is NULL, the base types are output and the return is false.
Referenced by OBConversion::GetSupportedInputFormat(), OBConversion::GetSupportedOutputFormat(), and OBPlugin::List().
void List | ( | const char * | PluginID, | |
const char * | param = NULL , |
|||
std::ostream * | os = &std::cout | |||
) | [static, inherited] |
As ListAsVector but sent to an ostream with a default of cout if not specified.
Referenced by OBPlugin::ListAsString().
string ListAsString | ( | const char * | PluginID, | |
const char * | param = NULL | |||
) | [static, inherited] |
As ListAsVector but returns a string containing the list.
string FirstLine | ( | const char * | txt | ) | [static, inherited] |
Utility function to return only the first line of a string.
Referenced by OBPlugin::Display(), OBFormat::Display(), and OBOp::OpOptions().
static PluginIterator Begin | ( | const char * | PluginID | ) | [inline, static, inherited] |
Return an iterator at the start of the map of the plugin types PluginID or, if there is no such map, the end of the top level plugin map.
Referenced by OBConversion::GetNextFormat(), and OBOp::OpOptions().
static PluginIterator End | ( | const char * | PluginID | ) | [inline, static, inherited] |
Referenced by OBConversion::GetNextFormat(), and OBOp::OpOptions().
virtual PluginMapType& GetMap | ( | ) | const [pure virtual, inherited] |
static PluginMapType& PluginMap | ( | ) | [inline, static, protected, inherited] |
Returns a reference to the map of the plugin types. Is a function rather than a static member variable to avoid initialization problems.
Referenced by OBPlugin::GetTypeMap(), OBPlugin::ListAsVector(), and OBFormat::RegisterFormat().
OBPlugin::PluginMapType & GetTypeMap | ( | const char * | PluginID | ) | [static, protected, inherited] |
Returns the map of a particular plugin type, e.g. GetMapType("fingerprints").
static OBPlugin* BaseFindType | ( | PluginMapType & | Map, | |
const char * | ID | |||
) | [inline, static, protected, inherited] |
Returns the type with the specified ID, or NULL if not found. Will be cast to the appropriate class in the calling routine.
const char* _id [protected, inherited] |
Referenced by OBFormat::RegisterFormat().