Loading...
Searching...
No Matches
format.h
Go to the documentation of this file.
/**********************************************************************
obconversion.cpp - Declarations for OBFormat
Copyright (C) 2004-2007 by Chris Morley
Some portions Copyright (C) 2005-2007 by Geoffrey Hutchison
This file is part of the Open Babel project.
For more information, see <http://openbabel.org/>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
***********************************************************************/
#ifndef OB_FORMAT_H
#define OB_FORMAT_H
#include <openbabel/babelconfig.h>
#include <openbabel/plugin.h>
#include <typeinfo>
namespace OpenBabel
{
class OBBase;
class OBConversion;
#define NOTREADABLE 0x01
#define READONEONLY 0x02
#define READBINARY 0x04
#define ZEROATOMSOK 0x08
#define NOTWRITABLE 0x10
#define WRITEONEONLY 0x20
#define WRITEBINARY 0x40
#define READXML 0x80
#define DEPICTION2D 0x100
#define DEFAULTFORMAT 0x4000
// class introduction in obconversion.cpp
class OBCONV OBFormat : public OBPlugin
{
//Macro to include functions to handle plugin operations
MAKE_PLUGIN(OBFormat);
public:
OBFormat(){}
const char* TypeID(){ return "formats"; }
virtual bool ReadMolecule(OBBase* /*pOb*/, OBConversion* /*pConv*/)
{ std::cerr << "HIER" << std::endl;
std::cerr << "Not a valid input format"; return false;}
virtual bool ReadChemObject(OBConversion* /*pConv*/)
{ std::cerr << "Not a valid input format"; return false;}
virtual bool WriteMolecule(OBBase* /*pOb*/, OBConversion* /*pConv*/)
{ std::cerr << "Not a valid output format"; return false;}
virtual bool WriteChemObject(OBConversion* /*pConv*/)
{ std::cerr << "Not a valid output format"; return false;}
virtual const char* Description()=0;
virtual const char* TargetClassDescription();
virtual const std::type_info& GetType();
virtual const char* SpecificationURL() { return ""; }
virtual const char* GetMIMEType() { return pMime; }
virtual unsigned int Flags() { return 0;};
virtual int SkipObjects(int /*n*/, OBConversion* /*pConv*/)
{
return 0; //shows not implemented in the format class
};
virtual OBFormat* MakeNewInstance()
{
return nullptr; //shows not implemented in the format class
}
//New functions since OBFormat is derived from OBPlugin
//\brief Called from, and an alternative to, OBConversion::RegisterFormat();
int RegisterFormat(const char* ID, const char* MIME = nullptr);
virtual bool Display(std::string& txt, const char* param, const char* ID=nullptr);
static OBFormat* FormatFromMIME(const char* MIME);
private:
static PluginMapType &FormatsMIMEMap()
{
static PluginMapType m;
return m;
}
const char* pMime;
/* Functions provided by the MAKE_PLUGIN macro
Not currently used for formats
OBFormat(const char* ID, bool IsDefault=false);
static OBFormat* FindType(const char* ID);
*/};
}//namespace
#endif
OpenBabel::OBBase
Base Class.
Definition base.h:240
OpenBabel::OBConversion
Class to convert from one format to another.
Definition obconversion.h:60
OpenBabel::OBFormat
Base class for file formats.
Definition format.h:45
OpenBabel::OBFormat::OBFormat
OBFormat()
Default constructor. Registration via RegisterFormat(), not via constructor as in other plugins.
Definition format.h:52
OpenBabel::OBFormat::TargetClassDescription
virtual const char * TargetClassDescription()
A decription of the chemical object converted by this format.
Definition format.cpp:46
OpenBabel::OBFormat::ReadMolecule
virtual bool ReadMolecule(OBBase *, OBConversion *)
The "API" interface Read function.
Definition format.h:61
OpenBabel::OBFormat::SkipObjects
virtual int SkipObjects(int, OBConversion *)
Skip past first n objects in input stream (or current one with n=0).
Definition format.h:124
OpenBabel::OBFormat::MakeNewInstance
virtual OBFormat * MakeNewInstance()
Definition format.h:134
OpenBabel::OBFormat::WriteChemObject
virtual bool WriteChemObject(OBConversion *)
The "Convert" interface Write function.
Definition format.h:87
OpenBabel::OBFormat::ReadChemObject
virtual bool ReadChemObject(OBConversion *)
The "Convert" interface Read function.
Definition format.h:70
OpenBabel::OBFormat::WriteMolecule
virtual bool WriteMolecule(OBBase *, OBConversion *)
The "API" interface Write function.
Definition format.h:79
OpenBabel::OBFormat::Description
virtual const char * Description()=0
Information on this format. Printed out in response to -Hxxx option where xxx id the id of the format...
OpenBabel::OBFormat::GetType
virtual const std::type_info & GetType()
Definition format.cpp:56
OpenBabel::OBFormat::Flags
virtual unsigned int Flags()
Decribes the capabilities of the format (Read only etc.).
Definition format.h:119
OpenBabel::OBFormat::GetMIMEType
virtual const char * GetMIMEType()
Chemical MIME type associated with this file type (if any).
Definition format.h:112
OpenBabel::OBFormat::TypeID
const char * TypeID()
Redefined by each plugin type: "formats", "fingerprints", etc.
Definition format.h:54
OpenBabel::OBFormat::SpecificationURL
virtual const char * SpecificationURL()
Web address where the format is defined.
Definition format.h:109
OpenBabel::OBPlugin
Base class for all types of dynamic classes discovered at runtime.
Definition plugin.h:53
MAKE_PLUGIN
#define MAKE_PLUGIN(BaseClass)
Definition plugin.h:195
OpenBabel
Global namespace for all Open Babel code.
Definition alias.h:23
plugin.h
Simplify 'plugin' classes to be discovered and/or loaded at runtime.