* src/base.h, src/base.cpp: Add "const" qualifiers to

OBGenericData methods.

        * scripts/*/*.cpp: Regenerated using SWIG for above changes.
This commit is contained in:
Geoffrey Hutchison
2006-06-14 21:42:00 +00:00
parent e6e021a7a9
commit 170e0af579
4 changed files with 394 additions and 397 deletions
+49 -47
View File
@@ -20268,35 +20268,37 @@ XS(_wrap_OBBase_HasData__SWIG_0) {
bool result;
void *argp1 = 0 ;
int res1 = 0 ;
void *argp2 = 0 ;
int res2 = 0 ;
int res2 = SWIG_OLDOBJ ;
int argvi = 0;
dXSARGS;
if ((items < 2) || (items > 2)) {
SWIG_croak("Usage: OBBase_HasData(self,std::string &);");
SWIG_croak("Usage: OBBase_HasData(self,std::string const &);");
}
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OpenBabel__OBBase, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OBBase_HasData" "', argument " "1"" of type '" "OpenBabel::OBBase *""'");
}
arg1 = reinterpret_cast< OpenBabel::OBBase * >(argp1);
res2 = SWIG_ConvertPtr(ST(1), &argp2, SWIGTYPE_p_std__string, 0 );
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "OBBase_HasData" "', argument " "2"" of type '" "std::string &""'");
{
std::string *ptr = (std::string *)0;
res2 = SWIG_AsPtr_std_string SWIG_PERL_CALL_ARGS_2(ST(1), &ptr);
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "OBBase_HasData" "', argument " "2"" of type '" "std::string const &""'");
}
if (!ptr) {
SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "OBBase_HasData" "', argument " "2"" of type '" "std::string const &""'");
}
arg2 = ptr;
}
if (!argp2) {
SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "OBBase_HasData" "', argument " "2"" of type '" "std::string &""'");
}
arg2 = reinterpret_cast< std::string * >(argp2);
result = (bool)(arg1)->HasData(*arg2);
result = (bool)(arg1)->HasData((std::string const &)*arg2);
ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ;
if (SWIG_IsNewObj(res2)) delete arg2;
XSRETURN(argvi);
fail:
if (SWIG_IsNewObj(res2)) delete arg2;
SWIG_croak_null();
}
}
@@ -20400,9 +20402,10 @@ XS(_wrap_OBBase_HasData) {
_rankm += _pi;
_pi *= SWIG_MAXCASTRANK;
{
void *vptr = 0;
int res = SWIG_ConvertPtr(ST(1), &vptr, SWIGTYPE_p_std__string, 0);
_v = SWIG_CheckState(res);
{
int res = SWIG_AsVal_unsigned_SS_int SWIG_PERL_CALL_ARGS_2(ST(1), NULL);
_v = SWIG_CheckState(res);
}
}
if (!_v) goto check_1;
_ranki += _v*_pi;
@@ -20430,10 +20433,8 @@ XS(_wrap_OBBase_HasData) {
_rankm += _pi;
_pi *= SWIG_MAXCASTRANK;
{
{
int res = SWIG_AsVal_unsigned_SS_int SWIG_PERL_CALL_ARGS_2(ST(1), NULL);
_v = SWIG_CheckState(res);
}
int res = SWIG_AsPtr_std_string SWIG_PERL_CALL_ARGS_2(ST(1), (std::string**)(0));
_v = SWIG_CheckState(res);
}
if (!_v) goto check_2;
_ranki += _v*_pi;
@@ -20478,9 +20479,9 @@ XS(_wrap_OBBase_HasData) {
dispatch:
switch(_index) {
case 1:
++PL_markstack_ptr; SWIG_CALLXS(_wrap_OBBase_HasData__SWIG_0); return;
case 2:
++PL_markstack_ptr; SWIG_CALLXS(_wrap_OBBase_HasData__SWIG_2); return;
case 2:
++PL_markstack_ptr; SWIG_CALLXS(_wrap_OBBase_HasData__SWIG_0); return;
case 3:
++PL_markstack_ptr; SWIG_CALLXS(_wrap_OBBase_HasData__SWIG_1); return;
}
@@ -20769,10 +20770,10 @@ XS(_wrap_OBBase_DataSize) {
}
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OpenBabel__OBBase, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OBBase_DataSize" "', argument " "1"" of type '" "OpenBabel::OBBase *""'");
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OBBase_DataSize" "', argument " "1"" of type '" "OpenBabel::OBBase const *""'");
}
arg1 = reinterpret_cast< OpenBabel::OBBase * >(argp1);
result = (unsigned int)(arg1)->DataSize();
result = (unsigned int)((OpenBabel::OBBase const *)arg1)->DataSize();
ST(argvi) = SWIG_From_unsigned_SS_int SWIG_PERL_CALL_ARGS_1(static_cast< unsigned int >(result)); argvi++ ;
XSRETURN(argvi);
@@ -20828,35 +20829,37 @@ XS(_wrap_OBBase_GetData__SWIG_1) {
OpenBabel::OBGenericData *result = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
void *argp2 = 0 ;
int res2 = 0 ;
int res2 = SWIG_OLDOBJ ;
int argvi = 0;
dXSARGS;
if ((items < 2) || (items > 2)) {
SWIG_croak("Usage: OBBase_GetData(self,std::string &);");
SWIG_croak("Usage: OBBase_GetData(self,std::string const &);");
}
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OpenBabel__OBBase, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OBBase_GetData" "', argument " "1"" of type '" "OpenBabel::OBBase *""'");
}
arg1 = reinterpret_cast< OpenBabel::OBBase * >(argp1);
res2 = SWIG_ConvertPtr(ST(1), &argp2, SWIGTYPE_p_std__string, 0 );
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "OBBase_GetData" "', argument " "2"" of type '" "std::string &""'");
{
std::string *ptr = (std::string *)0;
res2 = SWIG_AsPtr_std_string SWIG_PERL_CALL_ARGS_2(ST(1), &ptr);
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "OBBase_GetData" "', argument " "2"" of type '" "std::string const &""'");
}
if (!ptr) {
SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "OBBase_GetData" "', argument " "2"" of type '" "std::string const &""'");
}
arg2 = ptr;
}
if (!argp2) {
SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "OBBase_GetData" "', argument " "2"" of type '" "std::string &""'");
}
arg2 = reinterpret_cast< std::string * >(argp2);
result = (OpenBabel::OBGenericData *)(arg1)->GetData(*arg2);
result = (OpenBabel::OBGenericData *)(arg1)->GetData((std::string const &)*arg2);
ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OpenBabel__OBGenericData, 0 | SWIG_SHADOW); argvi++ ;
if (SWIG_IsNewObj(res2)) delete arg2;
XSRETURN(argvi);
fail:
if (SWIG_IsNewObj(res2)) delete arg2;
SWIG_croak_null();
}
}
@@ -20974,9 +20977,10 @@ XS(_wrap_OBBase_GetData) {
_rankm += _pi;
_pi *= SWIG_MAXCASTRANK;
{
void *vptr = 0;
int res = SWIG_ConvertPtr(ST(1), &vptr, SWIGTYPE_p_std__string, 0);
_v = SWIG_CheckState(res);
{
int res = SWIG_AsVal_unsigned_SS_int SWIG_PERL_CALL_ARGS_2(ST(1), NULL);
_v = SWIG_CheckState(res);
}
}
if (!_v) goto check_2;
_ranki += _v*_pi;
@@ -21004,10 +21008,8 @@ XS(_wrap_OBBase_GetData) {
_rankm += _pi;
_pi *= SWIG_MAXCASTRANK;
{
{
int res = SWIG_AsVal_unsigned_SS_int SWIG_PERL_CALL_ARGS_2(ST(1), NULL);
_v = SWIG_CheckState(res);
}
int res = SWIG_AsPtr_std_string SWIG_PERL_CALL_ARGS_2(ST(1), (std::string**)(0));
_v = SWIG_CheckState(res);
}
if (!_v) goto check_3;
_ranki += _v*_pi;
@@ -21054,9 +21056,9 @@ XS(_wrap_OBBase_GetData) {
case 1:
++PL_markstack_ptr; SWIG_CALLXS(_wrap_OBBase_GetData__SWIG_3); return;
case 2:
++PL_markstack_ptr; SWIG_CALLXS(_wrap_OBBase_GetData__SWIG_1); return;
case 3:
++PL_markstack_ptr; SWIG_CALLXS(_wrap_OBBase_GetData__SWIG_0); return;
case 3:
++PL_markstack_ptr; SWIG_CALLXS(_wrap_OBBase_GetData__SWIG_1); return;
case 4:
++PL_markstack_ptr; SWIG_CALLXS(_wrap_OBBase_GetData__SWIG_2); return;
}
@@ -28016,7 +28018,7 @@ XS(_wrap_OBResidue_GetBonds__SWIG_0) {
dXSARGS;
if ((items < 2) || (items > 2)) {
SWIG_croak("Usage: OBResidue_GetBonds(self,bool);");
SWIG_croak("Usage: OBResidue_GetBonds(self,exterior);");
}
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OpenBabel__OBResidue, 0 | 0 );
if (!SWIG_IsOK(res1)) {
+46 -40
View File
@@ -30922,8 +30922,7 @@ SWIGINTERN PyObject *_wrap_OBBase_HasData__SWIG_0(PyObject *SWIGUNUSEDPARM(self)
bool result;
void *argp1 = 0 ;
int res1 = 0 ;
void *argp2 = 0 ;
int res2 = 0 ;
int res2 = SWIG_OLDOBJ ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
@@ -30933,18 +30932,23 @@ SWIGINTERN PyObject *_wrap_OBBase_HasData__SWIG_0(PyObject *SWIGUNUSEDPARM(self)
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OBBase_HasData" "', argument " "1"" of type '" "OpenBabel::OBBase *""'");
}
arg1 = reinterpret_cast< OpenBabel::OBBase * >(argp1);
res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__string, 0 );
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "OBBase_HasData" "', argument " "2"" of type '" "std::string &""'");
{
std::string *ptr = (std::string *)0;
res2 = SWIG_AsPtr_std_string(obj1, &ptr);
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "OBBase_HasData" "', argument " "2"" of type '" "std::string const &""'");
}
if (!ptr) {
SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "OBBase_HasData" "', argument " "2"" of type '" "std::string const &""'");
}
arg2 = ptr;
}
if (!argp2) {
SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "OBBase_HasData" "', argument " "2"" of type '" "std::string &""'");
}
arg2 = reinterpret_cast< std::string * >(argp2);
result = (bool)(arg1)->HasData(*arg2);
result = (bool)(arg1)->HasData((std::string const &)*arg2);
resultobj = SWIG_From_bool(static_cast< bool >(result));
if (SWIG_IsNewObj(res2)) delete arg2;
return resultobj;
fail:
if (SWIG_IsNewObj(res2)) delete arg2;
return NULL;
}
@@ -31030,11 +31034,12 @@ SWIGINTERN PyObject *_wrap_OBBase_HasData(PyObject *self, PyObject *args) {
int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_OpenBabel__OBBase, 0);
_v = SWIG_CheckState(res);
if (_v) {
void *vptr = 0;
int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__string, 0);
_v = SWIG_CheckState(res);
{
int res = SWIG_AsVal_unsigned_SS_int(argv[1], NULL);
_v = SWIG_CheckState(res);
}
if (_v) {
return _wrap_OBBase_HasData__SWIG_0(self, args);
return _wrap_OBBase_HasData__SWIG_2(self, args);
}
}
}
@@ -31044,12 +31049,10 @@ SWIGINTERN PyObject *_wrap_OBBase_HasData(PyObject *self, PyObject *args) {
int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_OpenBabel__OBBase, 0);
_v = SWIG_CheckState(res);
if (_v) {
{
int res = SWIG_AsVal_unsigned_SS_int(argv[1], NULL);
_v = SWIG_CheckState(res);
}
int res = SWIG_AsPtr_std_string(argv[1], (std::string**)(0));
_v = SWIG_CheckState(res);
if (_v) {
return _wrap_OBBase_HasData__SWIG_2(self, args);
return _wrap_OBBase_HasData__SWIG_0(self, args);
}
}
}
@@ -31267,10 +31270,10 @@ SWIGINTERN PyObject *_wrap_OBBase_DataSize(PyObject *SWIGUNUSEDPARM(self), PyObj
if(!PyArg_UnpackTuple(args,(char *)"OBBase_DataSize",1,1,&obj0)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_OpenBabel__OBBase, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OBBase_DataSize" "', argument " "1"" of type '" "OpenBabel::OBBase *""'");
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OBBase_DataSize" "', argument " "1"" of type '" "OpenBabel::OBBase const *""'");
}
arg1 = reinterpret_cast< OpenBabel::OBBase * >(argp1);
result = (unsigned int)(arg1)->DataSize();
result = (unsigned int)((OpenBabel::OBBase const *)arg1)->DataSize();
resultobj = SWIG_From_unsigned_SS_int(static_cast< unsigned int >(result));
return resultobj;
fail:
@@ -31316,8 +31319,7 @@ SWIGINTERN PyObject *_wrap_OBBase_GetData__SWIG_1(PyObject *SWIGUNUSEDPARM(self)
OpenBabel::OBGenericData *result = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
void *argp2 = 0 ;
int res2 = 0 ;
int res2 = SWIG_OLDOBJ ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
@@ -31327,18 +31329,23 @@ SWIGINTERN PyObject *_wrap_OBBase_GetData__SWIG_1(PyObject *SWIGUNUSEDPARM(self)
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OBBase_GetData" "', argument " "1"" of type '" "OpenBabel::OBBase *""'");
}
arg1 = reinterpret_cast< OpenBabel::OBBase * >(argp1);
res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__string, 0 );
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "OBBase_GetData" "', argument " "2"" of type '" "std::string &""'");
{
std::string *ptr = (std::string *)0;
res2 = SWIG_AsPtr_std_string(obj1, &ptr);
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "OBBase_GetData" "', argument " "2"" of type '" "std::string const &""'");
}
if (!ptr) {
SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "OBBase_GetData" "', argument " "2"" of type '" "std::string const &""'");
}
arg2 = ptr;
}
if (!argp2) {
SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "OBBase_GetData" "', argument " "2"" of type '" "std::string &""'");
}
arg2 = reinterpret_cast< std::string * >(argp2);
result = (OpenBabel::OBGenericData *)(arg1)->GetData(*arg2);
result = (OpenBabel::OBGenericData *)(arg1)->GetData((std::string const &)*arg2);
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OpenBabel__OBGenericData, 0 | 0 );
if (SWIG_IsNewObj(res2)) delete arg2;
return resultobj;
fail:
if (SWIG_IsNewObj(res2)) delete arg2;
return NULL;
}
@@ -31427,11 +31434,12 @@ SWIGINTERN PyObject *_wrap_OBBase_GetData(PyObject *self, PyObject *args) {
int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_OpenBabel__OBBase, 0);
_v = SWIG_CheckState(res);
if (_v) {
void *vptr = 0;
int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__string, 0);
_v = SWIG_CheckState(res);
{
int res = SWIG_AsVal_unsigned_SS_int(argv[1], NULL);
_v = SWIG_CheckState(res);
}
if (_v) {
return _wrap_OBBase_GetData__SWIG_1(self, args);
return _wrap_OBBase_GetData__SWIG_0(self, args);
}
}
}
@@ -31441,12 +31449,10 @@ SWIGINTERN PyObject *_wrap_OBBase_GetData(PyObject *self, PyObject *args) {
int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_OpenBabel__OBBase, 0);
_v = SWIG_CheckState(res);
if (_v) {
{
int res = SWIG_AsVal_unsigned_SS_int(argv[1], NULL);
_v = SWIG_CheckState(res);
}
int res = SWIG_AsPtr_std_string(argv[1], (std::string**)(0));
_v = SWIG_CheckState(res);
if (_v) {
return _wrap_OBBase_GetData__SWIG_0(self, args);
return _wrap_OBBase_GetData__SWIG_1(self, args);
}
}
}
+210 -219
View File
@@ -2,7 +2,7 @@
base.cpp - Base classes to build a graph
Copyright (C) 1998-2001 by OpenEye Scientific Software, Inc.
Some portions Copyright (C) 2001-2005 by Geoffrey R. Hutchison
Some portions Copyright (C) 2001-2006 by Geoffrey R. Hutchison
This file is part of the Open Babel project.
For more information, see <http://openbabel.sourceforge.net/>
@@ -20,151 +20,142 @@ GNU General Public License for more details.
#include "babelconfig.h"
#include "base.h"
#if HAVE_IOSTREAM
#include <iostream>
#elif HAVE_IOSTREAM_H
#include <iostream.h>
#endif
#if HAVE_FSTREAM
#include <fstream>
#elif HAVE_FSTREAM_H
#include <fstream.h>
#endif
using namespace std;
//! Global namespace for all Open Babel code
namespace OpenBabel
{
bool OBBase::HasData(string &s)
{
bool OBBase::HasData(const string &s)
{
if (_vdata.empty())
return(false);
return(false);
vector<OBGenericData*>::iterator i;
for (i = _vdata.begin();i != _vdata.end();i++)
if ((*i)->GetAttribute() == s)
return(true);
if ((*i)->GetAttribute() == s)
return(true);
return(false);
}
}
bool OBBase::HasData(const char *s)
//returns true if the generic attribute/value pair exists
{
bool OBBase::HasData(const char *s)
//returns true if the generic attribute/value pair exists
{
if (_vdata.empty())
return(false);
return(false);
vector<OBGenericData*>::iterator i;
for (i = _vdata.begin();i != _vdata.end();i++)
if ((*i)->GetAttribute() == s)
return(true);
if ((*i)->GetAttribute() == s)
return(true);
return(false);
}
}
bool OBBase::HasData(unsigned int dt)
//returns true if the generic attribute/value pair exists
{
bool OBBase::HasData(const unsigned int dt)
//returns true if the generic attribute/value pair exists
{
if (_vdata.empty())
return(false);
return(false);
vector<OBGenericData*>::iterator i;
for (i = _vdata.begin();i != _vdata.end();i++)
if ((*i)->GetDataType() == dt)
return(true);
if ((*i)->GetDataType() == dt)
return(true);
return(false);
}
}
//! Returns the value given an attribute name
OBGenericData *OBBase::GetData(string &s)
{
//! Returns the value given an attribute name
OBGenericData *OBBase::GetData(const string &s)
{
vector<OBGenericData*>::iterator i;
for (i = _vdata.begin();i != _vdata.end();i++)
if ((*i)->GetAttribute() == s)
return(*i);
if ((*i)->GetAttribute() == s)
return(*i);
return(NULL);
}
}
//! Returns the value given an attribute name
OBGenericData *OBBase::GetData(const char *s)
{
//! Returns the value given an attribute name
OBGenericData *OBBase::GetData(const char *s)
{
vector<OBGenericData*>::iterator i;
for (i = _vdata.begin();i != _vdata.end();i++)
if ((*i)->GetAttribute() == s)
return(*i);
if ((*i)->GetAttribute() == s)
return(*i);
return(NULL);
}
}
OBGenericData *OBBase::GetData(unsigned int dt)
{
OBGenericData *OBBase::GetData(const unsigned int dt)
{
vector<OBGenericData*>::iterator i;
for (i = _vdata.begin();i != _vdata.end();i++)
if ((*i)->GetDataType() == dt)
return(*i);
if ((*i)->GetDataType() == dt)
return(*i);
return(NULL);
}
}
void OBBase::DeleteData(unsigned int dt)
{
void OBBase::DeleteData(unsigned int dt)
{
vector<OBGenericData*> vdata;
vector<OBGenericData*>::iterator i;
for (i = _vdata.begin();i != _vdata.end();i++)
if ((*i)->GetDataType() == dt)
delete *i;
else
vdata.push_back(*i);
if ((*i)->GetDataType() == dt)
delete *i;
else
vdata.push_back(*i);
_vdata = vdata;
}
}
void OBBase::DeleteData(vector<OBGenericData*> &vg)
{
void OBBase::DeleteData(vector<OBGenericData*> &vg)
{
vector<OBGenericData*> vdata;
vector<OBGenericData*>::iterator i,j;
bool del;
for (i = _vdata.begin();i != _vdata.end();i++)
{
{
del = false;
for (j = vg.begin();j != vg.end();j++)
if (*i == *j)
if (*i == *j)
{
del = true;
break;
del = true;
break;
}
if (del)
delete *i;
delete *i;
else
vdata.push_back(*i);
}
vdata.push_back(*i);
}
_vdata = vdata;
}
}
void OBBase::DeleteData(OBGenericData *gd)
{
void OBBase::DeleteData(OBGenericData *gd)
{
vector<OBGenericData*>::iterator i;
for (i = _vdata.begin();i != _vdata.end();i++)
if (*i == gd)
if (*i == gd)
{
delete *i;
_vdata.erase(i);
delete *i;
_vdata.erase(i);
}
}
}
/*
bool OBGraphBase::Match(OBGraphBase &g,bool singleMatch)
{
/*
bool OBGraphBase::Match(OBGraphBase &g,bool singleMatch)
{
SetFinishedMatch(false);
SetSingleMatch(singleMatch);
ClearMatches();
@@ -176,235 +167,235 @@ bool OBGraphBase::Match(OBGraphBase &g,bool singleMatch)
vector<OBNodeBase*>::iterator i;
for (node = g.Begin(i);node;node = g.Next(i))
if (!node->Visit && seed->Eval(node))
{
node->Visit = true;
seed->SetMatch(node);
Match(g,BgnMatch(),BgnMatch()->second.begin());
seed->SetMatch((OBNodeBase*)NULL);
node->Visit = false;
if (SingleMatch() && FinishedMatch())
break;
}
if (!node->Visit && seed->Eval(node))
{
node->Visit = true;
seed->SetMatch(node);
Match(g,BgnMatch(),BgnMatch()->second.begin());
seed->SetMatch((OBNodeBase*)NULL);
node->Visit = false;
if (SingleMatch() && FinishedMatch())
break;
}
g.SetVisitLock(false);
return(FinishedMatch());
}
}
bool OBGraphBase::Match(OBGraphBase &g,
vector<pair<OBNodeBase*,vector<OBEdgeBase*> > >::iterator i,
vector<OBEdgeBase*>::iterator j)
{
bool OBGraphBase::Match(OBGraphBase &g,
vector<pair<OBNodeBase*,vector<OBEdgeBase*> > >::iterator i,
vector<OBEdgeBase*>::iterator j)
{
//bail if only one match has been requested
if (SingleMatch() && FinishedMatch())
return(true);
return(true);
//full match completed
if (i == EndMatch() || (j == i->second.end() && (i+1) == EndMatch()))
{
SetFinishedMatch(true);
OBNodeBase *node;
vector<OBNodeBase*> vn;
vector<OBNodeBase*>::iterator i;
for (node = Begin(i);node;node = Next(i))
vn.push_back(node->GetMatch());
PushBack(vn);
SetFinishedMatch(true);
OBNodeBase *node;
vector<OBNodeBase*> vn;
vector<OBNodeBase*>::iterator i;
for (node = Begin(i);node;node = Next(i))
vn.push_back(node->GetMatch());
PushBack(vn);
return(true);
return(true);
}
//handle next seed of disconnected pattern
if (j == i->second.end())
{
i++;
OBNodeBase *node;
OBNodeBase *seed = i->first;
vector<OBNodeBase*>::iterator k;
for (node = g.Begin(k);node;node = g.Next(k))
if (!node->Visit && seed->Eval(node))
{
node->Visit = true;
seed->SetMatch(node);
Match(g,i,i->second.begin());
seed->SetMatch((OBNodeBase*)NULL);
node->Visit = false;
if (SingleMatch() && FinishedMatch())
break;
}
return(true);
i++;
OBNodeBase *node;
OBNodeBase *seed = i->first;
vector<OBNodeBase*>::iterator k;
for (node = g.Begin(k);node;node = g.Next(k))
if (!node->Visit && seed->Eval(node))
{
node->Visit = true;
seed->SetMatch(node);
Match(g,i,i->second.begin());
seed->SetMatch((OBNodeBase*)NULL);
node->Visit = false;
if (SingleMatch() && FinishedMatch())
break;
}
return(true);
}
OBEdgeBase *edge = *j++;
if (edge->IsClosure()) //check to see if matched atoms are bonded
{
if (edge->GetBgn()->GetMatch()->IsConnected(edge->GetEnd()->GetMatch()))
Match(g,i,j);
if (edge->GetBgn()->GetMatch()->IsConnected(edge->GetEnd()->GetMatch()))
Match(g,i,j);
}
else //bond hasn't been covered yet
{
OBNodeBase *nbr;
OBNodeBase *curr = edge->GetBgn();
OBNodeBase *next = edge->GetEnd();
OBNodeBase *match = curr->GetMatch();
vector<OBEdgeBase*>::iterator k;
OBNodeBase *nbr;
OBNodeBase *curr = edge->GetBgn();
OBNodeBase *next = edge->GetEnd();
OBNodeBase *match = curr->GetMatch();
vector<OBEdgeBase*>::iterator k;
for (nbr = match->BeginNbr(k);nbr;nbr = match->NextNbr(k))
if (!nbr->Visit && next->Eval(nbr) && edge->Eval(*k))
{
nbr->Visit = true;
next->SetMatch(nbr);
Match(g,i,j);
next->SetMatch(NULL);
nbr->Visit = false;
}
for (nbr = match->BeginNbr(k);nbr;nbr = match->NextNbr(k))
if (!nbr->Visit && next->Eval(nbr) && edge->Eval(*k))
{
nbr->Visit = true;
next->SetMatch(nbr);
Match(g,i,j);
next->SetMatch(NULL);
nbr->Visit = false;
}
}
return(false);
}
*/
OBNodeBase *OBGraphBase::Begin(vector<OBNodeBase*>::iterator &i)
{
}
*/
OBNodeBase *OBGraphBase::Begin(vector<OBNodeBase*>::iterator &i)
{
i = _vatom.begin();
return((i != _vatom.end()) ? *i : NULL);
}
}
OBNodeBase *OBGraphBase::Next(vector<OBNodeBase*>::iterator &i)
{
OBNodeBase *OBGraphBase::Next(vector<OBNodeBase*>::iterator &i)
{
i++;
return((i != _vatom.end()) ? *i : NULL);
}
}
OBEdgeBase *OBGraphBase::Begin(vector<OBEdgeBase*>::iterator &i)
{
OBEdgeBase *OBGraphBase::Begin(vector<OBEdgeBase*>::iterator &i)
{
i = _vbond.begin();
return((i != _vbond.end()) ? *i : NULL);
}
}
OBEdgeBase *OBGraphBase::Next(vector<OBEdgeBase*>::iterator &i)
{
OBEdgeBase *OBGraphBase::Next(vector<OBEdgeBase*>::iterator &i)
{
i++;
return((i != _vbond.end()) ? *i : NULL);
}
}
OBNodeBase *OBNodeBase::BeginNbr(vector<OBEdgeBase*>::iterator &i)
{
OBNodeBase *OBNodeBase::BeginNbr(vector<OBEdgeBase*>::iterator &i)
{
i = _vbond.begin();
if (i == _vbond.end())
return(NULL);
return(NULL);
return((this == (*i)->GetBgn()) ? (*i)->GetEnd() : (*i)->GetBgn());
}
}
OBNodeBase *OBNodeBase::NextNbr(vector<OBEdgeBase*>::iterator &i)
{
OBNodeBase *OBNodeBase::NextNbr(vector<OBEdgeBase*>::iterator &i)
{
i++;
if (i == _vbond.end())
return(NULL);
return(NULL);
return((this == (*i)->GetBgn()) ? (*i)->GetEnd() : (*i)->GetBgn());
}
}
void OBNodeBase::SetParent(OBGraphBase *p)
{
void OBNodeBase::SetParent(OBGraphBase *p)
{
_parent = p;
}
}
void OBEdgeBase::SetParent(OBGraphBase *p)
{
void OBEdgeBase::SetParent(OBGraphBase *p)
{
_parent = p;
}
}
bool OBNodeBase::IsConnected(OBNodeBase *nb)
{
bool OBNodeBase::IsConnected(OBNodeBase *nb)
{
vector<OBEdgeBase*>::iterator i;
for (i = _vbond.begin();i != _vbond.end();i++)
if (nb == (*i)->GetBgn() || nb == (*i)->GetEnd())
return(true);
if (nb == (*i)->GetBgn() || nb == (*i)->GetEnd())
return(true);
return(false);
}
}
void OBGraphBase::ResetVisitFlags()
{
void OBGraphBase::ResetVisitFlags()
{
OBNodeBase *nb;
vector<OBNodeBase*>::iterator i;
for (nb = Begin(i);nb;nb = Next(i))
nb->Visit = false;
nb->Visit = false;
OBEdgeBase *eb;
vector<OBEdgeBase*>::iterator j;
for (eb = Begin(j);eb;eb = Next(j))
eb->Visit = false;
}
eb->Visit = false;
}
bool OBGraphBase::SetVisitLock(bool v)
{
bool OBGraphBase::SetVisitLock(bool v)
{
if (v && _vlock)
return(false);
return(false);
_vlock = v;
return(true);
}
}
/*! \mainpage
/*! \mainpage
\section intro Introduction and History
It is fair to say that Open Babel is a direct result of the original Babel.
Application development is facilitated
by building software on top of libraries rich in functionality. Babel
was the first experience for Matt Stahl in designing a molecule
library. In addition to developing Babel, Pat Walters and Matt
developed `OBabel' at Vertex Pharmaceuticals, a first
attempt at developing an object oriented molecule library.
Matt later designed a new molecule class library, OELib -- designed
to be flexible, extensible, portable, and efficient.
It is fair to say that Open Babel is a direct result of the original Babel.
Application development is facilitated
by building software on top of libraries rich in functionality. Babel
was the first experience for Matt Stahl in designing a molecule
library. In addition to developing Babel, Pat Walters and Matt
developed `OBabel' at Vertex Pharmaceuticals, a first
attempt at developing an object oriented molecule library.
Matt later designed a new molecule class library, OELib -- designed
to be flexible, extensible, portable, and efficient.
OELib was released under the GNU General Public License (GPL) by Matt Stahl
and Open Eye Scientific Software, Inc. to take advantage of many of
the "great minds writing chemical software." Open Babel took up where
OELib and Babel left off, starting from the existing GPL version of
OELib, and has continued to evolve and improve into a separate
high-quality chemistry class library and tool. Open Babel is now a
separate project and library and has changed considerably from the OELib days.
OELib was released under the GNU General Public License (GPL) by Matt Stahl
and Open Eye Scientific Software, Inc. to take advantage of many of
the "great minds writing chemical software." Open Babel took up where
OELib and Babel left off, starting from the existing GPL version of
OELib, and has continued to evolve and improve into a separate
high-quality chemistry class library and tool. Open Babel is now a
separate project and library and has changed considerably from the OELib days.
Thanks to all who have helped with Babel, OBabel, OELib and Open Babel.
The list is long and growing.
Thanks to all who have helped with Babel, OBabel, OELib and Open Babel.
The list is long and growing.
\section pointers Key Modules
The heart of Open Babel lies in the \link OpenBabel::OBMol OBMol\endlink,
\link OpenBabel::OBAtom OBAtom\endlink, and
\link OpenBabel::OBBond OBBond\endlink classes,
which handle operations on atoms, bonds and molecules. Newcomers should
start with looking at the \link OpenBabel::OBMol OBMol\endlink class,
designed to store the basic information
in a molecule and to perceive information about a molecule.
The heart of Open Babel lies in the \link OpenBabel::OBMol OBMol\endlink,
\link OpenBabel::OBAtom OBAtom\endlink, and
\link OpenBabel::OBBond OBBond\endlink classes,
which handle operations on atoms, bonds and molecules. Newcomers should
start with looking at the \link OpenBabel::OBMol OBMol\endlink class,
designed to store the basic information
in a molecule and to perceive information about a molecule.
One of the key philosophies in the code is that transformations and
automatic perception of properties are performed in a <a href="http://en.wikipedia.org/wiki/Lazy_evaluation">"lazy"</a>
manner. That is, until you call for partial atomic charges, no
charges are calculated. This ensures faster transformations of
chemical data -- properties that are not needed for your code will
typically not be calculated. When such data is needed, appropriate
routines are called, and a "flag" is set (e.g., via OBMol::SetFlag
or OBAtom::SetFlag etc.) so that the code is only run once.
One of the key philosophies in the code is that transformations and
automatic perception of properties are performed in a <a href="http://en.wikipedia.org/wiki/Lazy_evaluation">"lazy"</a>
manner. That is, until you call for partial atomic charges, no
charges are calculated. This ensures faster transformations of
chemical data -- properties that are not needed for your code will
typically not be calculated. When such data is needed, appropriate
routines are called, and a "flag" is set (e.g., via OBMol::SetFlag
or OBAtom::SetFlag etc.) so that the code is only run once.
Arbitrary custom data and text descriptors can be stored in any atom,
bond, molecule, or residue using the \link OpenBabel::OBGenericData
OBGenericData\endlink or \link OpenBabel::OBPairData
OBPairData\endlink classes.
Arbitrary custom data and text descriptors can be stored in any atom,
bond, molecule, or residue using the \link OpenBabel::OBGenericData
OBGenericData\endlink or \link OpenBabel::OBPairData
OBPairData\endlink classes.
Conversion between various chemical file formats is accomplished through
the \link OpenBabel::OBConversion OBConversion\endlink and \link
OpenBabel::OBFormat OBFormat\endlink classes, often through use of the \link
OpenBabel::OBMoleculeFormat OBMoleculeFormat\endlink subclass which is designed
for easy read/write access to one or more \link OpenBabel::OBMol OBMol\endlink
objects. The philosophy of the file format codes is to parse as much
chemical information from a given file as possible (no data left
behind) and ideally any perception or transformations will occur when
writing to some other format later.
Conversion between various chemical file formats is accomplished through
the \link OpenBabel::OBConversion OBConversion\endlink and \link
OpenBabel::OBFormat OBFormat\endlink classes, often through use of the \link
OpenBabel::OBMoleculeFormat OBMoleculeFormat\endlink subclass which is designed
for easy read/write access to one or more \link OpenBabel::OBMol OBMol\endlink
objects. The philosophy of the file format codes is to parse as much
chemical information from a given file as possible (no data left
behind) and ideally any perception or transformations will occur when
writing to some other format later.
*/
*/
} // namespace OpenBabel
+89 -91
View File
@@ -25,110 +25,108 @@ GNU General Public License for more details.
#include <vector>
#include <map>
#if HAVE_IOSTREAM
#include <iostream>
#elif HAVE_IOSTREAM_H
#include <iostream.h>
#endif
#include "generic.h"
namespace OpenBabel
{
class OBBase;
class OBNodeBase;
class OBEdgeBase;
class OBGraphBase;
class OBBase;
class OBNodeBase;
class OBEdgeBase;
class OBGraphBase;
/** \brief Base Class
/** \brief Base Class
The various classes (Atom, Bond, Molecule) inherit from base classes--
OBBase is just a placeholder class
*/
class OBAPI OBBase
{
public:
virtual ~OBBase()
{
if (!_vdata.empty())
{
std::vector<OBGenericData*>::iterator m;
for (m = _vdata.begin();m != _vdata.end();m++)
delete *m;
_vdata.clear();
}
}
; //NF
virtual OBBase* DoTransformations(const std::map<std::string,std::string>*pOptions)
{
return this;
}
//Base type does nothing
static const char* ClassDescription()
{
return "";
}
The various classes (Atom, Bond, Molecule) inherit from base classes--
OBBase is just a placeholder class
*/
class OBAPI OBBase
{
public:
virtual ~OBBase()
{
if (!_vdata.empty())
{
std::vector<OBGenericData*>::iterator m;
for (m = _vdata.begin();m != _vdata.end();m++)
delete *m;
_vdata.clear();
}
}
//! \name Generic data handling methods (via OBGenericData)
//@{
//! \returns whether the generic attribute/value pair exists
bool HasData(std::string &);
//! \returns whether the generic attribute/value pair exists
bool HasData(const char *);
//! \returns whether the generic attribute/value pair exists, for a given
//! OBGenericDataType
bool HasData(unsigned int type);
//! Delete any data matching the given OBGenericDataType
void DeleteData(unsigned int type);
//! delete the given generic data from this object
void DeleteData(OBGenericData*);
//! delete all of the given generic data from this object
void DeleteData(std::vector<OBGenericData*>&);
//! \adds a data object; does nothing if d==NULL
void SetData(OBGenericData *d)
{
if(d)
_vdata.push_back(d);
}
//! \return the number of OBGenericData items attached to this molecule.
unsigned int DataSize(){ return(_vdata.size()); }
//! \return the first matching data for a given type from OBGenericDataType
//! or NULL if nothing matches
OBGenericData *GetData(unsigned int type);
//! \return any data matching the given attribute name
//! or NULL if nothing matches
OBGenericData *GetData(std::string&);
//! \return any data matching the given attribute name
//! or NULL if nothing matches
OBGenericData *GetData(const char *);
//! \return all data, suitable for iterating
std::vector<OBGenericData*> &GetData() { return(_vdata); }
std::vector<OBGenericData*>::iterator BeginData()
{
return(_vdata.begin());
}
std::vector<OBGenericData*>::iterator EndData()
{
return(_vdata.end());
}
//@}
protected:
std::vector<OBGenericData*> _vdata; //!< Custom data
virtual OBBase* DoTransformations(const std::map<std::string,std::string>*pOptions)
{
return this;
}
//Base type does nothing
static const char* ClassDescription()
{
return "";
}
//! \name Generic data handling methods (via OBGenericData)
//@{
//! \returns whether the generic attribute/value pair exists
bool HasData(const std::string &);
//! \returns whether the generic attribute/value pair exists
bool HasData(const char *);
//! \returns whether the generic attribute/value pair exists, for a given
//! OBGenericDataType
bool HasData(const unsigned int type);
//! Delete any data matching the given OBGenericDataType
void DeleteData(unsigned int type);
//! delete the given generic data from this object
void DeleteData(OBGenericData*);
//! delete all of the given generic data from this object
void DeleteData(std::vector<OBGenericData*>&);
//! \adds a data object; does nothing if d==NULL
void SetData(OBGenericData *d)
{
if(d)
_vdata.push_back(d);
}
//! \return the number of OBGenericData items attached to this molecule.
unsigned int DataSize() const
{ return(_vdata.size()); }
//! \return the first matching data for a given type from OBGenericDataType
//! or NULL if nothing matches
OBGenericData *GetData(const unsigned int type);
//! \return any data matching the given attribute name
//! or NULL if nothing matches
OBGenericData *GetData(const std::string&);
//! \return any data matching the given attribute name
//! or NULL if nothing matches
OBGenericData *GetData(const char *);
//! \return all data, suitable for iterating
std::vector<OBGenericData*> &GetData() { return(_vdata); }
std::vector<OBGenericData*>::iterator BeginData()
{
return(_vdata.begin());
}
std::vector<OBGenericData*>::iterator EndData()
{
return(_vdata.end());
}
//@}
protected:
std::vector<OBGenericData*> _vdata; //!< Custom data
};
};
/** \brief Node Base Class
/** \brief Node Base Class
The base class for nodes (e.g. atoms) in a graph-theoretical representation.
*/
class OBAPI OBNodeBase : public OBBase
{
protected:
//! What is my unique node index? GetIdx(), SetIdx(int idx).
unsigned short int _idx;
//! To which graph do I belong? GetParent(), SetParent(OBGraphBase*).
OBGraphBase *_parent;
The base class for nodes (e.g. atoms) in a graph-theoretical representation.
*/
class OBAPI OBNodeBase : public OBBase
{
protected:
//! What is my unique node index? GetIdx(), SetIdx(int idx).
unsigned short int _idx;
//! To which graph do I belong? GetParent(), SetParent(OBGraphBase*).
OBGraphBase *_parent;
/** \brief What edges or bonds do I have? \sa AddEdge(), GetValence(),
This node is assumed to be one of the edge endpoints.
*/