Changes in src/Parser/TremoloParser.cpp [765f16:3bdb6d]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/TremoloParser.cpp
r765f16 r3bdb6d 29 29 #include "atom.hpp" 30 30 #include "Bond/bond.hpp" 31 #include " element.hpp"31 #include "Element/element.hpp" 32 32 #include "molecule.hpp" 33 #include " periodentafel.hpp"33 #include "Element/periodentafel.hpp" 34 34 #include "Descriptors/AtomIdDescriptor.hpp" 35 35 #include <map> … … 42 42 using namespace std; 43 43 44 // declare specialized static variables45 const std::string FormatParserTrait<tremolo>::name = "tremolo";46 const std::string FormatParserTrait<tremolo>::suffix = "data";47 const ParserTypes FormatParserTrait<tremolo>::type = tremolo;48 49 44 /** 50 45 * Constructor. 51 46 */ 52 FormatParser< tremolo >::FormatParser() : 53 FormatParser_common(NULL) 54 { 47 TremoloParser::TremoloParser() { 55 48 knownKeys["x"] = TremoloKey::x; 56 49 knownKeys["u"] = TremoloKey::u; … … 94 87 * Destructor. 95 88 */ 96 FormatParser< tremolo >::~FormatParser() 97 { 98 std::cerr << "Clearing usedFields." << std::endl; 89 TremoloParser::~TremoloParser() { 90 std::cerr << "Clearing usedFields." << std::endl; 99 91 usedFields.clear(); 100 92 additionalAtomData.clear(); … … 108 100 * \param tremolo file 109 101 */ 110 void FormatParser< tremolo >::load(istream* file) {102 void TremoloParser::load(istream* file) { 111 103 string line; 112 104 string::size_type location; … … 149 141 * \param atoms atoms to store 150 142 */ 151 void FormatParser< tremolo >::save(ostream* file, const std::vector<atom *> &AtomList) {143 void TremoloParser::save(ostream* file, const std::vector<atom *> &AtomList) { 152 144 DoLog(0) && (Log() << Verbose(0) << "Saving changes to tremolo." << std::endl); 153 145 … … 177 169 * @param id of atom 178 170 */ 179 void FormatParser< tremolo >::AtomInserted(atomId_t id)171 void TremoloParser::AtomInserted(atomId_t id) 180 172 { 181 173 std::map<int, TremoloAtomInfoContainer>::iterator iter = additionalAtomData.find(id); 182 174 ASSERT(iter == additionalAtomData.end(), 183 " FormatParser< tremolo >::AtomInserted() - additionalAtomData already present for newly added atom "175 "TremoloParser::AtomInserted() - additionalAtomData already present for newly added atom " 184 176 +toString(id)+"."); 185 177 // don't add entry, as this gives a default resSeq of 0 not the molecule id … … 191 183 * @param id of atom 192 184 */ 193 void FormatParser< tremolo >::AtomRemoved(atomId_t id)185 void TremoloParser::AtomRemoved(atomId_t id) 194 186 { 195 187 std::map<int, TremoloAtomInfoContainer>::iterator iter = additionalAtomData.find(id); 196 188 // as we do not insert AtomData on AtomInserted, we cannot be assured of its presence 197 189 // ASSERT(iter != additionalAtomData.end(), 198 // " FormatParser< tremolo >::AtomRemoved() - additionalAtomData is not present for atom "190 // "TremoloParser::AtomRemoved() - additionalAtomData is not present for atom " 199 191 // +toString(id)+" to remove."); 200 192 if (iter != additionalAtomData.end()) … … 209 201 * but without the prexix "ATOMDATA" 210 202 */ 211 void FormatParser< tremolo >::setFieldsForSave(std::string atomDataLine) {203 void TremoloParser::setFieldsForSave(std::string atomDataLine) { 212 204 parseAtomDataKeysLine(atomDataLine, 0); 213 205 } … … 220 212 * \param reference to the atom of which information should be written 221 213 */ 222 void FormatParser< tremolo >::saveLine(ostream* file, atom* currentAtom) { 223 //vector<string>::iterator it; 224 // TODO: Is unique for FormatParser< tremolo >::usedFields still required? 225 vector<string>::iterator it = unique(usedFields.begin(), usedFields.end()); // skips all duplicates in the vector 214 void TremoloParser::saveLine(ostream* file, atom* currentAtom) { 215 /* vector<string>::iterator it;*/ 216 vector<string>::iterator it = unique(usedFields.begin(), usedFields.end()); // skips all duplicates in the vector 226 217 227 218 TremoloKey::atomDataKey currentField; … … 317 308 * \param reference to the atom of which to take the neighbor information 318 309 */ 319 void FormatParser< tremolo >::writeNeighbors(ostream* file, int numberOfNeighbors, atom* currentAtom) {310 void TremoloParser::writeNeighbors(ostream* file, int numberOfNeighbors, atom* currentAtom) { 320 311 const BondList& ListOfBonds = currentAtom->getListOfBonds(); 321 312 // sort bonded indices … … 340 331 * \param with which offset the keys begin within the line 341 332 */ 342 void FormatParser< tremolo >::parseAtomDataKeysLine(string line, int offset) {333 void TremoloParser::parseAtomDataKeysLine(string line, int offset) { 343 334 string keyword; 344 335 stringstream lineStream; … … 362 353 * \a atomdata_string. 363 354 * 364 * We just call \sa FormatParser< tremolo >::parseAtomDataKeysLine() which is left355 * We just call \sa TremoloParser::parseAtomDataKeysLine() which is left 365 356 * private., 366 357 * 367 358 * @param atomdata_string line to parse with space-separated values 368 359 */ 369 void FormatParser< tremolo >::setAtomData(const std::string &atomdata_string)360 void TremoloParser::setAtomData(const std::string &atomdata_string) 370 361 { 371 362 parseAtomDataKeysLine(atomdata_string, 0); … … 380 371 * \param *newmol molecule to add atom to 381 372 */ 382 void FormatParser< tremolo >::readAtomDataLine(string line, molecule *newmol = NULL) {373 void TremoloParser::readAtomDataLine(string line, molecule *newmol = NULL) { 383 374 vector<string>::iterator it; 384 375 stringstream lineStream; … … 398 389 tokenizer tokens(line, whitespacesep); 399 390 ASSERT(tokens.begin() != tokens.end(), 400 " FormatParser< tremolo >::readAtomDataLine - empty string, need at least ' '!");391 "TremoloParser::readAtomDataLine - empty string, need at least ' '!"); 401 392 tokenizer::iterator tok_iter = tokens.begin(); 402 393 // then associate each token to each file … … 410 401 // for the moment, assume there are always three dimensions 411 402 for (int i=0;i<NDIM;i++) { 412 ASSERT(tok_iter != tokens.end(), " FormatParser< tremolo >::readAtomDataLine() - no value for x["+toString(i)+"]!");403 ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for x["+toString(i)+"]!"); 413 404 DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl); 414 405 newAtom->set(i, toDouble(*tok_iter)); … … 419 410 // for the moment, assume there are always three dimensions 420 411 for (int i=0;i<NDIM;i++) { 421 ASSERT(tok_iter != tokens.end(), " FormatParser< tremolo >::readAtomDataLine() - no value for u["+toString(i)+"]!");412 ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for u["+toString(i)+"]!"); 422 413 DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl); 423 414 tempVector[i] = toDouble(*tok_iter); … … 428 419 case TremoloKey::type : 429 420 { 430 ASSERT(tok_iter != tokens.end(), " FormatParser< tremolo >::readAtomDataLine() - no value for "+keyName+"!");421 ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for "+keyName+"!"); 431 422 DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl); 432 423 std::string element(knownTypes[(*tok_iter)]); … … 440 431 } 441 432 case TremoloKey::Id : 442 ASSERT(tok_iter != tokens.end(), " FormatParser< tremolo >::readAtomDataLine() - no value for "+keyName+"!");433 ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for "+keyName+"!"); 443 434 DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl); 444 435 atomIdMap[toInt(*tok_iter)] = newAtom->getId(); … … 447 438 case TremoloKey::neighbors : 448 439 for (int i=0;i<atoi(it->substr(it->find("=") + 1, 1).c_str());i++) { 449 ASSERT(tok_iter != tokens.end(), " FormatParser< tremolo >::readAtomDataLine() - no value for "+keyName+"!");440 ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for "+keyName+"!"); 450 441 DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl); 451 442 lineStream << *tok_iter << "\t"; … … 456 447 break; 457 448 default : 458 ASSERT(tok_iter != tokens.end(), " FormatParser< tremolo >::readAtomDataLine() - no value for "+keyName+"!");449 ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for "+keyName+"!"); 459 450 DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl); 460 451 atomInfo->set(currentField, *tok_iter); … … 476 467 * \param atomid world id of the atom the information belongs to 477 468 */ 478 void FormatParser< tremolo >::readNeighbors(stringstream* line, int numberOfNeighbors, int atomId) {469 void TremoloParser::readNeighbors(stringstream* line, int numberOfNeighbors, int atomId) { 479 470 int neighborId = 0; 480 471 for (int i = 0; i < numberOfNeighbors; i++) { … … 498 489 * \return true if the field name is used 499 490 */ 500 bool FormatParser< tremolo >::isUsedField(string fieldName) {491 bool TremoloParser::isUsedField(string fieldName) { 501 492 bool fieldNameExists = false; 502 493 for (vector<string>::iterator usedField = usedFields.begin(); usedField != usedFields.end(); usedField++) { … … 514 505 * Id found in the parsed file. 515 506 */ 516 void FormatParser< tremolo >::processNeighborInformation() {507 void TremoloParser::processNeighborInformation() { 517 508 if (!isUsedField("neighbors")) { 518 509 return; … … 547 538 * \return input string with modified atom IDs 548 539 */ 549 st d::string FormatParser< tremolo >::adaptIdDependentDataString(string data) {540 string TremoloParser::adaptIdDependentDataString(string data) { 550 541 // there might be no IDs 551 542 if (data == "-") { … … 572 563 * as they might differ from the originally read IDs. 573 564 */ 574 void FormatParser< tremolo >::adaptImprData() {565 void TremoloParser::adaptImprData() { 575 566 if (!isUsedField("imprData")) { 576 567 return; … … 588 579 * as they might differ from the originally read IDs. 589 580 */ 590 void FormatParser< tremolo >::adaptTorsion() {581 void TremoloParser::adaptTorsion() { 591 582 if (!isUsedField("torsion")) { 592 583 return; … … 603 594 * 604 595 */ 605 void FormatParser< tremolo >::createKnownTypesByIdentity()596 void TremoloParser::createKnownTypesByIdentity() 606 597 { 607 598 // remove old mapping … … 620 611 * @param file input stream of .potentials file 621 612 */ 622 void FormatParser< tremolo >::parseKnownTypes(std::istream &file)613 void TremoloParser::parseKnownTypes(std::istream &file) 623 614 { 624 615 const periodentafel *periode = World::getInstance().getPeriode(); … … 641 632 tokenizer tokens(line, tokensep); 642 633 ASSERT(tokens.begin() != tokens.end(), 643 " FormatParser< tremolo >::parseKnownTypes() - line with 'particle:' but no particles separated by comma.");634 "TremoloParser::parseKnownTypes() - line with 'particle:' but no particles separated by comma."); 644 635 // look for particle_type 645 636 std::string particle_type("NULL"); … … 652 643 tokenizer token((*tok_iter), equalitysep); 653 644 ASSERT(token.begin() != token.end(), 654 " FormatParser< tremolo >::parseKnownTypes() - could not split particle_type by equality sign");645 "TremoloParser::parseKnownTypes() - could not split particle_type by equality sign"); 655 646 tokenizer::iterator particle_iter = token.begin(); 656 647 particle_iter++; … … 661 652 tokenizer token((*tok_iter), equalitysep); 662 653 ASSERT(token.begin() != token.end(), 663 " FormatParser< tremolo >::parseKnownTypes() - could not split particle_type by equality sign");654 "TremoloParser::parseKnownTypes() - could not split particle_type by equality sign"); 664 655 tokenizer::iterator element_iter = token.begin(); 665 656 element_iter++;
Note:
See TracChangeset
for help on using the changeset viewer.