| 1 |
+ |
/********************************************************************** |
| 2 |
+ |
* Copyright (C) 2002-2003 by Gezelter's Group |
| 3 |
+ |
*This program is free software; you can redistribute it and/or modify |
| 4 |
+ |
*it under the terms of the GNU General Public License as published by |
| 5 |
+ |
*the Free Software Foundation version 2 of the License. |
| 6 |
+ |
* |
| 7 |
+ |
*This program is distributed in the hope that it will be useful, |
| 8 |
+ |
*but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 |
+ |
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 |
+ |
*GNU General Public License for more details. |
| 11 |
+ |
* |
| 12 |
+ |
************************************************************************ |
| 13 |
+ |
*Author: Teng Lin Email: tlin@nd.edu |
| 14 |
+ |
*Date: 08/13/2002 Version: 1.0 |
| 15 |
+ |
* |
| 16 |
+ |
************************************************************************ |
| 17 |
+ |
*Description: |
| 18 |
+ |
* |
| 19 |
+ |
***********************************************************************/ |
| 20 |
|
#ifndef EXTRADATA_H |
| 21 |
|
#define EXTRADATA_H |
| 22 |
|
#include <iostream> |
| 23 |
+ |
#include <vector> |
| 24 |
|
#include <map> |
| 25 |
|
|
| 26 |
+ |
|
| 27 |
+ |
|
| 28 |
|
using namespace std; |
| 29 |
|
|
| 30 |
|
// the advantage of using namespace over enum type is that you can |
| 31 |
|
// add the new type as you want but make sure do not have conflict value |
| 32 |
+ |
|
| 33 |
|
namespace TExtraDataType |
| 34 |
|
{ |
| 35 |
|
const int UNKNOWN = 0; |
| 36 |
< |
const int COMMENT =1; |
| 37 |
< |
const int ENERGY = 2; |
| 38 |
< |
const int FORCE= 3; |
| 39 |
< |
const int ANGLE = 4; |
| 36 |
> |
const int COMMENT = 1; |
| 37 |
> |
const int ENERGY = 2; |
| 38 |
> |
const int FORCE = 3; |
| 39 |
> |
const int DISTANCE = 4; |
| 40 |
> |
const int ANGLE = 5; |
| 41 |
> |
const int DIHE = 6; |
| 42 |
> |
const int IMPR = 7; |
| 43 |
> |
const int IC = 8; |
| 44 |
|
}; |
| 45 |
|
|
| 46 |
|
|
| 20 |
– |
namespace TEnergyDataType |
| 21 |
– |
{ |
| 22 |
– |
const int BOND = 1; |
| 23 |
– |
const int ANGEL = 2; |
| 24 |
– |
const int DIHE = 3; |
| 25 |
– |
const int IMPR = 4; |
| 26 |
– |
const int VDW = 5; |
| 27 |
– |
const int COUL = 6; |
| 28 |
– |
const int HBOND = 7; |
| 29 |
– |
const int KE = 8; |
| 30 |
– |
const int PE = 9; |
| 31 |
– |
const int TEMP = 10; |
| 32 |
– |
const int TOTAL = 11; |
| 33 |
– |
const int VOLUME = 12; |
| 34 |
– |
const int PRESSURE = 13; |
| 35 |
– |
const int EFILED = 14; |
| 36 |
– |
const int UREY_BRADLEY = 15; |
| 37 |
– |
const int RESTRAINT = 16; |
| 38 |
– |
}; |
| 47 |
|
|
| 48 |
|
class TExtraData |
| 49 |
|
{ |
| 50 |
|
protected: |
| 51 |
< |
string _ident; |
| 52 |
< |
int _type; |
| 51 |
> |
string _ident; |
| 52 |
> |
int _type; |
| 53 |
> |
|
| 54 |
|
public: |
| 55 |
|
TExtraData(); |
| 56 |
|
TExtraData(const TExtraData &extraData); |
| 57 |
|
TExtraData& operator =(const TExtraData &extraData); |
| 58 |
|
virtual ~TExtraData() {} |
| 59 |
< |
|
| 59 |
> |
|
| 60 |
|
string GetIdent() { return _ident;} |
| 61 |
|
int GetType() { return _type;} |
| 62 |
< |
|
| 62 |
> |
|
| 63 |
|
void SetIdent(string ident) { _ident = ident;} |
| 64 |
|
void SetType(int type) { _type = type;} |
| 65 |
+ |
|
| 66 |
|
}; |
| 67 |
|
|
| 68 |
< |
class TEnergyData : public TExtraData |
| 68 |
> |
class TExtraDataList :public vector<TExtraData *> |
| 69 |
|
{ |
| 70 |
< |
protected: |
| 71 |
< |
map<int, float> _energy; |
| 72 |
< |
map<int, float>::iterator FindEnergy(int energyType); |
| 73 |
< |
public: |
| 74 |
< |
TEnergyData(); |
| 75 |
< |
TEnergyData(const TEnergyData &energyData); |
| 66 |
< |
TEnergyData &operator =(const TEnergyData &energyData); |
| 67 |
< |
~TEnergyData(); |
| 70 |
> |
public: |
| 71 |
> |
void AddExtraData(TExtraData *extraData); |
| 72 |
> |
void RemoveExtraData(TExtraData *extraData); |
| 73 |
> |
TExtraData *GetExtraData(int type); |
| 74 |
> |
TExtraData *GetExtraData(string indet); |
| 75 |
> |
}; |
| 76 |
|
|
| 77 |
< |
void AddEnergy(int energyType, float value); |
| 78 |
< |
void DeleteEnergy(int energyType); |
| 79 |
< |
void ReplaceEnergy(int energyType, float value); |
| 80 |
< |
bool IsEnergyExist(int energyType); |
| 81 |
< |
float *GetEnergy(int energyType); |
| 77 |
> |
class TMatchExtraData : public unary_function<TExtraData *, bool> |
| 78 |
> |
{ |
| 79 |
> |
private: |
| 80 |
> |
string _ident; |
| 81 |
> |
int _type; |
| 82 |
|
|
| 83 |
+ |
enum TMatchExtraType {meIdent, meType} _matchExtraType; |
| 84 |
+ |
public: |
| 85 |
+ |
TMatchExtraData(const string &ident) : _ident(ident){ _matchExtraType = meIdent;} |
| 86 |
+ |
TMatchExtraData(const int &type) : _type(type){ _matchExtraType = meType;} |
| 87 |
+ |
|
| 88 |
+ |
bool operator ()(const TExtraData & extraData) const |
| 89 |
+ |
{ |
| 90 |
+ |
bool result; |
| 91 |
+ |
|
| 92 |
+ |
switch (_matchExtraType) |
| 93 |
+ |
{ |
| 94 |
+ |
case meIdent: |
| 95 |
+ |
result = (_ident == extraData.GetIdent()); |
| 96 |
+ |
return result; |
| 97 |
+ |
case meType: |
| 98 |
+ |
result = (_type == extraData.GetType()); |
| 99 |
+ |
return result; |
| 100 |
+ |
default: |
| 101 |
+ |
//Error |
| 102 |
+ |
; |
| 103 |
+ |
} |
| 104 |
+ |
} |
| 105 |
+ |
|
| 106 |
|
}; |
| 107 |
|
|
| 108 |
|
#endif |