Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/TremoloParser.cpp

    r765f16 r3bdb6d  
    2929#include "atom.hpp"
    3030#include "Bond/bond.hpp"
    31 #include "element.hpp"
     31#include "Element/element.hpp"
    3232#include "molecule.hpp"
    33 #include "periodentafel.hpp"
     33#include "Element/periodentafel.hpp"
    3434#include "Descriptors/AtomIdDescriptor.hpp"
    3535#include <map>
     
    4242using namespace std;
    4343
    44 // declare specialized static variables
    45 const std::string FormatParserTrait<tremolo>::name = "tremolo";
    46 const std::string FormatParserTrait<tremolo>::suffix = "data";
    47 const ParserTypes FormatParserTrait<tremolo>::type = tremolo;
    48 
    4944/**
    5045 * Constructor.
    5146 */
    52 FormatParser< tremolo >::FormatParser()  :
    53   FormatParser_common(NULL)
    54 {
     47TremoloParser::TremoloParser() {
    5548  knownKeys["x"] = TremoloKey::x;
    5649  knownKeys["u"] = TremoloKey::u;
     
    9487 * Destructor.
    9588 */
    96 FormatParser< tremolo >::~FormatParser()
    97 {
    98   std::cerr << "Clearing usedFields." << std::endl;
     89TremoloParser::~TremoloParser() {
     90        std::cerr << "Clearing usedFields." << std::endl;
    9991  usedFields.clear();
    10092  additionalAtomData.clear();
     
    108100 * \param tremolo file
    109101 */
    110 void FormatParser< tremolo >::load(istream* file) {
     102void TremoloParser::load(istream* file) {
    111103  string line;
    112104  string::size_type location;
     
    149141 * \param atoms atoms to store
    150142 */
    151 void FormatParser< tremolo >::save(ostream* file, const std::vector<atom *> &AtomList) {
     143void TremoloParser::save(ostream* file, const std::vector<atom *> &AtomList) {
    152144  DoLog(0) && (Log() << Verbose(0) << "Saving changes to tremolo." << std::endl);
    153145
     
    177169 * @param id of atom
    178170 */
    179 void FormatParser< tremolo >::AtomInserted(atomId_t id)
     171void TremoloParser::AtomInserted(atomId_t id)
    180172{
    181173  std::map<int, TremoloAtomInfoContainer>::iterator iter = additionalAtomData.find(id);
    182174  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 "
    184176      +toString(id)+".");
    185177  // don't add entry, as this gives a default resSeq of 0 not the molecule id
     
    191183 * @param id of atom
    192184 */
    193 void FormatParser< tremolo >::AtomRemoved(atomId_t id)
     185void TremoloParser::AtomRemoved(atomId_t id)
    194186{
    195187  std::map<int, TremoloAtomInfoContainer>::iterator iter = additionalAtomData.find(id);
    196188  // as we do not insert AtomData on AtomInserted, we cannot be assured of its presence
    197189//  ASSERT(iter != additionalAtomData.end(),
    198 //      "FormatParser< tremolo >::AtomRemoved() - additionalAtomData is not present for atom "
     190//      "TremoloParser::AtomRemoved() - additionalAtomData is not present for atom "
    199191//      +toString(id)+" to remove.");
    200192  if (iter != additionalAtomData.end())
     
    209201 *        but without the prexix "ATOMDATA"
    210202 */
    211 void FormatParser< tremolo >::setFieldsForSave(std::string atomDataLine) {
     203void TremoloParser::setFieldsForSave(std::string atomDataLine) {
    212204  parseAtomDataKeysLine(atomDataLine, 0);
    213205}
     
    220212 * \param reference to the atom of which information should be written
    221213 */
    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
     214void 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
    226217
    227218  TremoloKey::atomDataKey currentField;
     
    317308 * \param reference to the atom of which to take the neighbor information
    318309 */
    319 void FormatParser< tremolo >::writeNeighbors(ostream* file, int numberOfNeighbors, atom* currentAtom) {
     310void TremoloParser::writeNeighbors(ostream* file, int numberOfNeighbors, atom* currentAtom) {
    320311  const BondList& ListOfBonds = currentAtom->getListOfBonds();
    321312  // sort bonded indices
     
    340331 * \param with which offset the keys begin within the line
    341332 */
    342 void FormatParser< tremolo >::parseAtomDataKeysLine(string line, int offset) {
     333void TremoloParser::parseAtomDataKeysLine(string line, int offset) {
    343334  string keyword;
    344335  stringstream lineStream;
     
    362353 *  \a atomdata_string.
    363354 *
    364  *  We just call \sa  FormatParser< tremolo >::parseAtomDataKeysLine() which is left
     355 *  We just call \sa TremoloParser::parseAtomDataKeysLine() which is left
    365356 *  private.,
    366357 *
    367358 * @param atomdata_string line to parse with space-separated values
    368359 */
    369 void FormatParser< tremolo >::setAtomData(const std::string &atomdata_string)
     360void TremoloParser::setAtomData(const std::string &atomdata_string)
    370361{
    371362  parseAtomDataKeysLine(atomdata_string, 0);
     
    380371 * \param *newmol molecule to add atom to
    381372 */
    382 void FormatParser< tremolo >::readAtomDataLine(string line, molecule *newmol = NULL) {
     373void TremoloParser::readAtomDataLine(string line, molecule *newmol = NULL) {
    383374  vector<string>::iterator it;
    384375  stringstream lineStream;
     
    398389  tokenizer tokens(line, whitespacesep);
    399390  ASSERT(tokens.begin() != tokens.end(),
    400       "FormatParser< tremolo >::readAtomDataLine - empty string, need at least ' '!");
     391      "TremoloParser::readAtomDataLine - empty string, need at least ' '!");
    401392  tokenizer::iterator tok_iter = tokens.begin();
    402393  // then associate each token to each file
     
    410401        // for the moment, assume there are always three dimensions
    411402        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)+"]!");
    413404          DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl);
    414405          newAtom->set(i, toDouble(*tok_iter));
     
    419410        // for the moment, assume there are always three dimensions
    420411        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)+"]!");
    422413          DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl);
    423414          tempVector[i] = toDouble(*tok_iter);
     
    428419      case TremoloKey::type :
    429420      {
    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+"!");
    431422        DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl);
    432423        std::string element(knownTypes[(*tok_iter)]);
     
    440431      }
    441432      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+"!");
    443434        DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl);
    444435        atomIdMap[toInt(*tok_iter)] = newAtom->getId();
     
    447438      case TremoloKey::neighbors :
    448439        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+"!");
    450441          DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl);
    451442          lineStream << *tok_iter << "\t";
     
    456447        break;
    457448      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+"!");
    459450        DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl);
    460451        atomInfo->set(currentField, *tok_iter);
     
    476467 * \param atomid world id of the atom the information belongs to
    477468 */
    478 void FormatParser< tremolo >::readNeighbors(stringstream* line, int numberOfNeighbors, int atomId) {
     469void TremoloParser::readNeighbors(stringstream* line, int numberOfNeighbors, int atomId) {
    479470  int neighborId = 0;
    480471  for (int i = 0; i < numberOfNeighbors; i++) {
     
    498489 * \return true if the field name is used
    499490 */
    500 bool FormatParser< tremolo >::isUsedField(string fieldName) {
     491bool TremoloParser::isUsedField(string fieldName) {
    501492  bool fieldNameExists = false;
    502493  for (vector<string>::iterator usedField = usedFields.begin(); usedField != usedFields.end(); usedField++) {
     
    514505 * Id found in the parsed file.
    515506 */
    516 void FormatParser< tremolo >::processNeighborInformation() {
     507void TremoloParser::processNeighborInformation() {
    517508  if (!isUsedField("neighbors")) {
    518509    return;
     
    547538 * \return input string with modified atom IDs
    548539 */
    549 std::string FormatParser< tremolo >::adaptIdDependentDataString(string data) {
     540string TremoloParser::adaptIdDependentDataString(string data) {
    550541  // there might be no IDs
    551542  if (data == "-") {
     
    572563 * as they might differ from the originally read IDs.
    573564 */
    574 void FormatParser< tremolo >::adaptImprData() {
     565void TremoloParser::adaptImprData() {
    575566  if (!isUsedField("imprData")) {
    576567    return;
     
    588579 * as they might differ from the originally read IDs.
    589580 */
    590 void FormatParser< tremolo >::adaptTorsion() {
     581void TremoloParser::adaptTorsion() {
    591582  if (!isUsedField("torsion")) {
    592583    return;
     
    603594 *
    604595 */
    605 void FormatParser< tremolo >::createKnownTypesByIdentity()
     596void TremoloParser::createKnownTypesByIdentity()
    606597{
    607598  // remove old mapping
     
    620611 * @param file input stream of .potentials file
    621612 */
    622 void FormatParser< tremolo >::parseKnownTypes(std::istream &file)
     613void TremoloParser::parseKnownTypes(std::istream &file)
    623614{
    624615  const periodentafel *periode = World::getInstance().getPeriode();
     
    641632      tokenizer tokens(line, tokensep);
    642633      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.");
    644635      // look for particle_type
    645636      std::string particle_type("NULL");
     
    652643          tokenizer token((*tok_iter), equalitysep);
    653644          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");
    655646          tokenizer::iterator particle_iter = token.begin();
    656647          particle_iter++;
     
    661652          tokenizer token((*tok_iter), equalitysep);
    662653          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");
    664655          tokenizer::iterator element_iter = token.begin();
    665656          element_iter++;
Note: See TracChangeset for help on using the changeset viewer.