ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-3.0/src/io/BendTypesSectionParser.cpp
(Generate patch)

Comparing branches/new_design/OOPSE-3.0/src/io/BendTypesSectionParser.cpp (file contents):
Revision 1789 by tim, Mon Nov 29 15:27:43 2004 UTC vs.
Revision 1801 by tim, Tue Nov 30 04:43:29 2004 UTC

# Line 29 | Line 29 | namespace oopse {
29   #include "types/CubicBendType.hpp"
30   #include "types/QuarticBendType.hpp"
31   #include "types/PolynomialBendType.hpp"
32 + #include "UseTheForce/ForceField.hpp"
33   namespace oopse {
34  
35   BendTypesSectionParser::BendTypesSectionParser() {
36      setSectionName("BendTypes");
37 +
38 +    stringToEnumMap_["Harmonic"] =  btHarmonic;      
39 +    stringToEnumMap_["GhostBend"] =  btGhostBend;                
40 +    stringToEnumMap_["UreyBradley"] =  btUreyBradley;                    
41 +    stringToEnumMap_["Cubic"] = btCubic;
42 +    stringToEnumMap_["Quartic"] = btQuartic;
43 +    stringToEnumMap_["Polynomial"] = btPolynomial;    
44   }
45  
46   void BendTypesSectionParser::parseLine(ForceField& ff,const std::string& line, int lineNo){
47      StringTokenizer tokenizer(line);
40    std::string at1;
41    std::string at2;
42    std::string at3;
43    std::string bt;
44    double theta0;
48      BendType* bendType = NULL;
49  
50      int nTokens = tokenizer.countTokens();
# Line 51 | Line 54 | void BendTypesSectionParser::parseLine(ForceField& ff,
54          return;
55      }
56      
57 <    at1 = tokenizer.nextToken();
58 <    at2 = tokenizer.nextToken();
59 <    at3 = tokenizer.nextToken();
60 <    bt = tokenizer.nextToken();
61 <    theta0 = tokenizer.nextTokenAsDouble();
57 >    std::string at1 = tokenizer.nextToken();
58 >    std::string at2 = tokenizer.nextToken();
59 >    std::string at3 = tokenizer.nextToken();
60 >    BendTypeEnum bt = getBendTypeEnum(tokenizer.nextToken());
61 >    double theta0 = tokenizer.nextTokenAsDouble();
62      nTokens -= 5;
63  
64      //switch is a maintain nightmare
65      switch(bt) {
66              
67 <        case "Harmonic" :
67 >        case btHarmonic :
68              
69              if (nTokens < 1) {
70  
# Line 71 | Line 74 | void BendTypesSectionParser::parseLine(ForceField& ff,
74                  bendType = new HarmonicBendType(theta0, ktheta);
75              }
76              break;
77 <        case "GhostBend" :
77 >        case btGhostBend :
78              if (nTokens < 1) {
79  
80              } else {
# Line 80 | Line 83 | void BendTypesSectionParser::parseLine(ForceField& ff,
83              }
84              break;            
85  
86 <        case "UreyBradley" :
86 >        case btUreyBradley :
87              if (nTokens < 3) {
88  
89              } else {
# Line 91 | Line 94 | void BendTypesSectionParser::parseLine(ForceField& ff,
94              }
95              break;
96              
97 <        case "Cubic" :
97 >        case btCubic :
98              if (nTokens < 4) {
99  
100              } else {
# Line 105 | Line 108 | void BendTypesSectionParser::parseLine(ForceField& ff,
108              }
109              break;
110              
111 <        case "Quartic" :
111 >        case btQuartic :
112              if (nTokens < 5) {
113  
114              } else {
# Line 121 | Line 124 | void BendTypesSectionParser::parseLine(ForceField& ff,
124              }
125              break;
126  
127 <        case "Polynomial" :
127 >        case btPolynomial :
128              if (nTokens < 2 || nTokens % 2 != 0) {
129  
130              } else {
131                  int nPairs = nTokens / 2;
132                  int power;
133                  double coefficient;
134 <                PolynomialBendType* pbt = new PolynomialBendType();
134 >                PolynomialBendType* pbt = new PolynomialBendType(theta0);
135                  
136                  for (int i = 0; i < nPairs; ++i) {
137                      power = tokenizer.nextTokenAsInt();
# Line 139 | Line 142 | void BendTypesSectionParser::parseLine(ForceField& ff,
142              
143              break;
144  
145 +        case btUnknown :
146          default:
147 +            break;
148              
149      }
150  
# Line 148 | Line 153 | void BendTypesSectionParser::parseLine(ForceField& ff,
153      }
154   }
155  
156 + BendTypesSectionParser::BendTypeEnum BendTypesSectionParser::getBendTypeEnum(const std::string& str) {
157 +    std::map<std::string, BendTypeEnum>::iterator i;
158 +    i = stringToEnumMap_.find(str);
159 +
160 +    return i == stringToEnumMap_.end() ? btUnknown : i->second;
161 + }
162 +
163   } //end namespace oopse
164  
165  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines