File: generic.h

package info (click to toggle)
ghemical 1.01-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 10,984 kB
  • ctags: 19,443
  • sloc: ansic: 69,073; cpp: 60,583; fortran: 35,324; sh: 5,419; makefile: 506; perl: 91
file content (145 lines) | stat: -rw-r--r-- 4,182 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/**********************************************************************
Copyright (C) 1998-2001 by OpenEye Scientific Software, Inc.
Some portions Copyright (c) 2001-2002 by Geoffrey R. Hutchison

This file is part of the Open Babel project.
For more information, see <http://openbabel.sourceforge.net/>

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_GENERIC_H
#define OB_GENERIC_H

//obData0 through obData9 are data slots that are not used in OpenBabel, and
//are meant for use in derivative programs.  Macro definitions can be used
//to define what each data slot is used for.
 
namespace OpenBabel {

class OBAtom;
class OBBond; 

enum obDataType {obUndefinedData,obPairData,obEnergyData,
		 obCommentData,obCompressData,obExternalBondData,obRotamerList,
		 obVirtualBondData,obRingData,obData0,obData1,obData2,obData3,
		 obData4,obData5,obData6,obData7,obData8,obData9};

//base class for generic data - use obData# slots for undefined data types

class OBGenericData
{
protected:
	std::string     _attr; //attribute tag
	obDataType _type;
public:
	OBGenericData();
	OBGenericData(const OBGenericData&);
	virtual ~OBGenericData() {}
	void                  SetAttribute(std::string &v)       {_attr = v;}
	virtual const std::string &GetAttribute()          const {return(_attr);}
	obDataType      GetDataType()                 const {return(_type);}
};

class OBCommentData : public OBGenericData
{
protected:
	std::string _data;
public:
	OBCommentData();
	OBCommentData(const OBCommentData&);
	void          SetData(std::string &data)        {_data = data; }
	void          SetData(const char *d)       {_data = d;    }
	const std::string &GetData()              const {return(_data);}
};

class OBExternalBond
{
  int     _idx;
  OBAtom *_atom;
  OBBond *_bond;
public:
  OBExternalBond() {}
  OBExternalBond(OBAtom *,OBBond *,int);
  OBExternalBond(const OBExternalBond &);
  ~OBExternalBond(){}

  int     GetIdx()  const {return(_idx);  }
  OBAtom *GetAtom() const {return(_atom); }
  OBBond *GetBond() const {return(_bond); }
  void SetIdx(int idx) {_idx = idx;}
  void SetAtom(OBAtom *atom) {_atom = atom;}
  void SetBond(OBBond *bond) {_bond = bond;}
};

class OBExternalBondData : public OBGenericData
{
protected:
  std::vector<OBExternalBond> _vexbnd;
public:
  OBExternalBondData();
  void SetData(OBAtom*,OBBond*,int);
	std::vector<OBExternalBond> *GetData() {return(&_vexbnd);}
};

class OBCompressData : public OBGenericData
{
protected:
  int _size;
  unsigned char *_data;
public:
  OBCompressData();
  ~OBCompressData();
  void SetData(unsigned char *,int);
  int            GetSize() {return(_size);}
  unsigned char *GetData() {return(_data);}
};

class OBPairData : public OBGenericData //use to store attribute/value relationships
{
 protected:
  std::string _value;
 public:
  OBPairData();
  void    SetValue(const char *v) {_value = v;}
  void    SetValue(std::string &v)     {_value = v;}
  std::string &GetValue()              {return(_value);}
};

class OBVirtualBond : public OBGenericData
{
protected:
	int _bgn;
	int _end;
	int _ord;
	int _stereo;
public:
	OBVirtualBond();           
	OBVirtualBond(int,int,int,int stereo=0);
	int GetBgn()                           {return(_bgn);}
	int GetEnd()                           {return(_end);}
	int GetOrder()                         {return(_ord);}
	int GetStereo()                        {return(_stereo);}
};

class OBRingData : public OBGenericData
{
protected:
	std::vector<OBRing*> _vr;
public:
	OBRingData();
	void SetData(std::vector<OBRing*> &vr) {_vr = vr;}
	void PushBack(OBRing *r)          {_vr.push_back(r);}
	std::vector<OBRing*> &GetData()        {return(_vr);}
};

} //end namespace OpenBabel

#endif // OB_GENERIC_H