1 |
tim |
83 |
/********************************************************************** |
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 |
tim |
66 |
#ifndef EXTRADATA_H |
21 |
|
|
#define EXTRADATA_H |
22 |
|
|
#include <iostream> |
23 |
tim |
83 |
#include <vector> |
24 |
tim |
66 |
#include <map> |
25 |
|
|
|
26 |
tim |
83 |
|
27 |
tim |
88 |
|
28 |
tim |
66 |
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 |
tim |
83 |
|
33 |
tim |
66 |
namespace TExtraDataType |
34 |
|
|
{ |
35 |
|
|
const int UNKNOWN = 0; |
36 |
tim |
83 |
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 |
tim |
66 |
}; |
45 |
|
|
|
46 |
|
|
|
47 |
tim |
83 |
|
48 |
|
|
class TExtraData |
49 |
|
|
{ |
50 |
|
|
protected: |
51 |
tim |
88 |
string _ident; |
52 |
|
|
int _type; |
53 |
|
|
|
54 |
tim |
83 |
public: |
55 |
|
|
TExtraData(); |
56 |
|
|
TExtraData(const TExtraData &extraData); |
57 |
|
|
TExtraData& operator =(const TExtraData &extraData); |
58 |
|
|
virtual ~TExtraData() {} |
59 |
|
|
|
60 |
|
|
string GetIdent() { return _ident;} |
61 |
|
|
int GetType() { return _type;} |
62 |
|
|
|
63 |
|
|
void SetIdent(string ident) { _ident = ident;} |
64 |
|
|
void SetType(int type) { _type = type;} |
65 |
tim |
88 |
|
66 |
tim |
83 |
}; |
67 |
|
|
|
68 |
tim |
88 |
class TExtraDataList :public vector<TExtraData *> |
69 |
tim |
83 |
{ |
70 |
|
|
public: |
71 |
|
|
void AddExtraData(TExtraData *extraData); |
72 |
|
|
void RemoveExtraData(TExtraData *extraData); |
73 |
tim |
88 |
TExtraData *GetExtraData(int type); |
74 |
|
|
TExtraData *GetExtraData(string indet); |
75 |
tim |
83 |
}; |
76 |
|
|
|
77 |
tim |
88 |
class TMatchExtraData : public unary_function<TExtraData *, bool> |
78 |
tim |
83 |
{ |
79 |
|
|
private: |
80 |
tim |
88 |
string _ident; |
81 |
tim |
83 |
int _type; |
82 |
|
|
|
83 |
tim |
88 |
enum TMatchExtraType {meIdent, meType} _matchExtraType; |
84 |
tim |
83 |
public: |
85 |
tim |
88 |
TMatchExtraData(const string &ident) : _ident(ident){ _matchExtraType = meIdent;} |
86 |
tim |
83 |
TMatchExtraData(const int &type) : _type(type){ _matchExtraType = meType;} |
87 |
|
|
|
88 |
|
|
bool operator ()(const TExtraData & extraData) const |
89 |
|
|
{ |
90 |
tim |
88 |
bool result; |
91 |
|
|
|
92 |
tim |
83 |
switch (_matchExtraType) |
93 |
|
|
{ |
94 |
tim |
88 |
case meIdent: |
95 |
|
|
result = (_ident == extraData.GetIdent()); |
96 |
|
|
return result; |
97 |
|
|
case meType: |
98 |
|
|
result = (_type == extraData.GetType()); |
99 |
|
|
return result; |
100 |
tim |
83 |
default: |
101 |
|
|
//Error |
102 |
|
|
; |
103 |
|
|
} |
104 |
|
|
} |
105 |
|
|
|
106 |
|
|
}; |
107 |
|
|
|
108 |
tim |
66 |
#endif |