00001 /********************************************************************** 00002 obconversion.cpp - Declarations for OBFormat 00003 00004 Copyright (C) 2004-2007 by Chris Morley 00005 Some portions Copyright (C) 2005-2007 by Geoffrey Hutchison 00006 00007 This file is part of the Open Babel project. 00008 For more information, see <http://openbabel.sourceforge.net/> 00009 00010 This program is free software; you can redistribute it and/or modify 00011 it under the terms of the GNU General Public License as published by 00012 the Free Software Foundation version 2 of the License. 00013 00014 This program is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 ***********************************************************************/ 00019 #ifndef OB_FORMAT_H 00020 #define OB_FORMAT_H 00021 #include <openbabel/babelconfig.h> 00022 #include <openbabel/plugin.h> 00023 00024 namespace OpenBabel 00025 { 00026 class OBBase; 00027 class OBConversion; 00028 00030 #define NOTREADABLE 0x01 00031 #define READONEONLY 0x02 00032 #define READBINARY 0x04 00033 #define ZEROATOMSOK 0x08 00034 #define NOTWRITABLE 0x10 00035 #define WRITEONEONLY 0x20 00036 #define WRITEBINARY 0x40 00037 #define READXML 0x80 00038 #define DEFAULTFORMAT 0x4000 00039 00041 // class introduction in obconversion.cpp 00042 class OBCONV OBFormat : public OBPlugin 00043 { 00044 //Macro to include functions to handle plugin operations 00045 MAKE_PLUGIN(OBFormat); 00046 00047 public: 00048 00050 OBFormat(){} 00051 00052 const char* TypeID(){ return "formats"; } 00053 00055 00059 virtual bool ReadMolecule(OBBase* /*pOb*/, OBConversion* /*pConv*/) 00060 { std::cerr << "Not a valid input format"; return false;} 00061 00063 00067 virtual bool ReadChemObject(OBConversion* /*pConv*/) 00068 { std::cerr << "Not a valid input format"; return false;} 00069 00071 00076 virtual bool WriteMolecule(OBBase* /*pOb*/, OBConversion* /*pConv*/) 00077 { std::cerr << "Not a valid output format"; return false;} 00078 00080 00084 virtual bool WriteChemObject(OBConversion* /*pConv*/) 00085 { std::cerr << "Not a valid output format"; return false;} 00086 00088 00092 virtual const char* Description()=0; 00093 00095 00097 virtual const char* TargetClassDescription(); 00098 00100 00103 virtual const std::type_info& GetType(); 00104 00106 virtual const char* SpecificationURL() { return ""; } 00107 00109 const char* GetMIMEType() { return pMime; } 00110 00112 00116 virtual unsigned int Flags() { return 0;}; 00117 00119 00121 virtual int SkipObjects(int /*n*/, OBConversion* /*pConv*/) 00122 { 00123 return 0; //shows not implemented in the format class 00124 }; 00125 00127 00131 virtual OBFormat* MakeNewInstance() 00132 { 00133 return NULL; //shows not implemented in the format class 00134 } 00135 00136 //New functions since OBFormat is derived from OBPlugin 00137 //\brief Called from, and an alternative to, OBConversion::RegisterFormat(); 00138 int RegisterFormat(const char* ID, const char* MIME = NULL); 00139 00144 virtual bool Display(std::string& txt, const char* param, const char* ID=NULL); 00145 00146 static OBFormat* FormatFromMIME(const char* MIME); 00147 00148 private: 00149 static PluginMapType &FormatsMIMEMap() 00150 { 00151 static PluginMapType m; 00152 return m; 00153 } 00154 00155 const char* pMime; 00156 00157 /* Functions provided by the MAKE_PLUGIN macro 00158 00160 Not currently used for formats 00161 OBFormat(const char* ID, bool IsDefault=false); 00162 00164 static OBFormat* FindType(const char* ID); 00165 00166 */}; 00167 00168 }//namespace 00169 #endif 00170
This file is part of the documentation for Open Babel, version 2.2.0.