Changes in / [fa9d1d:360c8b]


Ignore:
Files:
55 added
1 deleted
43 edited

Legend:

Unmodified
Added
Removed
  • configure.ac

    rfa9d1d r360c8b  
    122122BOOST_RANDOM
    123123BOOST_SMART_PTR
     124BOOST_STRING_ALGO
    124125BOOST_TOKENIZER
    125126
  • src/Actions/MoleculeAction/FillVoidWithMoleculeAction.cpp

    rfa9d1d r360c8b  
    2828#include "Descriptors/MoleculeOrderDescriptor.hpp"
    2929#include "molecule.hpp"
     30#include "Parser/FormatParserInterface.hpp"
    3031#include "Parser/FormatParserStorage.hpp"
    3132#include "World.hpp"
     
    6768  input.open(params.fillername.string().c_str());
    6869  ParserTypes type = FormatParserStorage::getInstance().getTypeFromSuffix(FilenameSuffix);
    69   FormatParser &parser = FormatParserStorage::getInstance().get(type);
     70  FormatParserInterface &parser = FormatParserStorage::getInstance().get(type);
    7071  parser.load(&input);
    7172
  • src/Actions/MoleculeAction/FillWithMoleculeAction.cpp

    rfa9d1d r360c8b  
    2828#include "Descriptors/MoleculeOrderDescriptor.hpp"
    2929#include "molecule.hpp"
     30#include "Parser/FormatParserInterface.hpp"
    3031#include "Parser/FormatParserStorage.hpp"
    3132#include "World.hpp"
     
    6162  input.open(params.fillername.string().c_str());
    6263  ParserTypes type = FormatParserStorage::getInstance().getTypeFromSuffix(FilenameSuffix);
    63   FormatParser &parser = FormatParserStorage::getInstance().get(type);
     64  FormatParserInterface &parser = FormatParserStorage::getInstance().get(type);
    6465  parser.load(&input);
    6566
  • src/Actions/MoleculeAction/LoadAction.cpp

    rfa9d1d r360c8b  
    2323#include "CodePatterns/Verbose.hpp"
    2424#include "Descriptors/MoleculeIdDescriptor.hpp"
     25#include "Parser/FormatParserInterface.hpp"
    2526#include "Parser/FormatParserStorage.hpp"
    2627#include "Parser/FormatParser_Parameters.hpp"
     
    7071    // get undo state for parser
    7172    enum ParserTypes type = FormatParserStorage::getInstance().getTypeFromSuffix(FilenameSuffix);
     73    ASSERT(type != ParserTypes_end,
     74        "MoleculeLoadAction::performCall() - unknown file suffix "+FilenameSuffix+".");
    7275    FormatParser_Parameters *ParserParams = FormatParserStorage::getInstance().get(type).parameters;
    7376    if (ParserParams != NULL)
  • src/Actions/ParserAction/ParseTremoloPotentialsAction.cpp

    rfa9d1d r360c8b  
    4343
    4444  boost::filesystem::ifstream test;
    45   TremoloParser &tremolo = FormatParserStorage::getInstance().getTremolo();
     45  FormatParser<tremolo> &parser = FormatParserStorage::getInstance().getParser<tremolo>();
    4646  // parsing file if present
    4747  if (!boost::filesystem::exists(params.filename)) {
    4848    DoLog(1) && (Log() << Verbose(1) << "Specified potentials file " << params.filename << " not found." << endl);
    4949    // DONT FAIL: it's just empty we re-create default id-mapping
    50     tremolo.createKnownTypesByIdentity();
     50    parser.createKnownTypesByIdentity();
    5151
    5252  } else {
     
    5555    // parse the file
    5656    test.open(params.filename);
    57     TremoloParser &tremolo = FormatParserStorage::getInstance().getTremolo();
    58     tremolo.parseKnownTypes(test);
     57    parser.parseKnownTypes(test);
    5958    test.close();
    6059  }
  • src/Actions/ParserAction/SetMpqcParametersAction.cpp

    rfa9d1d r360c8b  
    3838/** =========== define the function ====================== */
    3939Action::state_ptr ParserSetMpqcParametersAction::performCall() {
    40   MpqcParser_Parameters &mpqc = FormatParserStorage::getInstance().getMpqc().getParams();
     40  MpqcParser_Parameters &parser = FormatParserStorage::getInstance().getParser<mpqc>().getParams();
    4141
    4242  std::stringstream oldparamstream;
    43   oldparamstream << mpqc;
     43  oldparamstream << parser;
    4444  // obtain information
    4545  getParametersfromValueStorage();
    4646  std::stringstream newparamstream(params.newparams);
    47   newparamstream >> mpqc;
     47  newparamstream >> parser;
    4848
    4949  return Action::state_ptr(new ParserSetMpqcParametersState(oldparamstream.str(), params));
     
    5353  ParserSetMpqcParametersState *state = assert_cast<ParserSetMpqcParametersState*>(_state.get());
    5454
    55   MpqcParser_Parameters &mpqc = FormatParserStorage::getInstance().getMpqc().getParams();
     55  MpqcParser_Parameters &parser = FormatParserStorage::getInstance().getParser<mpqc>().getParams();
    5656  std::stringstream oldparamstream(state->oldparams);
    57   oldparamstream >> mpqc;
     57  oldparamstream >> parser;
    5858
    5959  return Action::state_ptr(_state);
     
    6363  ParserSetMpqcParametersState *state = assert_cast<ParserSetMpqcParametersState*>(_state.get());
    6464
    65   MpqcParser_Parameters &mpqc = FormatParserStorage::getInstance().getMpqc().getParams();
     65  MpqcParser_Parameters &parser = FormatParserStorage::getInstance().getParser<mpqc>().getParams();
    6666  std::stringstream newparamstream(state->params.newparams);
    67   newparamstream >> mpqc;
     67  newparamstream >> parser;
    6868
    6969  return Action::state_ptr(_state);
  • src/Actions/ParserAction/SetTremoloAtomdataAction.cpp

    rfa9d1d r360c8b  
    4242  getParametersfromValueStorage();
    4343
    44   TremoloParser &tremolo = FormatParserStorage::getInstance().getTremolo();
     44  FormatParser<tremolo> &parser = FormatParserStorage::getInstance().getParser<tremolo>();
    4545
    4646  DoLog(1) && (Log() << Verbose(1) << "Setting Tremolo's ATOMDATA to: '" << params.atomdata_string << "'" << std::endl);
    4747
    48   tremolo.setAtomData(params.atomdata_string);
     48  parser.setAtomData(params.atomdata_string);
    4949
    5050  return Action::success;
  • src/Parser/FormatParser.hpp

    rfa9d1d r360c8b  
    1414#endif
    1515
     16#include <iosfwd>
     17#include <string>
     18#include <vector>
    1619
    17 #include "CodePatterns/Observer.hpp"
    18 #include "ChangeTracker.hpp"
    19 #include "FormatParser_Parameters.hpp"
     20#include "CodePatterns/Assert.hpp"
    2021
    21 namespace MoleCuilder {
    22   class MoleculeLoadAction;
    23 }
     22#include "FormatParserTrait.hpp"
     23#include "FormatParserInterface.hpp"
     24#include "FormatParser_common.hpp"
     25#include "ParserTypes.hpp"
    2426
    2527class atom;
    2628
    2729/**
     30 * @file
     31 * <H1> FormatParser Howto </H1>
     32 *
     33 * <H2> Introduction </H2>
     34 *
     35 * FormatParsers parse external streams (files) and bring their information
     36 * into the World. That is they implement load and save functions that work
     37 * on a specific vector atoms.
     38 *
     39 * <H2> Building your own Parsers </H2>
     40 *
     41 * Building Parsers is easy. All you have to do is the following:
     42 * -# add a new parser type to the file ParserTypes.def.
     43 * -# add a new template specialization of FormatParser in a new header and
     44 *    module that implement the virtual load and save functions.
     45 * -# Add the header file of your new parser to FormatParserStorage.cpp.
     46 *
     47 * <H3> Specific notes on the macros </H3>
     48 *
     49 * To clarify a bit the internals of all the different FormatParser... files, here
     50 * are some notes:
     51 * -# We make use of boost::preprocessor to generate lists from the sequence
     52 *    given in ParserTypes.def (and undefined in ParserTypes.undef). These might
     53 *    be forward declarations of even implementations. This is to assure that
     54 *    none are forgotten when a new FormatParser is added.
     55 * -# Thanks to the above construct FormatParserStorage also immediately knows
     56 *    about any new parsers and can get and add such instances.
     57 */
     58
     59/**
    2860 * General parser which observes the change tracker.
    2961 */
    30 class FormatParser : public Observer {
    31   friend class MoleCuilder::MoleculeLoadAction;
    32 public:
    33   FormatParser();
    34   virtual ~FormatParser();
    35   virtual void save(std::ostream* file, const std::vector<atom *> &atoms)=0;
    36   virtual void load(std::istream* file)=0;
    37   void setOstream(std::ostream* file);
     62template <enum ParserTypes Ptype>
     63class FormatParser : virtual public FormatParserInterface, public FormatParser_common {
     64  FormatParser() :
     65    FormatParser_common(NULL)
     66  {
     67    ASSERT(0, "FormatParser<>::FormatParser() - unspecialized function cannot be called.");
     68  }
     69  virtual ~FormatParser()
     70  {
     71    ASSERT(0, "FormatParser<>::~FormatParser() - unspecialized function cannot be called.");
     72  }
    3873
    39 protected:
    40   void update(Observable *publisher);
    41   void recieveNotification(Observable *publisher, Notification_ptr notification);
    42   void subjectKilled(Observable *publisher);
    43 
    44   // these functions are called when atoms are inserted or removed
    45   virtual void AtomInserted(atomId_t) {};
    46   virtual void AtomRemoved(atomId_t) {};
    47 
    48   FormatParser_Parameters *parameters;
    49 private:
    50 
    51   std::ostream* saveStream;
     74  void load(std::istream *file)
     75  {
     76    ASSERT(0, "FormatParser<>::load() - unspecialized function cannot be called.");
     77  }
     78  void save(std::ostream *file, const std::vector<atom *> &atoms)
     79  {
     80    ASSERT(0, "FormatParser<>::save() - unspecialized function cannot be called.");
     81  }
    5282};
    5383
     84#include "FormatParser_specializations_header.hpp"
     85
    5486#endif /* FORMATPARSER_HPP_ */
  • src/Parser/FormatParserStorage.cpp

    rfa9d1d r360c8b  
    2323#include <fstream>
    2424
    25 #include "Parser/FormatParserStorage.hpp"
    26 
     25#include <boost/preprocessor/iteration/local.hpp>
     26
     27#include "CodePatterns/Assert.hpp"
    2728#include "CodePatterns/Log.hpp"
    28 #include "CodePatterns/Verbose.hpp"
    29 
    30 #include "CodePatterns/Assert.hpp"
    3129
    3230#include "molecule.hpp"
     31#include "FormatParserStorage.hpp"
     32#include "ParserTypes.hpp"
     33
     34#include "MpqcParser.hpp"
     35#include "PcpParser.hpp"
     36#include "PdbParser.hpp"
     37#include "Psi3Parser.hpp"
     38#include "TremoloParser.hpp"
     39#include "XyzParser.hpp"
    3340
    3441#include "CodePatterns/Singleton_impl.hpp"
    3542
    36 /** Increment operator for the enumeration ParserTypes to allow loops.
    37  * \param &type value
    38  * \return value incremented by one
    39  */
    40 ParserTypes &operator++(ParserTypes &type)
    41 {
    42   return type = ParserTypes(type+1);
    43 }
    4443
    4544/** Constructor of class FormatParserStorage.
     
    5150  ParserPresent.resize(ParserTypes_end, false);
    5251
    53   ParserNames[mpqc] = "mpqc";
    54   ParserNames[pcp] = "pcp";
    55   ParserNames[pdb] = "pdb";
    56   ParserNames[tremolo] = "tremolo";
    57   ParserNames[xyz] = "xyz";
    58 
    59   for (std::map<ParserTypes, std::string>::const_iterator it = ParserNames.begin(); it != ParserNames.end(); ++it)
    60     ParserLookupNames.insert(pair<std::string, ParserTypes>(it->second,it->first) );
    61 
    62   ParserSuffixes[mpqc] = "in";
    63   ParserSuffixes[pcp] = "conf";
    64   ParserSuffixes[pdb] = "pdb";
    65   ParserSuffixes[tremolo] = "data";
    66   ParserSuffixes[xyz] = "xyz";
    67 
    68   for (std::map<ParserTypes, std::string>::const_iterator it = ParserSuffixes.begin(); it != ParserSuffixes.end(); ++it)
    69     ParserLookupSuffixes.insert(pair<std::string, ParserTypes>(it->second,it->first) );
    70 
    71   ParserAddFunction[mpqc] = &FormatParserStorage::addMpqc;
    72   ParserAddFunction[pcp] = &FormatParserStorage::addPcp;
    73   ParserAddFunction[pdb] = &FormatParserStorage::addPdb;
    74   ParserAddFunction[tremolo] = &FormatParserStorage::addTremolo;
    75   ParserAddFunction[xyz] = &FormatParserStorage::addXyz;
     52#include "ParserTypes.def"
     53
     54#define insert_print(z,n,seq,map, before, after) \
     55   map .insert( std::make_pair(  \
     56     BOOST_PP_SEQ_ELEM(n, seq) \
     57     , before < \
     58       BOOST_PP_SEQ_ELEM(n, seq) \
     59       > after \
     60     ) );
     61 
     62#define insert_invert_print(z,n,seq,map, before, after) \
     63   map .insert( std::make_pair( before < \
     64   BOOST_PP_SEQ_ELEM(n, seq) \
     65   > after, \
     66   BOOST_PP_SEQ_ELEM(n, seq) \
     67  ) );
     68
     69  // fill ParserNames
     70#if defined ParserTypes_END // do we have parameters at all?
     71#define BOOST_PP_LOCAL_MACRO(n) insert_print(~, n, PARSERSEQUENCE, ParserNames, FormatParserTrait, ::name)
     72#define BOOST_PP_LOCAL_LIMITS  (0, ParserTypes_END-1)
     73#include BOOST_PP_LOCAL_ITERATE()
     74#endif
     75
     76  // fill ParserLookupNames
     77#if defined ParserTypes_END // do we have parameters at all?
     78#define BOOST_PP_LOCAL_MACRO(n) insert_invert_print(~, n, PARSERSEQUENCE, ParserLookupNames, FormatParserTrait, ::name)
     79#define BOOST_PP_LOCAL_LIMITS  (0, ParserTypes_END-1)
     80#include BOOST_PP_LOCAL_ITERATE()
     81#endif
     82
     83  // fill ParserSuffixes
     84#if defined ParserTypes_END // do we have parameters at all?
     85#define BOOST_PP_LOCAL_MACRO(n) insert_print(~, n, PARSERSEQUENCE, ParserSuffixes, FormatParserTrait, ::suffix)
     86#define BOOST_PP_LOCAL_LIMITS  (0, ParserTypes_END-1)
     87#include BOOST_PP_LOCAL_ITERATE()
     88#endif
     89
     90  // fill ParserLookupSuffixes
     91#if defined ParserTypes_END // do we have parameters at all?
     92#define BOOST_PP_LOCAL_MACRO(n) insert_invert_print(~, n, PARSERSEQUENCE, ParserLookupSuffixes, FormatParserTrait, ::suffix)
     93#define BOOST_PP_LOCAL_LIMITS  (0, ParserTypes_END-1)
     94#include BOOST_PP_LOCAL_ITERATE()
     95#endif
     96
     97  // fill ParserAddFunction
     98#if defined ParserTypes_END // do we have parameters at all?
     99#define BOOST_PP_LOCAL_MACRO(n) insert_print(~, n, PARSERSEQUENCE, ParserAddFunction, &FormatParserStorage::addParser, )
     100#define BOOST_PP_LOCAL_LIMITS  (0, ParserTypes_END-1)
     101#include BOOST_PP_LOCAL_ITERATE()
     102#endif
     103
     104#undef insert_print
     105#undef insert_invert_print
     106#include "ParserTypes.undef"
     107
     108  //std::cout << "ParserNames:" << std::endl << ParserNames << std::endl;
     109  //std::cout << "ParserSuffixes:" << std::endl << ParserSuffixes << std::endl;
     110  //std::cout << "ParserLookupNames:" << std::endl << ParserLookupNames << std::endl;
     111  //std::cout << "ParserLookupSuffixes:" << std::endl << ParserLookupSuffixes << std::endl;
     112  //std::cout << "ParserAddFunction:" << std::endl << ParserAddFunction << std::endl;
     113
    76114}
    77115
     
    114152
    115153
    116 /** Adds an MpqcParser to the storage.
    117  */
    118 void FormatParserStorage::addMpqc()
    119 {
    120   if (!ParserPresent[mpqc]) {
    121     ParserList[mpqc] = dynamic_cast<FormatParser *>(new MpqcParser);
    122     ParserPresent[mpqc] = true;
    123   }
    124   else
    125     DoeLog(2) && (eLog() << Verbose(2) << "Parser mpqc is already present." << endl
    126         << "Note that you don't need to add '-o mpqc' if the input file is of type mpqc." << endl);
    127 }
    128 
    129 
    130 /** Adds an PcpParser to the storage.
    131  */
    132 void FormatParserStorage::addPcp()
    133 {
    134   if (!ParserPresent[pcp]) {
    135     ParserList[pcp] = new PcpParser();
    136     ParserPresent[pcp] = true;
    137   } else
    138     DoeLog(2) && (eLog() << Verbose(2) << "Parser pcp is already present." << endl
    139         << "Note that you don't need to add '-o pcp' if the input file is of type pcp." << endl);
    140 }
    141 
    142 
    143 /** Adds an PdbParser to the storage.
    144  */
    145 void FormatParserStorage::addPdb()
    146 {
    147   if (!ParserPresent[pdb]) {
    148     ParserList[pdb] = new PdbParser();
    149     ParserPresent[pdb] = true;
    150   } else
    151     DoeLog(2) && (eLog() << Verbose(2) << "Parser pdb is already present." << endl
    152         << "Note that you don't need to add '-o pdb' if the input file is of type pdb." << endl);
    153 }
    154 
    155 
    156 /** Adds an TremoloParser to the storage.
    157  */
    158 void FormatParserStorage::addTremolo()
    159 {
    160   if (!ParserPresent[tremolo]) {
    161     ParserList[tremolo] = new TremoloParser();
    162     ParserPresent[tremolo] = true;
    163   } else
    164     DoeLog(2) && (eLog() << Verbose(2) << "Parser tremolo is already present." << endl
    165         << "Note that you don't need to add '-o tremolo' if the input file is of type tremolo." << endl);
    166 }
    167 
    168 
    169 /** Adds an XyzParser to the storage.
    170  */
    171 void FormatParserStorage::addXyz()
    172 {
    173   if (!ParserPresent[xyz]) {
    174     ParserList[xyz] = new XyzParser();
    175     ParserPresent[xyz] = true;
    176   } else
    177     DoeLog(2) && (eLog() << Verbose(2) << "Parser xyz is already present." << endl
    178         << "Note that you don't need to add '-o xyz' if the input file is of type xyz." << endl);
    179 }
    180 
    181154ParserTypes FormatParserStorage::getTypeFromName(std::string type)
    182155{
     
    201174  if (ptype != ParserTypes_end) {
    202175    if (ParserAddFunction.find(ptype) != ParserAddFunction.end()) {
    203       DoLog(0) && (Log() << Verbose(0) << "Adding " << ParserNames[ptype] << " type to output." << endl);
     176      LOG(0, "STATUS: Adding " << ParserNames[ptype] << " type to output.");
    204177      (getInstance().*(ParserAddFunction[ptype]))(); // we still need an object to work on ...
    205178      return true;
    206179    } else {
    207       DoeLog(1) && (eLog() << Verbose(1) << "No parser to add for this known type " << ParserNames[ptype] << ", not implemented?" << endl);
     180      ELOG(1, "No parser to add for this known type " << ParserNames[ptype] << ", not implemented?");
    208181      return false;
    209182    }
     
    215188bool FormatParserStorage::add(std::string type)
    216189{
    217   return add(getTypeFromName(type));
     190  enum ParserTypes Ptype = getTypeFromName(type);
     191  return add(Ptype);
    218192}
    219193
     
    226200bool FormatParserStorage::load(std::istream &input, std::string suffix)
    227201{
    228   if (suffix == ParserSuffixes[mpqc]) {
    229     getMpqc().load(&input);
    230   } else if (suffix == ParserSuffixes[pcp]) {
    231     getPcp().load(&input);
    232   } else if (suffix == ParserSuffixes[pdb]) {
    233     getPdb().load(&input);
    234   } else if (suffix == ParserSuffixes[tremolo]) {
    235     getTremolo().load(&input);
    236   } else if (suffix == ParserSuffixes[xyz]) {
    237     getXyz().load(&input);
    238   } else {
    239     DoeLog(1) && (eLog() << Verbose(1) << "Unknown suffix " << suffix << " to for FormatParserStorage::get()." << endl);
     202  enum ParserTypes type = getTypeFromSuffix(suffix);
     203  if (type != ParserTypes_end)
     204    get(type).load(&input);
     205  else
    240206    return false;
    241   }
    242207  return true;
    243208}
     
    302267bool FormatParserStorage::save(std::ostream &output, std::string suffix, const std::vector<atom *> &atoms)
    303268{
    304   if (suffix == ParserSuffixes[mpqc]) {
    305     getMpqc().save(&output, atoms);
    306   } else if (suffix == ParserSuffixes[pcp]) {
    307     getPcp().save(&output, atoms);
    308   } else if (suffix == ParserSuffixes[pdb]) {
    309     getPdb().save(&output, atoms);
    310   } else if (suffix == ParserSuffixes[tremolo]) {
    311     getTremolo().save(&output, atoms);
    312   } else if (suffix == ParserSuffixes[xyz]) {
    313     getXyz().save(&output, atoms);
    314   } else {
    315     DoeLog(1) && (eLog() << Verbose(1) << "Unknown suffix " << suffix << " to for FormatParserStorage::put()." << endl);
     269  enum ParserTypes type = getTypeFromSuffix(suffix);
     270  if (type != ParserTypes_end)
     271    get(type).save(&output, atoms);
     272  else
    316273    return false;
    317   }
    318274  return true;
    319 }
    320 
    321 /** Returns reference to the output MpqcParser, adds if not present.
    322  * \return reference to the output MpqcParser
    323  */
    324 MpqcParser &FormatParserStorage::getMpqc()
    325 {
    326   if (!ParserPresent[mpqc])
    327     addMpqc();
    328   return dynamic_cast<MpqcParser &>(*ParserList[mpqc]);
    329 }
    330 
    331 /** Returns reference to the output PcpParser, adds if not present.
    332  * \return reference to the output PcpParser
    333  */
    334 PcpParser &FormatParserStorage::getPcp()
    335 {
    336   if (!ParserPresent[pcp])
    337     addPcp();
    338   return dynamic_cast<PcpParser &>(*ParserList[pcp]);
    339 }
    340 
    341 /** Returns reference to the output PdbParser, adds if not present.
    342  * \return reference to the output PdbParser
    343  */
    344 PdbParser &FormatParserStorage::getPdb()
    345 {
    346   if (!ParserPresent[pdb])
    347     addPdb();
    348   return dynamic_cast<PdbParser &>(*ParserList[pdb]);
    349 }
    350 
    351 /** Returns reference to the output TremoloParser, adds if not present.
    352  * \return reference to the output TremoloParser
    353  */
    354 TremoloParser &FormatParserStorage::getTremolo()
    355 {
    356   if (!ParserPresent[tremolo])
    357     addTremolo();
    358   return dynamic_cast<TremoloParser &>(*ParserList[tremolo]);
    359 }
    360 
    361 /** Returns reference to the output XyzParser, adds if not present.
    362  * \return reference to the output XyzParser
    363  */
    364 XyzParser &FormatParserStorage::getXyz()
    365 {
    366   if (!ParserPresent[xyz])
    367     addXyz();
    368   return dynamic_cast<XyzParser &>(*ParserList[xyz]);
    369275}
    370276
     
    373279 * \return reference to the output FormatParser with desired type
    374280 */
    375 FormatParser &FormatParserStorage::get(ParserTypes _type)
     281FormatParserInterface &FormatParserStorage::get(ParserTypes _type)
    376282{
    377283  if (!ParserPresent[_type]) {
  • src/Parser/FormatParserStorage.hpp

    rfa9d1d r360c8b  
    1616#include "CodePatterns/Singleton.hpp"
    1717
     18#include <iosfwd>
     19#include <map>
    1820#include <string>
    19 #include <map>
    2021#include <vector>
    2122
    22 #include "Parser/FormatParser.hpp"
    23 #include "Parser/MpqcParser.hpp"
    24 #include "Parser/PcpParser.hpp"
    25 #include "Parser/PdbParser.hpp"
    26 #include "Parser/TremoloParser.hpp"
    27 #include "Parser/XyzParser.hpp"
     23#include "CodePatterns/Assert.hpp"
     24#include "CodePatterns/Log.hpp"
     25#include "FormatParser.hpp"
     26#include "ParserTypes.hpp"
    2827
    2928class atom;
    30 
    31 // enum has to be outside of class for operator++ to be possible
    32 enum ParserTypes { mpqc, pcp, pdb, tremolo, xyz, ParserTypes_end, ParserTypes_begin = mpqc };
    33 typedef enum ParserTypes ParserTypes;
    34 
    35 ParserTypes &operator++(ParserTypes &type);
     29class FormatParserInterface;
    3630
    3731class FormatParserStorage : public Singleton<FormatParserStorage> {
     
    3933public:
    4034
    41   void addMpqc();
    42   void addPcp();
    43   void addPdb();
    44   void addTremolo();
    45   void addXyz();
    4635  bool add(std::string type);
    4736  bool add(ParserTypes type);
     
    5241  bool saveSelectedMolecules(std::ostream &output, std::string suffix);
    5342  bool saveWorld(std::ostream &output, std::string suffix);
    54   MpqcParser &getMpqc();
    55   PcpParser &getPcp();
    56   PdbParser &getPdb();
    57   TremoloParser &getTremolo();
    58   XyzParser &getXyz();
    59   FormatParser &get(enum ParserTypes _type);
     43 
     44  FormatParserInterface &get(ParserTypes _type);
    6045
    6146  ParserTypes getTypeFromName(std::string type);
     
    7156 
    7257  // list of allocated parsers
    73   std::vector<FormatParser *> ParserList;
     58  std::vector<FormatParserInterface *> ParserList;
    7459
    7560  // list of allocated strams
     
    9075  std::map<std::string, ParserTypes> ParserLookupNames;
    9176
    92 
    9377  // prefix of the filenames to use on save
    9478  std::string prefix;
     79
     80public:
     81  template<ParserTypes Ptype> void addParser()
     82  {
     83    if (!ParserPresent[Ptype]) {
     84      ParserList[Ptype] = new FormatParser<Ptype>();
     85      ParserPresent[Ptype] = true;
     86    } else {
     87      ASSERT(ParserNames.find(Ptype) != ParserNames.end(),
     88          "FormatParserStorage::addParser() - ParserNames unknown for type"+toString((size_t)Ptype)+".");
     89      ASSERT(ParserSuffixes.find(Ptype) != ParserSuffixes.end(),
     90          "FormatParserStorage::addParser() - ParserSuffixes unknown for type"+toString((size_t)Ptype)+".");
     91      LOG(2, "INFO: Parser " << ParserNames[Ptype] << " is already present." << std::endl
     92          << "Note that you don't need to add '-o "
     93          << ParserSuffixes[Ptype] << "' if the input file is non-empty and of type "
     94          << ParserSuffixes[Ptype] << "." << std::endl);
     95    }
     96  }
     97
     98  template<ParserTypes Ptype> FormatParser<Ptype> &getParser()
     99  {
     100    if(!ParserPresent[Ptype])
     101      addParser< Ptype >();
     102    return dynamic_cast<FormatParser<Ptype> &>(*ParserList[Ptype]);
     103  }
    95104};
    96105
  • src/Parser/FormatParser_Parameters.hpp

    rfa9d1d r360c8b  
    1414#endif
    1515
     16#include <iosfwd>
     17
    1618#include "CodePatterns/Clone.hpp"
     19
     20#include "Parser/Parameters/ParameterStorage.hpp"
     21
     22class Parameter;
    1723
    1824/** This class is an interface to the internal parameters of any FormatParser.
     
    2329class FormatParser_Parameters : public Clone<FormatParser_Parameters>
    2430{
     31  //!> allow operator access to storage for easier printing.
     32  friend std::ostream & operator << (std::ostream& ost, const FormatParser_Parameters &params);
    2533public:
    26   FormatParser_Parameters() {}
    27   ~FormatParser_Parameters() {}
     34  FormatParser_Parameters();
     35  FormatParser_Parameters(const FormatParser_Parameters &_parameters);
     36  ~FormatParser_Parameters();
    2837
    29   /** Makes this instance a clone of given \a _instance.
    30    *
    31    * @param _instance instance to clone
    32    */
    33   virtual void makeClone(const FormatParser_Parameters & _instance)=0;
     38  // cloning
     39  FormatParser_Parameters* clone() const;
     40  void makeClone(const FormatParser_Parameters &_instance);
     41
     42  // accessing parameters in storage
     43  void appendParameter(Parameter *instance);
     44  bool haveParameter(const std::string &_name) const;
     45  Parameter *getParameter(const std::string &_name) const;
     46
     47protected:
     48  ParameterStorage *storage;
    3449};
     50
     51std::ostream & operator << (std::ostream& ost, const FormatParser_Parameters &params);
     52
     53std::istream & operator >> (std::istream& ist, FormatParser_Parameters &params);
    3554
    3655
  • src/Parser/Makefile.am

    rfa9d1d r360c8b  
    55PARSERSOURCE = \
    66  Parser/ChangeTracker.cpp \
    7   Parser/FormatParser.cpp \
     7  Parser/FormatParser_common.cpp \
     8  Parser/FormatParser_Parameters.cpp \
    89  Parser/FormatParserStorage.cpp \
    910  Parser/MpqcParser.cpp \
    1011  Parser/MpqcParser_Parameters.cpp \
    1112  Parser/MpqcParser_Parameters_initBasis.cpp \
     13  Parser/ParserTypes.cpp \
    1214  Parser/PcpParser.cpp \
    1315  Parser/PdbAtomInfoContainer.cpp \
    1416  Parser/PdbParser.cpp \
     17  Parser/Psi3Parser.cpp \
     18  Parser/Psi3Parser_Parameters.cpp \
    1519  Parser/TremoloParser.cpp \
    1620  Parser/TremoloAtomInfoContainer.cpp \
     
    2024  Parser/ChangeTracker.hpp \
    2125  Parser/FormatParser.hpp \
     26  Parser/FormatParser_specializations_header.hpp \
     27  Parser/FormatParser_common.hpp \
     28  Parser/FormatParserInterface.hpp \
     29  Parser/FormatParserTrait.hpp \
     30  Parser/FormatParserTrait_specializations_header.hpp \
    2231  Parser/FormatParser_Parameters.hpp \
    2332  Parser/FormatParserStorage.hpp \
    2433  Parser/MpqcParser.hpp \
    2534  Parser/MpqcParser_Parameters.hpp \
     35  Parser/ParserTypes.hpp \
     36  Parser/ParserTypes.def \
     37  Parser/ParserTypes.undef \
    2638  Parser/PcpParser.hpp \
    2739  Parser/PdbAtomInfoContainer.hpp \
    2840  Parser/PdbKey.hpp \
    2941  Parser/PdbParser.hpp \
     42  Parser/Psi3Parser.hpp \
     43  Parser/Psi3Parser_Parameters.hpp \
    3044  Parser/TremoloKey.hpp \
    3145  Parser/TremoloParser.hpp \
     
    3347  Parser/XyzParser.hpp
    3448
     49PARSERPARAMETERSSOURCE = \
     50        Parser/Parameters/ParameterStorage.cpp \
     51        Parser/Parameters/StringParameter.cpp
     52
     53PARSERPARAMETERSHEADER = \
     54        Parser/Parameters/ParameterStorage.hpp \
     55        Parser/Parameters/ContinuousParameter.hpp \
     56        Parser/Parameters/ContinuousParameter_impl.hpp \
     57        Parser/Parameters/ContinuousValue.hpp \
     58        Parser/Parameters/ContinuousValue_impl.hpp \
     59        Parser/Parameters/DiscreteParameter.hpp \
     60        Parser/Parameters/DiscreteParameter_impl.hpp \
     61        Parser/Parameters/DiscreteValue.hpp \
     62        Parser/Parameters/DiscreteValue_impl.hpp \
     63        Parser/Parameters/Parameter.hpp \
     64        Parser/Parameters/StringParameter.hpp \
     65        Parser/Parameters/ValueInterface.hpp
    3566
    3667noinst_LTLIBRARIES += libMolecuilderParser.la
    3768libMolecuilderParser_la_includedir = $(includedir)/MoleCuilder/Parser/
    3869
    39 nobase_libMolecuilderParser_la_include_HEADERS = ${PARSERHEADER}
     70nobase_libMolecuilderParser_la_include_HEADERS = ${PARSERHEADER} ${PARSERPARAMETERSHEADER}
    4071
    4172## Define the source file list for the "libexample-@MOLECUILDER_API_VERSION@.la"
     
    4778## from each source file.  Note that it is not necessary to list header files
    4879## which are already listed elsewhere in a _HEADERS variable assignment.
    49 libMolecuilderParser_la_SOURCES = ${PARSERSOURCE}
     80libMolecuilderParser_la_SOURCES = ${PARSERSOURCE} ${PARSERPARAMETERSSOURCE}
    5081
    5182## Instruct libtool to include ABI version information in the generated shared
  • src/Parser/MpqcParser.cpp

    rfa9d1d r360c8b  
    3838#include "World.hpp"
    3939
     40// declare specialized static variables
     41const std::string FormatParserTrait<mpqc>::name = "mpqc";
     42const std::string FormatParserTrait<mpqc>::suffix = "in";
     43const ParserTypes FormatParserTrait<mpqc>::type = mpqc;
     44
     45// a converter we often need
     46ConvertTo<bool> FormatParser<mpqc>::Converter;
    4047
    4148/** Constructor of MpqcParser.
    4249 *
    4350 */
    44 MpqcParser::MpqcParser()
    45 {
    46   parameters = new MpqcParser_Parameters();
    47 }
     51FormatParser< mpqc >::FormatParser() :
     52  FormatParser_common(new MpqcParser_Parameters())
     53{}
    4854
    4955/** Destructor of MpqcParser.
    5056 *
    5157 */
    52 MpqcParser::~MpqcParser()
    53 {
    54   delete parameters;
    55 }
     58FormatParser< mpqc >::~FormatParser()
     59{}
    5660
    5761/** Load an MPQC config file into the World.
    5862 * \param *file input stream
    5963 */
    60 void MpqcParser::load(istream *file)
     64void FormatParser< mpqc >::load(istream *file)
    6165{
    6266  bool MpqcSection = false;
     
    96100        tokenizer::iterator tok_iter = tokens.begin();
    97101        ASSERT(tok_iter != tokens.end(),
    98             "MpqcParser::load() - missing token for MoleculeSection in line "+linestring+"!");
     102            "FormatParser< mpqc >::load() - missing token for MoleculeSection in line "+linestring+"!");
    99103        std::stringstream whitespacefilter(*tok_iter++);
    100104        std::string element;
    101105        whitespacefilter >> ws >> element;
    102106        ASSERT(tok_iter != tokens.end(),
    103             "MpqcParser::load() - missing token for MoleculeSection in line "+linestring+"!");
     107            "FormatParser< mpqc >::load() - missing token for MoleculeSection in line "+linestring+"!");
    104108        std::string vector = *tok_iter;
    105109        tokenizer vectorcomponents(vector, whitesep);
     
    125129        ++tok_iter;
    126130        ASSERT(tok_iter != tokens.end(),
    127             "MpqcParser::load() - missing token in brackets<> for mole< in line "+linestring+"!");
     131            "FormatParser< mpqc >::load() - missing token in brackets<> for mole< in line "+linestring+"!");
    128132        std::string value(*tok_iter);
    129133        std::stringstream linestream("theory = "+value);
     
    134138        ++tok_iter;
    135139        ASSERT(tok_iter != tokens.end(),
    136             "MpqcParser::load() - missing token in brackets<> for integrals< in line "+linestring+"!");
     140            "FormatParser< mpqc >::load() - missing token in brackets<> for integrals< in line "+linestring+"!");
    137141        std::string value(*tok_iter);
    138142        std::stringstream linestream("integration = "+value);
     
    143147        tokenizer::iterator tok_iter = tokens.begin();
    144148        ASSERT(tok_iter != tokens.end(),
    145             "MpqcParser::load() - missing token before '=' for MpqcSection in line "+linestring+"!");
     149            "FormatParser< mpqc >::load() - missing token before '=' for MpqcSection in line "+linestring+"!");
    146150        std::stringstream whitespacefilter(*tok_iter);
    147151        std::string key;
    148152        whitespacefilter >> ws >> key;
    149         if (getParams().haveParam(key)) {
     153        if (getParams().haveParameter(key)) {
    150154          std::stringstream linestream(linestring);
    151155          linestream >> getParams();
     
    159163      tokenizer::iterator tok_iter = tokens.begin();
    160164      ASSERT(tok_iter != tokens.end(),
    161           "MpqcParser::load() - missing token for BasisSection in line "+linestring+"!");
     165          "FormatParser< mpqc >::load() - missing token for BasisSection in line "+linestring+"!");
    162166      std::string key(*tok_iter++);
    163167      ASSERT(tok_iter != tokens.end(),
    164           "MpqcParser::load() - missing value for BasisSection after key "+key+" in line "+linestring+"!");
     168          "FormatParser< mpqc >::load() - missing value for BasisSection after key "+key+" in line "+linestring+"!");
    165169      std::string value(*tok_iter);
    166170      tok_iter++;
    167171      // TODO: use exception instead of ASSERT
    168172      ASSERT(tok_iter == tokens.end(),
    169           "MpqcParser::load() - more than (key = value) on line "+linestring+".");
     173          "FormatParser< mpqc >::load() - more than (key = value) on line "+linestring+".");
    170174      if (key == "name") {
    171175        std::stringstream linestream("basis = "+value);
     
    177181      tokenizer::iterator tok_iter = tokens.begin();
    178182      ASSERT(tok_iter != tokens.end(),
    179           "MpqcParser::load() - missing token for AuxBasisSection in line "+linestring+"!");
     183          "FormatParser< mpqc >::load() - missing token for AuxBasisSection in line "+linestring+"!");
    180184      std::string key(*tok_iter++);
    181185      ASSERT(tok_iter != tokens.end(),
    182           "MpqcParser::load() - missing value for BasisSection after key "+key+" in line "+linestring+"!");
     186          "FormatParser< mpqc >::load() - missing value for BasisSection after key "+key+" in line "+linestring+"!");
    183187      std::string value(*tok_iter);
    184188      tok_iter++;
    185189      // TODO: use exception instead of ASSERT
    186190      ASSERT(tok_iter == tokens.end(),
    187           "MpqcParser::load() - more than (key = value) on line "+linestring+".");
     191          "FormatParser< mpqc >::load() - more than (key = value) on line "+linestring+".");
    188192      if (key == "name") {
    189193        std::stringstream linestream("aux_basis = "+value);
     
    216220 * \param atoms atoms to store
    217221 */
    218 void MpqcParser::save(ostream *file, const std::vector<atom *> &atoms)
     222void FormatParser< mpqc >::save(ostream *file, const std::vector<atom *> &atoms)
    219223{
    220224  Vector center;
     
    232236    *file << "% Created by MoleCuilder" << endl;
    233237    *file << "mpqc: (" << endl;
    234     *file << "\tsavestate = " << getParams().getString(MpqcParser_Parameters::savestateParam) << endl;
    235     *file << "\tdo_gradient = " << getParams().getString(MpqcParser_Parameters::do_gradientParam) << endl;
    236     if (getParams().getBool(MpqcParser_Parameters::hessianParam)) {
     238    *file << "\tsavestate = " << getParams().getParameter(MpqcParser_Parameters::savestateParam) << endl;
     239    *file << "\tdo_gradient = " << getParams().getParameter(MpqcParser_Parameters::do_gradientParam) << endl;
     240    if (Converter(getParams().getParameter(MpqcParser_Parameters::hessianParam))) {
    237241      *file << "\tfreq<MolecularFrequencies>: (" << endl;
    238242      *file << "\t\tmolecule=$:molecule" << endl;
    239243      *file << "\t)" << endl;
    240244    }
    241     switch (getParams().getTheory()) {
    242       case MpqcParser_Parameters::CLHF:
    243         *file << "\tmole<" << getParams().getString(MpqcParser_Parameters::theoryParam) << ">: (" << endl;
    244         *file << "\t\tmolecule = $:molecule" << endl;
    245         *file << "\t\tbasis = $:basis" << endl;
    246         *file << "\t\tmaxiter = " << toString(getParams().getInt(MpqcParser_Parameters::maxiterParam))<< endl;
    247         *file << "\t\tmemory = " << toString(getParams().getInt(MpqcParser_Parameters::memoryParam)) << endl;
    248         *file << "\t)" << endl;
    249         break;
    250       case MpqcParser_Parameters::CLKS:
    251         *file << "\tmole<" << getParams().getString(MpqcParser_Parameters::theoryParam) << ">: (" << endl;
    252         *file << "\t\tfunctional<StdDenFunctional>:(name=B3LYP)" << endl;
    253         *file << "\t\tmolecule = $:molecule" << endl;
    254         *file << "\t\tbasis = $:basis" << endl;
    255         *file << "\t\tmaxiter = " << toString(getParams().getInt(MpqcParser_Parameters::maxiterParam))<< endl;
    256         *file << "\t\tmemory = " << toString(getParams().getInt(MpqcParser_Parameters::memoryParam)) << endl;
    257         *file << "\t)" << endl;
    258         break;
    259       case MpqcParser_Parameters::MBPT2:
    260         *file << "\tmole<" << getParams().getString(MpqcParser_Parameters::theoryParam) << ">: (" << endl;
    261         *file << "\t\tbasis = $:basis" << endl;
    262         *file << "\t\tmolecule = $:molecule" << endl;
    263         *file << "\t\tmemory = " << toString(getParams().getInt(MpqcParser_Parameters::memoryParam)) << endl;
    264         *file << "\t\treference<CLHF>: (" << endl;
    265         *file << "\t\t\tmaxiter = " << toString(getParams().getInt(MpqcParser_Parameters::maxiterParam))<< endl;
    266         *file << "\t\t\tbasis = $:basis" << endl;
    267         *file << "\t\t\tmolecule = $:molecule" << endl;
    268         *file << "\t\t\tmemory = " << toString(getParams().getInt(MpqcParser_Parameters::memoryParam)) << endl;
    269         *file << "\t\t)" << endl;
    270         *file << "\t)" << endl;
    271         break;
    272       case MpqcParser_Parameters::MBPT2_R12:
    273         *file << "\tmole<" << getParams().getString(MpqcParser_Parameters::theoryParam) << ">: (" << endl;
    274         *file << "\t\tmolecule = $:molecule" << endl;
    275         *file << "\t\tbasis = $:basis" << endl;
    276         *file << "\t\taux_basis = $:abasis" << endl;
    277         *file << "\t\tstdapprox = \"" << getParams().getString(MpqcParser_Parameters::stdapproxParam) << "\"" << endl;
    278         *file << "\t\tnfzc = " << toString(getParams().getInt(MpqcParser_Parameters::nfzcParam)) << endl;
    279         *file << "\t\tmemory = " << toString(getParams().getInt(MpqcParser_Parameters::memoryParam)) << endl;
    280         *file << "\t\tintegrals<IntegralCints>:()" << endl;
    281         *file << "\t\treference<CLHF>: (" << endl;
    282         *file << "\t\t\tmolecule = $:molecule" << endl;
    283         *file << "\t\t\tbasis = $:basis" << endl;
    284         *file << "\t\t\tmaxiter = " << toString(getParams().getInt(MpqcParser_Parameters::maxiterParam)) << endl;
    285         *file << "\t\t\tmemory = " << toString(getParams().getInt(MpqcParser_Parameters::memoryParam)) << endl;
    286         *file << "\t\t\tintegrals<" << getParams().getString(MpqcParser_Parameters::integrationParam) << ">:()" << endl;
    287         *file << "\t\t)" << endl;
    288         *file << "\t)" << endl;
    289         break;
    290       default:
    291         DoeLog(0) && (eLog() << Verbose(0)
    292             << "Unknown level of theory requested for MPQC output file." << std::endl);
    293         break;
     245    const std::string theory = getParams().getParameter(MpqcParser_Parameters::theoryParam);
     246    if (theory == getParams().getTheoryName(MpqcParser_Parameters::CLHF)) {
     247      *file << "\tmole<" << getParams().getParameter(MpqcParser_Parameters::theoryParam) << ">: (" << endl;
     248      *file << "\t\tmolecule = $:molecule" << endl;
     249      *file << "\t\t" << getParams().getParameterName(MpqcParser_Parameters::basisParam) << " = $:basis" << endl;
     250      *file << "\t\t" << getParams().getParameterName(MpqcParser_Parameters::maxiterParam)
     251          << " = " << getParams().getParameter(MpqcParser_Parameters::maxiterParam)<< endl;
     252      *file << "\t\t" << getParams().getParameterName(MpqcParser_Parameters::memoryParam)
     253          << " = " << getParams().getParameter(MpqcParser_Parameters::memoryParam) << endl;
     254      *file << "\t)" << endl;
     255    } else if (theory == getParams().getTheoryName(MpqcParser_Parameters::CLKS)) {
     256      *file << "\tmole<" << getParams().getParameter(MpqcParser_Parameters::theoryParam) << ">: (" << endl;
     257      *file << "\t\tfunctional<StdDenFunctional>:(name=B3LYP)" << endl;
     258      *file << "\t\tmolecule = $:molecule" << endl;
     259      *file << "\t\t" << getParams().getParameterName(MpqcParser_Parameters::basisParam) << " = $:basis" << endl;
     260      *file << "\t\t" << getParams().getParameterName(MpqcParser_Parameters::maxiterParam)
     261          << " = " << getParams().getParameter(MpqcParser_Parameters::maxiterParam)<< endl;
     262      *file << "\t\t" << getParams().getParameterName(MpqcParser_Parameters::memoryParam)
     263          << " = " << getParams().getParameter(MpqcParser_Parameters::memoryParam) << endl;
     264      *file << "\t)" << endl;
     265    } else if (theory == getParams().getTheoryName(MpqcParser_Parameters::MBPT2)) {
     266      *file << "\tmole<" << getParams().getParameter(MpqcParser_Parameters::theoryParam) << ">: (" << endl;
     267      *file << "\t\t" << getParams().getParameterName(MpqcParser_Parameters::basisParam) << " = $:basis" << endl;
     268      *file << "\t\tmolecule = $:molecule" << endl;
     269      *file << "\t\t" << getParams().getParameterName(MpqcParser_Parameters::memoryParam)
     270          << " = " << getParams().getParameter(MpqcParser_Parameters::memoryParam) << endl;
     271      *file << "\t\treference<CLHF>: (" << endl;
     272      *file << "\t\t\t" << getParams().getParameterName(MpqcParser_Parameters::maxiterParam)
     273          << " = " << getParams().getParameter(MpqcParser_Parameters::maxiterParam)<< endl;
     274      *file << "\t\t\t" << getParams().getParameterName(MpqcParser_Parameters::basisParam) << " = $:basis" << endl;
     275      *file << "\t\t\tmolecule = $:molecule" << endl;
     276      *file << "\t\t\t" << getParams().getParameterName(MpqcParser_Parameters::memoryParam)
     277          << " = " << getParams().getParameter(MpqcParser_Parameters::memoryParam) << endl;
     278      *file << "\t\t)" << endl;
     279      *file << "\t)" << endl;
     280    } else if (theory == getParams().getTheoryName(MpqcParser_Parameters::MBPT2_R12)) {
     281      *file << "\tmole<" << getParams().getParameter(MpqcParser_Parameters::theoryParam) << ">: (" << endl;
     282      *file << "\t\tmolecule = $:molecule" << endl;
     283      *file << "\t\t" << getParams().getParameterName(MpqcParser_Parameters::basisParam) << " = $:basis" << endl;
     284      *file << "\t\t" << getParams().getParameterName(MpqcParser_Parameters::aux_basisParam) << " = $:abasis" << endl;
     285      *file << "\t\t" << getParams().getParameterName(MpqcParser_Parameters::stdapproxParam)
     286          << " = \"" << getParams().getParameter(MpqcParser_Parameters::stdapproxParam) << "\"" << endl;
     287      *file << "\t\t" << getParams().getParameterName(MpqcParser_Parameters::nfzcParam)
     288          << " = " << getParams().getParameter(MpqcParser_Parameters::nfzcParam) << endl;
     289      *file << "\t\t" << getParams().getParameterName(MpqcParser_Parameters::memoryParam)
     290          << " = " << getParams().getParameter(MpqcParser_Parameters::memoryParam) << endl;
     291      *file << "\t\tintegrals<IntegralCints>:()" << endl;
     292      *file << "\t\treference<CLHF>: (" << endl;
     293      *file << "\t\t\tmolecule = $:molecule" << endl;
     294      *file << "\t\t\t" << getParams().getParameterName(MpqcParser_Parameters::basisParam) << " = $:basis" << endl;
     295      *file << "\t\t\tmaxiter = " << getParams().getParameter(MpqcParser_Parameters::maxiterParam) << endl;
     296      *file << "\t\t\tmemory = " << getParams().getParameter(MpqcParser_Parameters::memoryParam) << endl;
     297      *file << "\t\t\tintegrals<" << getParams().getParameter(MpqcParser_Parameters::integrationParam) << ">:()" << endl;
     298      *file << "\t\t)" << endl;
     299      *file << "\t)" << endl;
     300    } else {
     301      DoeLog(0) && (eLog() << Verbose(0)
     302          << "Unknown level of theory requested for MPQC output file." << std::endl);
    294303    }
    295304    *file << ")" << endl;
     
    304313    *file << ")" << endl;
    305314    *file << "basis<GaussianBasisSet>: (" << endl;
    306     *file << "\tname = \"" << getParams().getString(MpqcParser_Parameters::basisParam) << "\"" << endl;
     315    *file << "\tname = \"" << getParams().getParameter(MpqcParser_Parameters::basisParam) << "\"" << endl;
    307316    *file << "\tmolecule = $:molecule" << endl;
    308317    *file << ")" << endl;
    309     if (getParams().getTheory() == MpqcParser_Parameters::MBPT2_R12) {
     318    if (theory == getParams().getTheoryName(MpqcParser_Parameters::MBPT2_R12)) {
    310319      *file << "% auxiliary basis set specification" << endl;
    311320      *file << "\tabasis<GaussianBasisSet>: (" << endl;
    312       *file << "\tname = \"" << getParams().getString(MpqcParser_Parameters::aux_basisParam) << "\"" << endl;
     321      *file << "\tname = \"" << getParams().getParameter(MpqcParser_Parameters::aux_basisParam) << "\"" << endl;
    313322      *file << "\tmolecule = $:molecule" << endl;
    314323      *file << ")" << endl;
  • src/Parser/MpqcParser.hpp

    rfa9d1d r360c8b  
    1414#endif
    1515
     16#include "CodePatterns/toString.hpp"
    1617
    1718#include "FormatParser.hpp"
     19#include "FormatParserTrait.hpp"
     20#include "FormatParserInterface.hpp"
     21#include "FormatParser_common.hpp"
     22#include "ParserTypes.hpp"
     23
    1824#include "MpqcParser_Parameters.hpp"
    1925
    2026#include <iosfwd>
    2127
     28// declaration of specialized FormatParserTrait
     29template<>
     30struct FormatParserTrait<mpqc>
     31{
     32  //!> Name of the parser
     33  static const std::string name;
     34  //!> suffix of the files the parser understands to read and write
     35  static const std::string suffix;
     36  //!> ParserTypes enumeration for the parser
     37  static const enum ParserTypes type;
     38};
     39
    2240/**
    2341 * Loads a MPQC config file into the World and saves the World as a tremolo file.
    2442 */
    25 class MpqcParser : public FormatParser
     43template <>
     44class FormatParser< mpqc >  : virtual public FormatParserInterface, public FormatParser_common
    2645{
    2746  friend class ParserMpqcUnitTest;
    2847public:
     48  FormatParser();
     49  virtual ~FormatParser();
    2950
    30   MpqcParser();
    31   virtual ~MpqcParser();
    32   void load(std::istream* file);
    33   void save(std::ostream* file, const std::vector<atom *> &atoms);
     51  void load(std::istream *file);
     52  void save(std::ostream *file, const std::vector<atom *> &atoms);
    3453
    3554  /** Getter for parameter set.
     
    3857   */
    3958  MpqcParser_Parameters & getParams() { return *static_cast<MpqcParser_Parameters *>(parameters); }
     59
     60private:
     61  static ConvertTo<bool> Converter;
    4062};
    4163
  • src/Parser/MpqcParser_Parameters.cpp

    rfa9d1d r360c8b  
    1818#endif
    1919
    20 #include <iostream>
    21 #include <boost/tokenizer.hpp>
     20#include "CodePatterns/MemDebug.hpp"
     21
    2222#include <string>
    2323
    24 #include "CodePatterns/MemDebug.hpp"
    25 
    2624#include "CodePatterns/Log.hpp"
    27 #include "CodePatterns/Verbose.hpp"
    2825
    2926#include "MpqcParser.hpp"
    30 
    3127#include "MpqcParser_Parameters.hpp"
    3228
     29#include "Parser/Parameters/ContinuousParameter.hpp"
     30#include "Parser/Parameters/DiscreteParameter.hpp"
     31#include "Parser/Parameters/StringParameter.hpp"
    3332
    34 using boost::any_cast;
     33template <>
     34const std::string ContinuousValue<bool>::get() const
     35{
     36  ASSERT(ValueSet,
     37      "ContinuousValue<bool>::get() - requesting unset value.");
     38  if (value)
     39    return std::string("yes");
     40  else
     41    return std::string("no");
     42}
     43
     44template <>
     45void ContinuousValue<bool>::set(const std::string _value)
     46{
     47  if (_value == std::string("yes")) {
     48    setValue(true);
     49  } else if (_value == std::string("no")) {
     50    setValue(false);
     51  } else {
     52    ASSERT(0,
     53        "void ContinuousValue<bool>::set() - value "+_value+" is neither yes or no.");
     54  }
     55}
     56
    3557
    3658MpqcParser_Parameters::MpqcParser_Parameters()
     
    4466  initBasis();
    4567
    46   // add all theory names
    47   TheoryNames[CLHF]="CLHF";
    48   TheoryNames[CLKS]="CLKS";
    49   TheoryNames[MBPT2]="MBPT2";
    50   TheoryNames[MBPT2_R12]="MBPT2_R12";
    51 
     68  // add all parameter names
    5269  {
    53     // TODO: throw exception instead of eLog()
    54     std::pair<TheoryLookupType::iterator, bool> inserter;
    55     for (TheoryNamesType::iterator iter = TheoryNames.begin();
    56         iter != TheoryNames.end();
    57         ++iter) {
    58       inserter = TheoryLookup.insert( make_pair(iter->second, iter->first) );
    59       if (!inserter.second)
    60         DoeLog(0) && (eLog() << Verbose(0)
    61             << "MpqcParser_Parameters::MpqcParser_Parameters() - Theory name already present: "
    62             << (inserter.first)->second << " and " << iter->first << "!"
    63             << std::endl);
    64     }
     70    ParamNames.clear();
     71    ParamNames.resize(unknownParam);
     72    ParamNames[hessianParam] = "Hessian";
     73    ParamNames[savestateParam] = "savestate";
     74    ParamNames[do_gradientParam] = "do_gradient";
     75    ParamNames[maxiterParam] = "maxiter";
     76    ParamNames[memoryParam] = "memory";
     77    ParamNames[stdapproxParam] = "stdapprox";
     78    ParamNames[nfzcParam] = "nfzc";
     79    ParamNames[basisParam] = "basis";
     80    ParamNames[aux_basisParam] = "aux_basis";
     81    ParamNames[integrationParam] = "integration";
     82    ParamNames[theoryParam] = "theory";
    6583  }
    6684
    67   // add all integration names
    68   IntegrationNames[IntegralCints] = "IntegralCints";
     85  // create theory parameter
    6986  {
    70     // TODO: throw exception instead of eLog()
    71     std::pair<IntegrationLookupType::iterator, bool> inserter;
    72     for (IntegrationNamesType::iterator iter = IntegrationNames.begin();
    73         iter != IntegrationNames.end();
    74         ++iter) {
    75       inserter = IntegrationLookup.insert( make_pair(iter->second, iter->first) );
    76       if (!inserter.second)
    77         DoeLog(0) && (eLog() << Verbose(0)
    78             << "MpqcParser_Parameters::MpqcParser_Parameters() - Integration name already present: "
    79             << (inserter.first)->second << " and " << iter->first << "!"
    80             << std::endl);
    81     }
     87    ValidTheories.clear();
     88    ValidTheories.resize(unknownTheory);
     89    ValidTheories[CLHF]="CLHF";
     90    ValidTheories[CLKS]="CLKS";
     91    ValidTheories[MBPT2]="MBPT2";
     92    ValidTheories[MBPT2_R12]="MBPT2_R12";
     93    appendParameter(
     94        new DiscreteParameter<std::string>(
     95            ParamNames[theoryParam],
     96            ValidTheories,
     97            ValidTheories[MBPT2]));
     98  }
     99  //InvertMap<TheoryNamesType,TheoryLookupType>(TheoryNames,TheoryLookup);
     100
     101  // create integration parameter
     102  {
     103    ValidIntegrationMethods.clear();
     104    ValidIntegrationMethods.resize(unknownIntegration);
     105    ValidIntegrationMethods[IntegralCints] = "IntegralCints";
     106    appendParameter(
     107        new DiscreteParameter<std::string>(
     108            ParamNames[integrationParam],
     109            ValidIntegrationMethods,
     110            ValidIntegrationMethods[IntegralCints]));
    82111  }
    83112
    84   // have names for all parmaters
    85   ParamNames[hessianParam] = "Hessian";
    86   ParamNames[savestateParam] = "savestate";
    87   ParamNames[do_gradientParam] = "do_gradient";
    88   ParamNames[maxiterParam] = "maxiter";
    89   ParamNames[memoryParam] = "memory";
    90   ParamNames[stdapproxParam] = "stdapprox";
    91   ParamNames[nfzcParam] = "nfzc";
    92   ParamNames[basisParam] = "basis";
    93   ParamNames[aux_basisParam] = "aux_basis";
    94   ParamNames[integrationParam] = "integration";
    95   ParamNames[theoryParam] = "theory";
    96 
     113  // add all continuous parameters
    97114  {
    98     // TODO: throw exception instead of eLog()
    99     std::pair<ParamLookupType::iterator, bool> inserter;
    100     for (ParamNamesType::iterator iter = ParamNames.begin();
    101         iter != ParamNames.end();
    102         ++iter) {
    103       inserter = ParamLookup.insert( make_pair(iter->second, iter->first) );
    104       if (!inserter.second)
    105         DoeLog(0) && (eLog() << Verbose(0)
    106             << "MpqcParser_Parameters::MpqcParser_Parameters() - parameter name already present: "
    107             << (inserter.first)->second << " and " << iter->first << "!"
    108             << std::endl);
    109     }
     115    appendParameter(new ContinuousParameter<bool>(ParamNames[hessianParam], false));
     116    appendParameter(new ContinuousParameter<bool>(ParamNames[savestateParam], false));
     117    appendParameter(new ContinuousParameter<bool>(ParamNames[do_gradientParam], true));
     118    appendParameter(new ContinuousParameter<int>(ParamNames[maxiterParam], 1000));
     119    appendParameter(new ContinuousParameter<int>(ParamNames[memoryParam], 16000000));
     120    appendParameter(new StringParameter(ParamNames[stdapproxParam], "A'"));
     121    appendParameter(new ContinuousParameter<int>(ParamNames[nfzcParam], 1));
     122    appendParameter(new StringParameter(ParamNames[basisParam], "3-21G"));
     123    appendParameter(new StringParameter(ParamNames[aux_basisParam], "aug-cc-pVDZ"));
    110124  }
    111 
    112   initParameters();
    113 }
    114 
    115 MpqcParser_Parameters::MpqcParser_Parameters(const MpqcParser_Parameters & state)
    116 {
    117   // init
    118   Init();
    119 
    120   // copy values
    121   copyParameters(state);
    122 }
    123 
    124 void MpqcParser_Parameters::copyParameters(const MpqcParser_Parameters & state)
    125 {
    126   appendParameter(hessianParam, state.getBool(hessianParam));
    127   appendParameter(savestateParam, state.getBool(savestateParam));
    128   appendParameter(do_gradientParam, state.getBool(do_gradientParam));
    129   appendParameter(maxiterParam, state.getInt(maxiterParam));
    130   appendParameter(memoryParam, state.getInt(memoryParam));
    131   appendParameter(stdapproxParam, state.getString(stdapproxParam));
    132   appendParameter(nfzcParam, state.getInt(nfzcParam));
    133   appendParameter(basisParam, state.getString(basisParam));
    134   appendParameter(aux_basisParam, state.getString(aux_basisParam));
    135   appendParameter(integrationParam, state.getIntegration());
    136   appendParameter(theoryParam, state.getTheory());
    137 }
    138 
    139 FormatParser_Parameters* MpqcParser_Parameters::clone() const
    140 {
    141   //LOG(3, "Cloning parameters.");
    142   MpqcParser_Parameters *instance = new MpqcParser_Parameters(*this);
    143   return instance;
    144 }
    145 
    146 void MpqcParser_Parameters::makeClone(const FormatParser_Parameters & _state)
    147 {
    148   //LOG(3, "Cloning parameters from other instance.");
    149   copyParameters(static_cast<const MpqcParser_Parameters &>(_state));
    150 }
    151 
    152 void MpqcParser_Parameters::initParameters()
    153 {
    154         appendParameter(hessianParam, bool(false));
    155         appendParameter(savestateParam, bool(false));
    156         appendParameter(do_gradientParam, bool(true));
    157         appendParameter(maxiterParam, int(1000));
    158         appendParameter(memoryParam, int(16000000));
    159         appendParameter(stdapproxParam, std::string("A'"));
    160         appendParameter(nfzcParam, int(1));
    161         appendParameter(basisParam, std::string("3-21G"));
    162         appendParameter(aux_basisParam, std::string("aug-cc-pVDZ"));
    163         appendParameter(integrationParam, IntegralCints);
    164         appendParameter(theoryParam, MBPT2);
    165125}
    166126
     
    168128{}
    169129
    170 std::ostream & operator << (std::ostream& ost, MpqcParser_Parameters const &_mpqc_params)
     130/** Getter for a specific Parameter.
     131 *
     132 * @param param index among enum Parameters
     133 * @return value of the desired Parameters
     134 */
     135const std::string MpqcParser_Parameters::getParameter(const enum Parameters param) const
    171136{
    172   // this is ugly, but with boost::any to safeguard const-ness is plain impossible
    173   MpqcParser_Parameters &mpqc_params = const_cast<MpqcParser_Parameters &>(_mpqc_params);
    174   std::ostringstream output;
    175   output << "Hessian=" << mpqc_params.getBool(MpqcParser_Parameters::hessianParam) << ";";
    176   output << "savestate=" << mpqc_params.getBool(MpqcParser_Parameters::savestateParam) << ";";
    177   output << "do_gradient=" << mpqc_params.getBool(MpqcParser_Parameters::do_gradientParam) << ";";
    178   output << "maxiter=" << mpqc_params.getInt(MpqcParser_Parameters::maxiterParam) << ";";
    179   output << "memory=" << mpqc_params.getInt(MpqcParser_Parameters::memoryParam) << ";";
    180   output << "stdapprox=" << mpqc_params.getString(MpqcParser_Parameters::stdapproxParam) << ";";
    181   output << "nfzc=" << mpqc_params.getInt(MpqcParser_Parameters::nfzcParam) << ";";
    182   output << "basis=" << mpqc_params.getString(MpqcParser_Parameters::basisParam) << ";";
    183   output << "aux_basis=" << mpqc_params.getString(MpqcParser_Parameters::aux_basisParam) << ";";
    184   output << "integration=" << mpqc_params.getString(MpqcParser_Parameters::integrationParam) << ";";
    185   output << "theory=" << mpqc_params.getString(MpqcParser_Parameters::theoryParam) << ";";
    186   ost << output.str();
    187   return ost;
     137  return FormatParser_Parameters::getParameter(ParamNames[param])->get();
    188138}
    189139
    190 std::istream & operator >> (std::istream& ist, MpqcParser_Parameters &params)
     140/** Setter for a specific Parameter.
     141 *
     142 * @param param index among enum Parameters
     143 * @param _value value to set desired Parameter to
     144 */
     145void MpqcParser_Parameters::setParameter(const enum Parameters param, const std::string &_value)
    191146{
    192   typedef boost::tokenizer<boost::char_separator<char> >
    193       tokenizer;
    194   boost::char_separator<char> semicolonsep(";");
    195   boost::char_separator<char> equalitysep(" =");
    196   boost::char_separator<char> ticksep("\"");
    197   std::string line;
    198   std::getline( ist, line );
    199   //DoLog(0) && (Log() << Verbose(0) << "INFO: full line of parameters is '" << line << "'" << std::endl);
    200   tokenizer tokens(line, semicolonsep);
    201   ASSERT(tokens.begin() != tokens.end(),
    202       "operator<< on MpqcParser_Parameters - empty string, need at least ';' in line "+line+"!");
    203   for (tokenizer::iterator tok_iter = tokens.begin();
    204         tok_iter != tokens.end(); ++tok_iter) {
    205     tokenizer paramtokens(*tok_iter, equalitysep);
    206     if (paramtokens.begin() != paramtokens.end()) {
    207       tokenizer::iterator tok_paramiter = paramtokens.begin();
    208       tokenizer::iterator tok_valueiter = tok_paramiter;
    209       tokenizer::iterator tok_checkiter = ++tok_valueiter;
    210       ++tok_checkiter;
    211       // TODO: throw exception instead of ASSERT
    212       ASSERT(tok_paramiter != paramtokens.end(),
    213           "operator<< on MpqcParser_Parameters - missing value before ' =' in token "+*tok_iter+"!");
    214       ASSERT(tok_valueiter != paramtokens.end(),
    215           "operator<< on MpqcParser_Parameters - missing value after ' =' in token "+*tok_iter+"!");
    216       ASSERT(tok_checkiter == paramtokens.end(),
    217           "operator<< on MpqcParser_Parameters - still more tokens after ' =' in token "+*tok_iter+":"
    218           +*tok_checkiter+"!");
    219       std::stringstream keystream(*tok_paramiter);
    220       std::string key;
    221       keystream >> ws >> key;
    222       tokenizer ticklesstokens(*tok_valueiter, ticksep);
    223       ASSERT(ticklesstokens.begin() != ticklesstokens.end(),
    224           "operator<< on MpqcParser_Parameters - no tokens present after removing ticks in token "+*tok_valueiter+"!");
    225       std::stringstream valuestream(*(ticklesstokens.begin()));
    226       DoLog(2) && (Log() << Verbose(2)
    227           << "INFO: Token pair is " << key << "," << valuestream.str() << std::endl);
    228 
    229       // TODO: throw exception instead of DoeLog()
    230       ASSERT(params.haveParam(key),
    231           "operator >> on MpqcParser_Parameters - unknown parameter name '"
    232           +key+"' with value "+valuestream.str()+"!");
    233       if (params.haveParam(key))
    234         params.setter(params.getParam(key), valuestream);
    235     } else {
    236       ist.setstate(std::ios::eofbit);
    237     }
    238   }
    239   return ist;
     147  const std::string &name = getParameterName(param);
     148  FormatParser_Parameters::getParameter(name)->set(_value);
    240149}
    241150
    242 
    243 /** Sets a desired value in the params from a string.
     151/** Getter for name of a specific Parameter.
    244152 *
    245  * This is due to strict typing of C++ very ugly and boost::any does not make
    246  * it any better because it offers to functions to use values directly from
    247  * stringstream. Probably, because value is unknown to is as well and hence
    248  * the author could not implement it beautifully, so he dropped it altogether.
    249  * Grrr ....
    250  *
    251  * @param _param param to set
    252  * @param _desired stringstream containing value as next argument
    253  * @return true - type ok, false - unknown type in params.
     153 * @param param index among enum Parameters
     154 * @return name of the desired Parameter
    254155 */
    255 bool MpqcParser_Parameters::setter(enum Parameters _param, std::stringstream& _desired) {
    256   if (_param == integrationParam) {
    257      std::string tmp;
    258     _desired >> tmp;
    259     params[_param] = IntegrationLookup[tmp];
    260   } else if(_param == theoryParam) {
    261     std::string tmp;
    262     _desired >> tmp;
    263     params[_param] = TheoryLookup[tmp];
    264   } else if (params[_param].type() == typeid(std::string)) {
    265     std::string tmp;
    266     _desired >> tmp;
    267     params[_param] = tmp;
    268   } else if (params[_param].type() ==  typeid(int)) {
    269     int tmp;
    270     _desired >> tmp;
    271     params[_param] = tmp;
    272   } else if (params[_param].type() == typeid(double)) {
    273     double tmp;
    274     _desired >> tmp;
    275     params[_param] = tmp;
    276   } else if (params[_param].type() == typeid(bool)) {
    277     std::string tmp;
    278     _desired >> tmp;
    279     if ((tmp == "yes") || (tmp == "1")) {
    280       params[_param] = bool(true);
    281     } else if ((tmp == "no") || (tmp == "0")) {
    282       params[_param] = bool(false);
    283     } else {
    284       DoeLog(0) && (eLog() << Verbose(0)
    285           << "MpqcParser_Parameters::setter() - unknown boolean key "
    286           << tmp << "!" << std::endl);
    287     }
    288   } else {
    289     DoeLog(0) && (eLog() << Verbose(0)
    290         << "MpqcParser_Parameters::setter() - unknown type!" << std::endl);
    291     return false;
    292   }
    293   return true;
     156const std::string &MpqcParser_Parameters::getParameterName(const enum Parameters param) const
     157{
     158  return ParamNames[param];
    294159}
    295160
    296 
    297 void MpqcParser_Parameters::setTheory(enum Theory _theory)
     161/** Getter for name of a specific Parameter.
     162 *
     163 * @param param index among enum Theory
     164 * @return name of the desired Theory
     165 */
     166const std::string &MpqcParser_Parameters::getTheoryName(const enum Theory theory) const
    298167{
    299   // TODO: throw exception instead of eLog()
    300 //  try {
    301     params[theoryParam] = _theory;
    302 //  } catch(const boost::bad_any_cast &) {
    303 //    DoeLog(0) && (eLog() << Verbose(0)
    304 //        << "MpqcParser_Parameters::setTheory() - could not set boolean!" << std::endl);
    305 //  }
     168  return ValidTheories[theory];
    306169}
    307170
    308 void MpqcParser_Parameters::setIntegration(enum MpqcParser_Parameters::IntegrationMethod _integration){
    309   // TODO: throw exception instead of eLog()
    310 //  try {
    311     params[integrationParam] = _integration;
    312 //  } catch(const boost::bad_any_cast &) {
    313 //    DoeLog(0) && (eLog() << Verbose(0)
    314 //        << "MpqcParser_Parameters::setIntegration() - could not set boolean!" << std::endl);
    315 //  }
     171/** Getter for the name of specific of IntegrationMethod.
     172 *
     173 * @param param index among enum IntegrationMethod
     174 * @return value of the desired IntegrationMethod
     175 */
     176const std::string &MpqcParser_Parameters::getIntegrationMethodName(const enum IntegrationMethod integration) const
     177{
     178  return ValidIntegrationMethods[integration];
    316179}
    317 
    318 bool MpqcParser_Parameters::haveParam(std::string _name) const
    319 {
    320   return ParamLookup.count(_name) != 0;
    321 }
    322 
    323 enum MpqcParser_Parameters::Parameters MpqcParser_Parameters::getParam(std::string _name) const
    324 {
    325   ParamLookupType::const_iterator iter = ParamLookup.find(_name);
    326   return iter->second;
    327 }
    328 
    329 enum MpqcParser_Parameters::IntegrationMethod MpqcParser_Parameters::getIntegration() const
    330 {
    331   parameterlist::const_iterator iter = params.find(integrationParam);
    332   enum IntegrationMethod value;
    333   // TODO: throw exception instead of eLog()
    334 //  try {
    335     value = boost::any_cast<enum IntegrationMethod>(iter->second);
    336 //  } catch(const boost::bad_any_cast &) {
    337 //    DoeLog(0) && (eLog() << Verbose(0)
    338 //        << "MpqcParser_Parameters::getIntegration() - could not convert "
    339 //        +ParamNames[integrationParam]+" to enum IntegrationMethod!" << std::endl);
    340 //  }
    341   return value;
    342 }
    343 
    344 enum MpqcParser_Parameters::Theory MpqcParser_Parameters::getTheory() const
    345 {
    346   parameterlist::const_iterator iter = params.find(theoryParam);
    347   enum Theory value;
    348   // TODO: throw exception instead of eLog()
    349 //  try {
    350     value = boost::any_cast<enum Theory>(iter->second);
    351 //  } catch(const boost::bad_any_cast &) {
    352 //    DoeLog(0) && (eLog() << Verbose(0)
    353 //        << "MpqcParser_Parameters::getTheory() - could not convert "
    354 //        +ParamNames[theoryParam]+" to enum Theory!" << std::endl);
    355 //  }
    356   return value;
    357 }
    358 
    359 std::string MpqcParser_Parameters::getString(enum Parameters _param) const
    360 {
    361   std::string value;
    362   enum IntegrationMethod Iindex;
    363   enum Theory Tindex;
    364   bool test;
    365   parameterlist::const_iterator iter = params.find(_param);
    366   switch (_param) {
    367     case hessianParam:
    368     case savestateParam:
    369     case do_gradientParam:
    370       test = boost::any_cast<bool>(iter->second);
    371       if (test)
    372         value = "yes";
    373       else
    374         value = "no";
    375       break;
    376     case integrationParam:
    377       // TODO: throw exception instead of eLog()
    378 //      try {
    379         Iindex = boost::any_cast<enum IntegrationMethod>(iter->second);
    380 //      } catch(const boost::bad_any_cast &) {
    381 //        DoeLog(0) && (eLog() << Verbose(0)
    382 //            << "MpqcParser_Parameters::getString() - could not convert "
    383 //            +ParamNames[_param]+" to string!" << std::endl);
    384 //      }
    385       {
    386         IntegrationNamesType::const_iterator Iiter = IntegrationNames.find(Iindex);
    387         value = Iiter->second;
    388       }
    389       break;
    390     case theoryParam:
    391       // TODO: throw exception instead of eLog()
    392 //      try {
    393         Tindex = boost::any_cast<enum Theory>(iter->second);
    394 //      } catch(const boost::bad_any_cast &) {
    395 //        DoeLog(0) && (eLog() << Verbose(0)
    396 //            << "MpqcParser_Parameters::getString() - could not convert "
    397 //            +ParamNames[_param]+" to string!" << std::endl);
    398 //      }
    399         {
    400           TheoryNamesType::const_iterator Titer = TheoryNames.find(Tindex);
    401           value = Titer->second;
    402         }
    403       break;
    404     default:
    405       // TODO: throw exception instead of eLog()
    406 //      try {
    407         value = boost::any_cast<std::string>(iter->second);
    408 //      } catch(const boost::bad_any_cast &) {
    409 //        DoeLog(0) && (eLog() << Verbose(0)
    410 //            << "MpqcParser_Parameters::getString() - could not convert "
    411 //            +ParamNames[_param]+" to string!" << std::endl);
    412 //      }
    413       break;
    414   }
    415 
    416   return value;
    417 }
    418 
    419 int MpqcParser_Parameters::getInt(enum Parameters _param) const
    420 {
    421   int value;
    422   parameterlist::const_iterator iter = params.find(_param);
    423   switch (_param) {
    424     default:
    425       // TODO: throw exception instead of eLog()
    426 //      try {
    427         value = boost::any_cast<int>(iter->second);
    428 //      } catch(const boost::bad_any_cast &) {
    429 //        DoeLog(0) && (eLog() << Verbose(0)
    430 //            << "MpqcParser_Parameters::getInt() - could not convert "
    431 //            +ParamNames[_param]+" to int!" << std::endl);
    432 //      }
    433       break;
    434   }
    435   return value;
    436 }
    437 
    438 double MpqcParser_Parameters::getDouble(enum Parameters _param) const
    439 {
    440   double value;
    441   parameterlist::const_iterator iter = params.find(_param);
    442   // TODO: throw exception instead of eLog()
    443 //  try {
    444     value = boost::any_cast<double>(iter->second);
    445 //  } catch(const boost::bad_any_cast &) {
    446 //    DoeLog(0) && (eLog() << Verbose(0)
    447 //        << "MpqcParser_Parameters::getDouble() - could not convert "
    448 //        +ParamNames[_param]+" to double!" << std::endl);
    449 //  }
    450   return value;
    451 }
    452 
    453 bool MpqcParser_Parameters::getBool(enum Parameters _param) const
    454 {
    455   bool value;
    456   parameterlist::const_iterator iter = params.find(_param);
    457   // TODO: throw exception instead of eLog()
    458 //  try {
    459     value = boost::any_cast<bool>(iter->second);
    460 //  } catch(const boost::bad_any_cast &) {
    461 //    DoeLog(0) && (eLog() << Verbose(0)
    462 //        << "MpqcParser_Parameters::getBool() - could not convert "
    463 //        +ParamNames[_param]+" to bool!" << std::endl);
    464 //  }
    465   return value;
    466 }
    467 
    468180
    469181/** Checks whether all elements in the world also have parameters in the basis.
  • src/Parser/MpqcParser_Parameters.hpp

    rfa9d1d r360c8b  
    1414#endif
    1515
    16 #include <iosfwd>
    1716#include <list>
    18 #include <typeinfo>
     17#include <map>
    1918#include <vector>
    2019
    2120#include "CodePatterns/Clone.hpp"
    2221#include "CodePatterns/Log.hpp"
    23 #include "CodePatterns/Verbose.hpp"
    24 
    25 #include <boost/any.hpp>
    2622
    2723#include "Parser/FormatParser_Parameters.hpp"
     24
     25#include "Parser/Parameters/ContinuousParameter.hpp"
     26
     27// specialization for bool (we want "yes/no" not "1/0")
     28template <> const std::string ContinuousValue<bool>::get() const;
     29template <> void ContinuousValue<bool>::set(const std::string _value);
    2830
    2931class MpqcParser;
     
    4244  MpqcParser_Parameters();
    4345
    44   /** Copy Constructor of MpqcParser_Parameters.
    45    *
    46    * @param state ref to instance to copy
    47    */
    48   MpqcParser_Parameters(const MpqcParser_Parameters & state);
    49 
    5046  /** Destructor of MpqcParser_Parameters.
    5147   *
    5248   */
    5349  virtual ~MpqcParser_Parameters();
     50
     51  /** Enumeration of all known Parameters to allow placing them in vectors, maps.
     52   *
     53   */
     54  enum Parameters {
     55    hessianParam,    //!< HessianParam, whether hessian should be calculated or not
     56    savestateParam,  //!< savestateParam, whether intermediate/final states (wave function) should be stored
     57    do_gradientParam,//!< do_gradientParam, whether a gradient should be calculated
     58    maxiterParam,    //!< maxiterParam, number of maximum iterations for CG
     59    memoryParam,     //!< memoryParam, maximum amount of memory to use
     60    stdapproxParam,  //!< stdapproxParam, standard approximation in MBPT2 R12
     61    nfzcParam,       //!< nfzcParam, nfzc parameter in MBPT2 R12
     62    basisParam,      //!< basisParam, basis set to use
     63    aux_basisParam,  //!< aux_basisParam, auxiliary baseis set to use in MBPT2 R12
     64    integrationParam,//!< integrationParam, integration method to use in MBPT2 R12
     65    theoryParam,     //!< theoryParam, level of theory to use
     66    unknownParam};   //!< unknownParam, designates an unknown parameter
    5467
    5568  /** Enumeration of all known theories.
     
    7285  };
    7386
    74   /** Enumeration of all known Parameters to allow placing them in vectors, maps.
    75    *
    76    */
    77   enum Parameters {
    78     hessianParam,    //!< HessianParam, whether hessian should be calculated or not
    79     savestateParam,  //!< savestateParam, whether intermediate/final states (wave function) should be stored
    80     do_gradientParam,//!< do_gradientParam, whether a gradient should be calculated
    81     maxiterParam,    //!< maxiterParam, number of maximum iterations for CG
    82     memoryParam,     //!< memoryParam, maximum amount of memory to use
    83     stdapproxParam,  //!< stdapproxParam, standard approximation in MBPT2 R12
    84     nfzcParam,       //!< nfzcParam, nfzc parameter in MBPT2 R12
    85     basisParam,      //!< basisParam, basis set to use
    86     aux_basisParam,  //!< aux_basisParam, auxiliary baseis set to use in MBPT2 R12
    87     integrationParam,//!< integrationParam, integration method to use in MBPT2 R12
    88     theoryParam,     //!< theoryParam, level of theory to use
    89     unknownParam};   //!< unknownParam, designates an unknown parameter
     87  // enum to string getters
     88  const std::string getParameter(const enum Parameters param) const;
     89  void setParameter(const enum Parameters param, const std::string &);
     90  const std::string &getParameterName(const enum Parameters param) const;
     91  const std::string &getTheoryName(const enum Theory theory) const;
     92  const std::string &getIntegrationMethodName(const enum IntegrationMethod integration) const;
     93
     94private:
     95
     96
     97  //!> vector with all available theories in same order as enum Theory.
     98  std::vector<std::string> ValidTheories;
     99
     100  //!> vector with all available integration methods in same order as enum IntegrationMethod.
     101  std::vector<std::string> ValidIntegrationMethods;
    90102
    91103  bool checkWorldElementsAgainstCurrentBasis() const;
    92104
    93   /** Sets the desired level of solving theory to use.
    94    *
    95    * \param _theory shorthand of the theory
    96    */
    97   void setTheory(enum Theory _theory);
    98 
    99   /** Sets the desired level of solving integration to use.
    100    *
    101    * \param _integration shorthand of the integration
    102    */
    103   void setIntegration(enum IntegrationMethod _integration);
    104 
    105   /** Getter for integration method in params.
    106    *
    107    * @return enumeration index of IntegrationMethod.
    108    */
    109   enum IntegrationMethod getIntegration() const;
    110 
    111   /** Getter for current Theory in params.
    112    *
    113    * @return enumeration index of Theory
    114    */
    115   enum Theory getTheory() const;
    116 
    117   /** Getter for a parameter in params as a string.
    118    *
    119    * @param _param enumeration index of desired Parameter
    120    * @return string value
    121    */
    122   std::string getString(enum Parameters _param) const;
    123 
    124   /** Getter for integer value of desired Parameter in params.
    125    *
    126    * Only if type in params matches int!
    127    *
    128    * @param _param enumeration index in Parameter
    129    * @return integer value of parameter
    130    */
    131   int getInt(enum Parameters _param) const;
    132 
    133   /** Getter for double value of desired Parameter in params.
    134    *
    135    * Only if type in params matches double!
    136    *
    137    * @param _param enumeration index in Parameter
    138    * @return double value of parameter
    139    */
    140   double getDouble(enum Parameters _param) const;
    141 
    142   /** Getter for bool value of desired Parameter in params.
    143    *
    144    * Only if type in params matches bool!
    145    *
    146    * @param _param enumeration index in Parameter
    147    * @return bool value of parameter
    148    */
    149   bool getBool(enum Parameters _param) const;
    150 
    151   /** Setter for a desired value of its type is known.
    152    *
    153    * We check whether given type matches present type in params.
    154    *
    155    * @param _param enumeration index of Parameter
    156    * @param _desired desired value to set to
    157    * @return true - type match, value set, false - type mismatch
    158    */
    159   template <class T> bool setter(enum Parameters _param, T _desired) {
    160     if (typeid(T) == params[_param].type()) {
    161       params[_param] = _desired;
    162       return true;
    163     } else
    164       return false;
    165   }
    166 
    167   /** Sets a desired value in the params from a string.
    168    *
    169    * This is due to strict typing of C++ very ugly and boost::any does not make
    170    * it any better because it offers to functions to use values directly from
    171    * stringstream. Probably, because value is unknown to is as well and hence
    172    * the author could not implement it beautifully, so he dropped it altogether.
    173    * Grrr ....
    174    *
    175    * @param _param param to set
    176    * @param _desired stringstream containing value as next argument
    177    * @return true - type ok, false - unknown type in params.
    178    */
    179   bool setter(enum Parameters _param, std::stringstream& _desired);
    180 
    181   /** Grants access to ParamLookup.
    182    *
    183    *  Does not check for unknown parameter.
    184    *
    185    * @param _name name of parameter
    186    * @return enumeration index of Parameters
    187    */
    188   enum Parameters getParam(std::string _name) const;
    189 
    190   /** Checker whether parameter with name is known.
    191    *
    192    * @param _name
    193    * @return true - parameter known, false - parameter unknown
    194    */
    195   bool haveParam(std::string _name) const;
    196 
    197   /** Creates a clone of the class.
    198    *
    199    * @return
    200    */
    201   FormatParser_Parameters* clone() const;
    202 
    203   /** Applies a before returned undo state.
    204    *
    205    * @param undo state to set
    206    */
    207   void makeClone(const FormatParser_Parameters & _state);
    208 
    209   /** Set the internal parameters to the one's from the given \a state.
    210    *
    211    * @param state set of parameters
    212    */
    213   void copyParameters(const MpqcParser_Parameters & state);
    214 
    215 private:
    216105  /** Global initialization in cstor.
    217106   *
     
    224113  void initBasis();
    225114
    226   /** Initializes params.
    227    * Sets the type and the associated enumeration index.
    228    */
    229   void initParameters();
     115  //!> vector with all parameter names in same order as enum Parameters
     116  std::vector<std::string> ParamNames;
    230117
    231   /** Internal function used by initParameters() to add parameters to params.
    232    *
    233    * @param _enum enumeration index to set
    234    * @param _p (default) value to set with certain type
    235    */
    236   template <class T> void appendParameter(enum Parameters _enum, T _p) {
    237     boost::any _p_value = _p;
    238     params[_enum] = _p_value;
    239   }
     118  //!> typedef for the list of all available basis sets
     119  typedef std::map<std::string, std::list<std::string> > BasisMapType;
    240120
    241   // all internal typedefs for lists below
    242   typedef std::map<std::string, std::list<std::string> > BasisMapType;
    243   typedef std::map<enum Theory, std::string> TheoryNamesType;
    244   typedef std::map<std::string, enum Theory> TheoryLookupType;
    245   typedef std::map<enum IntegrationMethod, std::string> IntegrationNamesType;
    246   typedef std::map<std::string, enum IntegrationMethod> IntegrationLookupType;
    247   typedef std::map<enum Parameters, std::string> ParamNamesType;
    248   typedef std::map<std::string, enum Parameters> ParamLookupType;
    249   typedef std::map<enum Parameters, boost::any> parameterlist;
    250 
    251   //!> boost::any container for all the parameters
    252   parameterlist params;
    253 
    254   // maps from names to enumerations
    255 
    256   //!> contains basis and all elements the basis knows about
     121  //!> list of all basis along with their present element parametrization
    257122  BasisMapType BasisList;
    258   //!> contains the name of a theory as string
    259   TheoryNamesType TheoryNames;
    260   //!> contains a lookup from theory name to enumeration index
    261   TheoryLookupType TheoryLookup;
    262   //!> contains the name of an integration method as string
    263   IntegrationNamesType IntegrationNames;
    264   //!> contains a lookup from integration method name to enumeration index
    265   IntegrationLookupType IntegrationLookup;
    266   //!> contains the name of a parameter
    267   ParamNamesType ParamNames;
    268   //!> contains a lookup from parameter name to enumeration index
    269   ParamLookupType ParamLookup;
    270123};
    271124
    272 /** Output operator for the contents of MpqcParser_Parameters::params.
    273  *
    274  * @param ost output stream
    275  * @param params reference to MpqcParser_Parameters containing params.
    276  * @return reference to output stream for concatenation
    277  */
    278 std::ostream & operator << (std::ostream& ost, const MpqcParser_Parameters &params);
    279 
    280 /** Input operator for a list of parameters to place into \a params.
    281  *
    282  * @param ist input stream
    283  * @param params parameters to parse into
    284  * @return input stream for concatenation
    285  */
    286 std::istream & operator >> (std::istream& ist, MpqcParser_Parameters &params);
    287 
    288125#endif /* MPQCPARSER_PARAMETERS_HPP_ */
  • src/Parser/PcpParser.cpp

    rfa9d1d r360c8b  
    4040
    4141
    42 PcpParser::StructParallelization::StructParallelization() :
     42// declare specialized static variables
     43const std::string FormatParserTrait<pcp>::name = "pcp";
     44const std::string FormatParserTrait<pcp>::suffix = "conf";
     45const ParserTypes FormatParserTrait<pcp>::type = pcp;
     46
     47FormatParser< pcp >::StructParallelization::StructParallelization() :
    4348  ProcPEGamma(8),
    4449  ProcPEPsi(1)
    4550{}
    4651
    47 PcpParser::StructParallelization::~StructParallelization()
    48 {}
    49 
    50 PcpParser::StructPaths::StructPaths() :
     52FormatParser< pcp >::StructParallelization::~StructParallelization()
     53{}
     54
     55FormatParser< pcp >::StructPaths::StructPaths() :
    5156  databasepath(NULL),
    5257  configname(NULL),
     
    5661{}
    5762
    58 PcpParser::StructPaths::~StructPaths()
    59 {}
    60 
    61 PcpParser::StructSwitches::StructSwitches() :
     63FormatParser< pcp >::StructPaths::~StructPaths()
     64{}
     65
     66FormatParser< pcp >::StructSwitches::StructSwitches() :
    6267  DoConstrainedMD(0),
    6368  DoOutVis(0),
     
    7176{}
    7277
    73 PcpParser::StructSwitches::~StructSwitches()
    74 {}
    75 
    76 PcpParser::StructLocalizedOrbitals::StructLocalizedOrbitals() :
     78FormatParser< pcp >::StructSwitches::~StructSwitches()
     79{}
     80
     81FormatParser< pcp >::StructLocalizedOrbitals::StructLocalizedOrbitals() :
    7782  CommonWannier(0),
    7883  SawtoothStart(0.01),
     
    8489{}
    8590
    86 PcpParser::StructLocalizedOrbitals::~StructLocalizedOrbitals()
    87 {}
    88 
    89 PcpParser::StructStepCounts::StructStepCounts() :
     91FormatParser< pcp >::StructLocalizedOrbitals::~StructLocalizedOrbitals()
     92{}
     93
     94FormatParser< pcp >::StructStepCounts::StructStepCounts() :
    9095  MaxMinStopStep(1),
    9196  InitMaxMinStopStep(1),
     
    104109{}
    105110
    106 PcpParser::StructStepCounts::~StructStepCounts()
    107 {}
    108 
    109 PcpParser::StructPlaneWaveSpecifics::StructPlaneWaveSpecifics() :
     111FormatParser< pcp >::StructStepCounts::~StructStepCounts()
     112{}
     113
     114FormatParser< pcp >::StructPlaneWaveSpecifics::StructPlaneWaveSpecifics() :
    110115  PsiType(0),
    111116  MaxPsiDouble(0),
     
    123128{}
    124129
    125 PcpParser::StructPlaneWaveSpecifics::~StructPlaneWaveSpecifics()
     130FormatParser< pcp >::StructPlaneWaveSpecifics::~StructPlaneWaveSpecifics()
    126131{}
    127132
     
    129134 *
    130135 */
    131 PcpParser::PcpParser() :
     136FormatParser< pcp >::FormatParser() :
     137  FormatParser_common(NULL),
    132138  FastParsing(false),
    133139  Deltat(0.01),
     
    141147 *
    142148 */
    143 PcpParser::~PcpParser()
    144 {}
    145 
    146 void PcpParser::load(std::istream* file)
     149FormatParser< pcp >::~FormatParser()
     150{}
     151
     152void FormatParser< pcp >::load(std::istream* file)
    147153{
    148154  if (file->fail()) {
     
    380386 * \param atoms atoms to store
    381387 */
    382 void PcpParser::save(std::ostream* file, const std::vector<atom *> &atoms)
     388void FormatParser< pcp >::save(std::ostream* file, const std::vector<atom *> &atoms)
    383389{
    384390  DoLog(0) && (Log() << Verbose(0) << "Saving changes to pcp." << std::endl);
     
    414420    *file << "DoFullCurrent\t" << Switches.DoFullCurrent << "\t# Do full perturbation" << endl;
    415421    *file << "DoConstrainedMD\t" << Switches.DoConstrainedMD << "\t# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD" << endl;
    416     ASSERT(Thermostats != NULL, "PcpParser::save() - Thermostats not initialized!");
     422    ASSERT(Thermostats != NULL, "FormatParser< pcp >::save() - Thermostats not initialized!");
    417423    *file << "Thermostat\t" << Thermostats->activeThermostat->name() << "\t";
    418424    *file << Thermostats->activeThermostat->writeParams();
     
    487493 * \param &allatoms all atoms to store away
    488494 */
    489 void PcpParser::CalculateOrbitals(const std::vector<atom *> &allatoms)
     495void FormatParser< pcp >::CalculateOrbitals(const std::vector<atom *> &allatoms)
    490496{
    491497  PlaneWaveSpecifics.MaxPsiDouble = PlaneWaveSpecifics.PsiMaxNoDown = PlaneWaveSpecifics.PsiMaxNoUp = PlaneWaveSpecifics.PsiType = 0;
     
    520526 * \param &ZtoIndexMap map of which atoms belong to which ion number
    521527 */
    522 void PcpParser::OutputElements(ostream *file, const std::vector<atom *> &allatoms, map<int, int> &ZtoIndexMap)
     528void FormatParser< pcp >::OutputElements(ostream *file, const std::vector<atom *> &allatoms, map<int, int> &ZtoIndexMap)
    523529{
    524530  map<int, int> PresentElements;
     
    550556 * \param &ZtoIndexMap map of which atoms belong to which ion number
    551557 */
    552 void PcpParser::OutputAtoms(ostream *file, const std::vector<atom *> &allatoms, map<int, int> &ZtoIndexMap)
     558void FormatParser< pcp >::OutputAtoms(ostream *file, const std::vector<atom *> &allatoms, map<int, int> &ZtoIndexMap)
    553559{
    554560  *file << "#Ion_TypeNr._Nr.R[0]    R[1]    R[2]    MoveType (0 MoveIon, 1 FixedIon)" << endl;
     
    598604 * \param *fb file buffer containing the config file
    599605 */
    600 void PcpParser::ParseThermostats(class ConfigFileBuffer * const fb)
     606void FormatParser< pcp >::ParseThermostats(class ConfigFileBuffer * const fb)
    601607{
    602608  char * const thermo = new char[12];
     
    615621};
    616622
    617 bool PcpParser::operator==(const PcpParser& b) const
     623bool FormatParser< pcp >::operator==(const FormatParser< pcp >& b) const
    618624{
    619625  ASSERT(Parallelization.ProcPEGamma == b.Parallelization.ProcPEGamma, "PcpParser ==: ProcPEGamma not");
  • src/Parser/PcpParser.hpp

    rfa9d1d r360c8b  
    1414#endif
    1515
     16#include <iosfwd>
     17#include <map>
     18#include <string>
     19#include <vector>
    1620
    17 #include <iosfwd>
    18 #include "Parser/FormatParser.hpp"
     21#include "FormatParser.hpp"
     22#include "FormatParserTrait.hpp"
     23#include "FormatParserInterface.hpp"
     24#include "FormatParser_common.hpp"
     25#include "ParserTypes.hpp"
     26
     27class atom;
     28
     29// declaration of specialized FormatParserTrait
     30template<>
     31struct FormatParserTrait<pcp>
     32{
     33  //!> Name of the parser
     34  static const std::string name;
     35  //!> suffix of the files the parser understands to read and write
     36  static const std::string suffix;
     37  //!> ParserTypes enumeration for the parser
     38  static const enum ParserTypes type;
     39};
    1940
    2041/**
    2142 * Parser for PCP config files.
    2243 */
    23 class PcpParser : public FormatParser {
     44template <>
     45class FormatParser< pcp >  : virtual public FormatParserInterface, public FormatParser_common
     46{
    2447public:
    25   PcpParser();
    26   virtual ~PcpParser();
     48  FormatParser();
     49  virtual ~FormatParser();
    2750  void load(std::istream* file);
    2851  void save(std::ostream* file, const std::vector<atom *> &atoms);
    2952
    30   bool operator==(const PcpParser& b) const;
     53  bool operator==(const FormatParser< pcp >& b) const;
    3154
    3255private:
    3356
    3457  void ParseThermostats(class ConfigFileBuffer * const fb);
    35   void OutputAtoms(ostream *file, const std::vector<atom *> &allatoms, map<int, int> &ZtoIndexMap);
    36   void OutputElements(ostream *file, const std::vector<atom *> &allatoms, map<int, int> &ZtoIndexMap);
     58  void OutputAtoms(std::ostream *file, const std::vector<atom *> &allatoms, std::map<int, int> &ZtoIndexMap);
     59  void OutputElements(std::ostream *file, const std::vector<atom *> &allatoms, std::map<int, int> &ZtoIndexMap);
    3760  void CalculateOrbitals(const std::vector<atom *> &allatoms);
    3861
     
    154177  int StructOpt;
    155178  int MaxTypes;
    156   string basis;
     179  std::string basis;
    157180};
    158181
  • src/Parser/PdbAtomInfoContainer.hpp

    rfa9d1d r360c8b  
    1414#endif
    1515
     16#include <string>
     17#include <typeinfo>
    1618
     19#include "LinearAlgebra/Vector.hpp"
    1720#include "PdbKey.hpp"
    1821
    19 class PdbParser;
    20 class Vector;
     22#include "ParserTypes.hpp"
    2123
    22 #include <string>
    23 #include <typeinfo>
     24//template <class T> class FormatParser;
     25//template<> class FormatParser< pdb >;
    2426
    2527/**
     
    2729 */
    2830class PdbAtomInfoContainer {
    29   friend class PdbParser;
     31  //!> Grant all FormatParser specializations access, otherwise we have to fully define FormatParser<pdb>
     32  template<enum ParserTypes> friend class FormatParser;
    3033public:
    3134  PdbAtomInfoContainer();
  • src/Parser/PdbParser.cpp

    rfa9d1d r360c8b  
    4444using namespace std;
    4545
     46// declare specialized static variables
     47const std::string FormatParserTrait<pdb>::name = "pdb";
     48const std::string FormatParserTrait<pdb>::suffix = "pdb";
     49const ParserTypes FormatParserTrait<pdb>::type = pdb;
     50
    4651/**
    4752 * Constructor.
    4853 */
    49 PdbParser::PdbParser() {
     54FormatParser< pdb >::FormatParser() :
     55  FormatParser_common(NULL)
     56{
    5057  knownTokens["ATOM"] = PdbKey::Atom;
    5158  knownTokens["HETATM"] = PdbKey::Atom;
     
    6572 * Destructor.
    6673 */
    67 PdbParser::~PdbParser() {
     74FormatParser< pdb >::~FormatParser()
     75{
    6876  PdbAtomInfoContainer::clearknownDataKeys();
    6977  additionalAtomData.clear();
     
    7785 * @return token type
    7886 */
    79 enum PdbKey::KnownTokens PdbParser::getToken(string &line)
     87enum PdbKey::KnownTokens FormatParser< pdb >::getToken(string &line)
    8088{
    8189  // look for first space
     
    105113 * \param PDB file
    106114 */
    107 void PdbParser::load(istream* file) {
     115void FormatParser< pdb >::load(istream* file) {
    108116  string line;
    109117  size_t linecount  = 0;
     
    148156            // TODO: put a throw here
    149157            DoeLog(2) && (eLog() << Verbose(2) << "Unknown token: '" << line << "' for time step " << step << "." << std::endl);
    150             //ASSERT(0, "PdbParser::load() - Unknown token in line "+toString(linecount)+": "+line+".");
     158            //ASSERT(0, "FormatParser< pdb >::load() - Unknown token in line "+toString(linecount)+": "+line+".");
    151159            break;
    152160        }
     
    170178 * \param atoms atoms to store
    171179 */
    172 void PdbParser::save(ostream* file, const std::vector<atom *> &AtomList)
     180void FormatParser< pdb >::save(ostream* file, const std::vector<atom *> &AtomList)
    173181{
    174182  DoLog(0) && (Log() << Verbose(0) << "Saving changes to pdb." << std::endl);
     
    240248        } else {
    241249          ASSERT(MolIdMap.find(mol->getId()) != MolIdMap.end(),
    242               "PdbParser::save() - Mol id "+toString(mol->getId())+" not present despite we set it?!");
     250              "FormatParser< pdb >::save() - Mol id "+toString(mol->getId())+" not present despite we set it?!");
    243251          MolNo = MolIdMap[mol->getId()];
    244252          atomInfo.set(PdbKey::resSeq, toString(MolIdMap[mol->getId()]));
     
    289297 * @param id of atom
    290298 */
    291 void PdbParser::AtomInserted(atomId_t id)
    292 {
    293   //LOG(3, "PdbParser::AtomInserted() - notified of atom " << id << "'s insertion.");
     299void FormatParser< pdb >::AtomInserted(atomId_t id)
     300{
     301  //LOG(3, "FormatParser< pdb >::AtomInserted() - notified of atom " << id << "'s insertion.");
    294302  ASSERT(!isPresentadditionalAtomData(id),
    295       "PdbParser::AtomInserted() - additionalAtomData already present for newly added atom "
     303      "FormatParser< pdb >::AtomInserted() - additionalAtomData already present for newly added atom "
    296304      +toString(id)+".");
    297305  // don't insert here as this is our check whether we are in the first time step
     
    304312 * @param id of atom
    305313 */
    306 void PdbParser::AtomRemoved(atomId_t id)
    307 {
    308   //LOG(3, "PdbParser::AtomRemoved() - notified of atom " << id << "'s removal.");
     314void FormatParser< pdb >::AtomRemoved(atomId_t id)
     315{
     316  //LOG(3, "FormatParser< pdb >::AtomRemoved() - notified of atom " << id << "'s removal.");
    309317  std::map<size_t, PdbAtomInfoContainer>::iterator iter = additionalAtomData.find(id);
    310318  // as we do not insert AtomData on AtomInserted, we cannot be assured of its presence
    311319//  ASSERT(iter != additionalAtomData.end(),
    312 //      "PdbParser::AtomRemoved() - additionalAtomData is not present for atom "
     320//      "FormatParser< pdb >::AtomRemoved() - additionalAtomData is not present for atom "
    313321//      +toString(id)+" to remove.");
    314322  if (iter != additionalAtomData.end()) {
     
    325333 * @return true - entry present, false - only for atom's father or no entry
    326334 */
    327 bool PdbParser::isPresentadditionalAtomData(unsigned int _id)
     335bool FormatParser< pdb >::isPresentadditionalAtomData(unsigned int _id)
    328336{
    329337  return (additionalAtomData.find(_id) != additionalAtomData.end());
     
    336344 * @return
    337345 */
    338 PdbAtomInfoContainer& PdbParser::getadditionalAtomData(atom *_atom)
     346PdbAtomInfoContainer& FormatParser< pdb >::getadditionalAtomData(atom *_atom)
    339347{
    340348  if (additionalAtomData.find(_atom->getId()) != additionalAtomData.end()) {
     
    362370 * \param ResidueNo number of residue
    363371 */
    364 void PdbParser::saveLine(
     372void FormatParser< pdb >::saveLine(
    365373    ostream* file,
    366374    const PdbAtomInfoContainer &atomInfo)
     
    423431 * \param *currentAtom to the atom of which to take the neighbor information
    424432 */
    425 void PdbParser::writeNeighbors(ostream* file, int MaxnumberOfNeighbors, atom* currentAtom) {
     433void FormatParser< pdb >::writeNeighbors(ostream* file, int MaxnumberOfNeighbors, atom* currentAtom) {
    426434  int MaxNo = MaxnumberOfNeighbors;
    427435  int charsleft = 80;
     
    452460}
    453461
    454 /** Retrieves a value from PdbParser::atomIdMap.
     462/** Retrieves a value from  FormatParser< pdb >::atomIdMap.
    455463 * \param atomid key
    456464 * \return value
    457465 */
    458 size_t PdbParser::getSerial(const size_t atomid) const
    459 {
    460   ASSERT(atomIdMap.find(atomid) != atomIdMap.end(),
    461       "PdbParser::getSerial() - atomid "+toString(atomid)+" not present in Map.");
     466size_t FormatParser< pdb >::getSerial(const size_t atomid) const
     467{
     468  ASSERT(atomIdMap.find(atomid) != atomIdMap.end(), 
     469      "FormatParser< pdb >::getAtomId: atomid "+toString(atomid)+" not present in Map.");
    462470  return (atomIdMap.find(atomid)->second);
    463471}
    464472
    465 /** Sets an entry in PdbParser::atomIdMap.
     473/** Sets an entry in  FormatParser< pdb >::atomIdMap.
    466474 * \param localatomid key
    467475 * \param atomid value
    468476 * \return true - key not present, false - value present
    469477 */
    470 void PdbParser::setSerial(const size_t localatomid, const size_t atomid)
     478void FormatParser< pdb >::setSerial(const size_t localatomid, const size_t atomid)
    471479{
    472480  pair<std::map<size_t,size_t>::iterator, bool > inserter;
    473 //  DoLog(1) && (Log() << Verbose(1) << "PdbParser::setAtomId() - Inserting ("
     481//  DoLog(1) && (Log() << Verbose(1) << "FormatParser< pdb >::setAtomId() - Inserting ("
    474482//      << localatomid << " -> " << atomid << ")." << std::endl);
    475483  inserter = atomIdMap.insert( make_pair(localatomid, atomid) );
    476   ASSERT(inserter.second, "PdbParser::setAtomId: atomId already present in Map.");
     484  ASSERT(inserter.second, "FormatParser< pdb >::setAtomId: atomId already present in Map.");
    477485}
    478486
     
    482490 * @return
    483491 */
    484 atom* PdbParser::getAtomToParse(std::string id_string) const
     492atom* FormatParser< pdb >::getAtomToParse(std::string id_string) const
    485493{
    486494  // get the local ID
     
    517525 * @param line line containing key ATOM
    518526 */
    519 void PdbParser::readPdbAtomInfoContainer(PdbAtomInfoContainer &atomInfo, std::string &line) const
     527void FormatParser< pdb >::readPdbAtomInfoContainer(PdbAtomInfoContainer &atomInfo, std::string &line) const
    520528{
    521529  const size_t length = line.length();
    522530  if (length < 80)
    523     ELOG(2, "PdbParser::readPdbAtomInfoContainer() - pdb is mal-formed, containing less than 80 chars!");
     531    ELOG(2, "FormatParser< pdb >::readPdbAtomInfoContainer() - pdb is mal-formed, containing less than 80 chars!");
    524532  if (length >= 6) {
    525533    LOG(4,"INFO: Parsing token from "+line.substr(0,6)+".");
     
    530538    atomInfo.set(PdbKey::serial, line.substr(6,5));
    531539    ASSERT(atomInfo.get<int>(PdbKey::serial) != 0,
    532         "PdbParser::readPdbAtomInfoContainer() - serial 0 is invalid (filler id for conect entries).");
     540        "FormatParser< pdb >::readPdbAtomInfoContainer() - serial 0 is invalid (filler id for conect entries).");
    533541  }
    534542
     
    591599 * \param newmol molecule to add parsed atoms to
    592600 */
    593 void PdbParser::readAtomDataLine(const unsigned int _step, std::string &line, molecule *newmol = NULL) {
     601void FormatParser< pdb >::readAtomDataLine(const unsigned int _step, std::string &line, molecule *newmol = NULL) {
    594602  vector<string>::iterator it;
    595603
     
    598606  bool FirstTimestep = isPresentadditionalAtomData(newAtom->getId()) ? false : true;
    599607  ASSERT((FirstTimestep && (_step == 0)) || (!FirstTimestep && (_step !=0)),
    600       "PdbParser::readAtomDataLine() - additionalAtomData present though atom is newly parsed.");
     608      "FormatParser< pdb >::readAtomDataLine() - additionalAtomData present though atom is newly parsed.");
    601609  if (FirstTimestep) {
    602610    LOG(3,"INFO: Parsing new atom.");
     
    646654      SerialSet.insert(toSize_t(atomInfo.get<std::string>(PdbKey::serial)));
    647655    ASSERT(Inserter.second,
    648         "PdbParser::readAtomDataLine() - ATOM contains entry with serial "
     656        "FormatParser< pdb >::readAtomDataLine() - ATOM contains entry with serial "
    649657        +atomInfo.get<std::string>(PdbKey::serial)+" already present!");
    650658    setSerial(toSize_t(atomInfo.get<std::string>(PdbKey::serial)), newAtom->getId());
     
    667675        ->FindElement(value);
    668676    ASSERT(elem != NULL,
    669         "PdbParser::readAtomDataLine() - element "+atomInfo.get<std::string>(PdbKey::element)+" is unknown!");
     677        "FormatParser< pdb >::readAtomDataLine() - element "+atomInfo.get<std::string>(PdbKey::element)+" is unknown!");
    670678    newAtom->setType(elem);
    671679
     
    679687    // then check additional info for consistency
    680688    ASSERT(atomInfo.get<std::string>(PdbKey::token) == consistencyInfo.get<std::string>(PdbKey::token),
    681         "PdbParser::readAtomDataLine() - difference in token on multiple time step for atom with id "
     689        "FormatParser< pdb >::readAtomDataLine() - difference in token on multiple time step for atom with id "
    682690        +atomInfo.get<std::string>(PdbKey::serial)+"!");
    683691    ASSERT(atomInfo.get<std::string>(PdbKey::name) == consistencyInfo.get<std::string>(PdbKey::name),
    684         "PdbParser::readAtomDataLine() - difference in name on multiple time step for atom with id "
     692        "FormatParser< pdb >::readAtomDataLine() - difference in name on multiple time step for atom with id "
    685693        +atomInfo.get<std::string>(PdbKey::serial)+":"
    686694        +atomInfo.get<std::string>(PdbKey::name)+"!="
    687695        +consistencyInfo.get<std::string>(PdbKey::name)+".");
    688696    ASSERT(atomInfo.get<std::string>(PdbKey::altLoc) == consistencyInfo.get<std::string>(PdbKey::altLoc),
    689         "PdbParser::readAtomDataLine() - difference in altLoc on multiple time step for atom with id "
     697        "FormatParser< pdb >::readAtomDataLine() - difference in altLoc on multiple time step for atom with id "
    690698        +atomInfo.get<std::string>(PdbKey::serial)+"!");
    691699    ASSERT(atomInfo.get<std::string>(PdbKey::resName) == consistencyInfo.get<std::string>(PdbKey::resName),
    692         "PdbParser::readAtomDataLine() - difference in resName on multiple time step for atom with id "
     700        "FormatParser< pdb >::readAtomDataLine() - difference in resName on multiple time step for atom with id "
    693701        +atomInfo.get<std::string>(PdbKey::serial)+"!");
    694702    ASSERT(atomInfo.get<std::string>(PdbKey::chainID) == consistencyInfo.get<std::string>(PdbKey::chainID),
    695         "PdbParser::readAtomDataLine() - difference in chainID on multiple time step for atom with id "
     703        "FormatParser< pdb >::readAtomDataLine() - difference in chainID on multiple time step for atom with id "
    696704        +atomInfo.get<std::string>(PdbKey::serial)+"!");
    697705    ASSERT(atomInfo.get<std::string>(PdbKey::resSeq) == consistencyInfo.get<std::string>(PdbKey::resSeq),
    698         "PdbParser::readAtomDataLine() - difference in resSeq on multiple time step for atom with id "
     706        "FormatParser< pdb >::readAtomDataLine() - difference in resSeq on multiple time step for atom with id "
    699707        +atomInfo.get<std::string>(PdbKey::serial)+"!");
    700708    ASSERT(atomInfo.get<std::string>(PdbKey::iCode) == consistencyInfo.get<std::string>(PdbKey::iCode),
    701         "PdbParser::readAtomDataLine() - difference in iCode on multiple time step for atom with id "
     709        "FormatParser< pdb >::readAtomDataLine() - difference in iCode on multiple time step for atom with id "
    702710        +atomInfo.get<std::string>(PdbKey::serial)+"!");
    703711    ASSERT(atomInfo.get<std::string>(PdbKey::occupancy) == consistencyInfo.get<std::string>(PdbKey::occupancy),
    704         "PdbParser::readAtomDataLine() - difference in occupancy on multiple time step for atom with id "
     712        "FormatParser< pdb >::readAtomDataLine() - difference in occupancy on multiple time step for atom with id "
    705713        +atomInfo.get<std::string>(PdbKey::serial)+"!");
    706714    ASSERT(atomInfo.get<std::string>(PdbKey::tempFactor) == consistencyInfo.get<std::string>(PdbKey::tempFactor),
    707         "PdbParser::readAtomDataLine() - difference in tempFactor on multiple time step for atom with id "
     715        "FormatParser< pdb >::readAtomDataLine() - difference in tempFactor on multiple time step for atom with id "
    708716        +atomInfo.get<std::string>(PdbKey::serial)+"!");
    709717    ASSERT(atomInfo.get<std::string>(PdbKey::charge) == consistencyInfo.get<std::string>(PdbKey::charge),
    710         "PdbParser::readAtomDataLine() - difference in charge on multiple time step for atom with id "
     718        "FormatParser< pdb >::readAtomDataLine() - difference in charge on multiple time step for atom with id "
    711719        +atomInfo.get<std::string>(PdbKey::serial)+"!");
    712720    ASSERT(atomInfo.get<std::string>(PdbKey::element) == consistencyInfo.get<std::string>(PdbKey::element),
    713         "PdbParser::readAtomDataLine() - difference in element on multiple time step for atom with id "
     721        "FormatParser< pdb >::readAtomDataLine() - difference in element on multiple time step for atom with id "
    714722        +atomInfo.get<std::string>(PdbKey::serial)+"!");
    715723    // and parse in trajectory
     
    734742 *
    735743 */
    736 void PdbParser::printAtomInfo(const atom * const newAtom) const
     744void FormatParser< pdb >::printAtomInfo(const atom * const newAtom) const
    737745{
    738746  const PdbAtomInfoContainer &atomInfo = additionalAtomData.at(newAtom->getId()); // operator[] const does not exist
     
    762770 * \param line to parse as an atom
    763771 */
    764 void PdbParser::readNeighbors(const unsigned int _step, std::string &line)
     772void FormatParser< pdb >::readNeighbors(const unsigned int _step, std::string &line)
    765773{
    766774  const size_t length = line.length();
     
    772780  string output;
    773781  ASSERT(length >=16,
    774       "PdbParser::readNeighbors() - CONECT entry has not enough entries: "+line+"!");
    775   output = "Split line:|";
    776   output += line.substr(6,5) + "|";
     782      "FormatParser< pdb >::readNeighbors() - CONECT entry has not enough entries: "+line+"!");
     783//  output = "Split line:|";
     784//  output += line.substr(6,5) + "|";
    777785  const size_t id = toSize_t(line.substr(6,5));
    778786  for (size_t index = 11; index <= 26; index+=5) {
     
    785793        ListOfNeighbors.push_back(otherid);
    786794      else
    787         ELOG(2, "PdbParser::readNeighbors() - discarding conect entry with id 0.");
     795        ELOG(2, "FormatParser< pdb >::readNeighbors() - discarding conect entry with id 0.");
    788796    } else  {
    789797      break;
     
    813821 * \return input string with modified atom IDs
    814822 */
    815 //string PdbParser::adaptIdDependentDataString(string data) {
     823//string  FormatParser< pdb >::adaptIdDependentDataString(string data) {
    816824//  // there might be no IDs
    817825//  if (data == "-") {
     
    836844
    837845
    838 bool PdbParser::operator==(const PdbParser& b) const
     846bool FormatParser< pdb >::operator==(const FormatParser< pdb >& b) const
    839847{
    840848  bool status = true;
  • src/Parser/PdbParser.hpp

    rfa9d1d r360c8b  
    1414#endif
    1515
     16#include <string>
    1617
    17 #include <string>
    1818#include "FormatParser.hpp"
     19#include "FormatParserTrait.hpp"
     20#include "FormatParserInterface.hpp"
     21#include "FormatParser_common.hpp"
     22#include "ParserTypes.hpp"
     23
    1924#include "PdbAtomInfoContainer.hpp"
    2025#include "PdbKey.hpp"
     26
     27class molecule;
     28
     29// declaration of specialized FormatParserTrait
     30template<>
     31struct FormatParserTrait<pdb>
     32{
     33  //!> Name of the parser
     34  static const std::string name;
     35  //!> suffix of the files the parser understands to read and write
     36  static const std::string suffix;
     37  //!> ParserTypes enumeration for the parser
     38  static const enum ParserTypes type;
     39};
    2140
    2241/**
    2342 * Loads a PDB format 3.2 file into the World and saves the World as a PDB file.
    2443 */
    25 class PdbParser : public FormatParser
     44template <>
     45class FormatParser< pdb >  : virtual public FormatParserInterface, public FormatParser_common
    2646{
    2747public:
    28   PdbParser();
    29   virtual ~PdbParser();
     48  FormatParser();
     49  virtual ~FormatParser();
    3050  void load(std::istream* file);
    3151  void save(std::ostream* file, const std::vector<atom *> &atoms);
    3252
    33   bool operator==(const PdbParser& b) const;
     53  bool operator==(const FormatParser< pdb>& b) const;
    3454  void printAtomInfo(const atom *newAtom) const;
    3555
     
    91111   */
    92112  std::set<size_t> SerialSet;
    93 
    94113};
    95114
  • src/Parser/TremoloParser.cpp

    rfa9d1d r360c8b  
    4242using namespace std;
    4343
     44// declare specialized static variables
     45const std::string FormatParserTrait<tremolo>::name = "tremolo";
     46const std::string FormatParserTrait<tremolo>::suffix = "data";
     47const ParserTypes FormatParserTrait<tremolo>::type = tremolo;
     48
    4449/**
    4550 * Constructor.
    4651 */
    47 TremoloParser::TremoloParser() {
     52FormatParser< tremolo >::FormatParser()  :
     53  FormatParser_common(NULL)
     54{
    4855  knownKeys["x"] = TremoloKey::x;
    4956  knownKeys["u"] = TremoloKey::u;
     
    8794 * Destructor.
    8895 */
    89 TremoloParser::~TremoloParser() {
    90         std::cerr << "Clearing usedFields." << std::endl;
     96FormatParser< tremolo >::~FormatParser()
     97{
     98  std::cerr << "Clearing usedFields." << std::endl;
    9199  usedFields.clear();
    92100  additionalAtomData.clear();
     
    100108 * \param tremolo file
    101109 */
    102 void TremoloParser::load(istream* file) {
     110void FormatParser< tremolo >::load(istream* file) {
    103111  string line;
    104112  string::size_type location;
     
    141149 * \param atoms atoms to store
    142150 */
    143 void TremoloParser::save(ostream* file, const std::vector<atom *> &AtomList) {
     151void FormatParser< tremolo >::save(ostream* file, const std::vector<atom *> &AtomList) {
    144152  DoLog(0) && (Log() << Verbose(0) << "Saving changes to tremolo." << std::endl);
    145153
     
    169177 * @param id of atom
    170178 */
    171 void TremoloParser::AtomInserted(atomId_t id)
     179void FormatParser< tremolo >::AtomInserted(atomId_t id)
    172180{
    173181  std::map<int, TremoloAtomInfoContainer>::iterator iter = additionalAtomData.find(id);
    174182  ASSERT(iter == additionalAtomData.end(),
    175       "TremoloParser::AtomInserted() - additionalAtomData already present for newly added atom "
     183      "FormatParser< tremolo >::AtomInserted() - additionalAtomData already present for newly added atom "
    176184      +toString(id)+".");
    177185  // don't add entry, as this gives a default resSeq of 0 not the molecule id
     
    183191 * @param id of atom
    184192 */
    185 void TremoloParser::AtomRemoved(atomId_t id)
     193void FormatParser< tremolo >::AtomRemoved(atomId_t id)
    186194{
    187195  std::map<int, TremoloAtomInfoContainer>::iterator iter = additionalAtomData.find(id);
    188196  // as we do not insert AtomData on AtomInserted, we cannot be assured of its presence
    189197//  ASSERT(iter != additionalAtomData.end(),
    190 //      "TremoloParser::AtomRemoved() - additionalAtomData is not present for atom "
     198//      "FormatParser< tremolo >::AtomRemoved() - additionalAtomData is not present for atom "
    191199//      +toString(id)+" to remove.");
    192200  if (iter != additionalAtomData.end())
     
    201209 *        but without the prexix "ATOMDATA"
    202210 */
    203 void TremoloParser::setFieldsForSave(std::string atomDataLine) {
     211void FormatParser< tremolo >::setFieldsForSave(std::string atomDataLine) {
    204212  parseAtomDataKeysLine(atomDataLine, 0);
    205213}
     
    212220 * \param reference to the atom of which information should be written
    213221 */
    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
     222void 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
    217226
    218227  TremoloKey::atomDataKey currentField;
     
    308317 * \param reference to the atom of which to take the neighbor information
    309318 */
    310 void TremoloParser::writeNeighbors(ostream* file, int numberOfNeighbors, atom* currentAtom) {
     319void FormatParser< tremolo >::writeNeighbors(ostream* file, int numberOfNeighbors, atom* currentAtom) {
    311320  const BondList& ListOfBonds = currentAtom->getListOfBonds();
    312321  // sort bonded indices
     
    331340 * \param with which offset the keys begin within the line
    332341 */
    333 void TremoloParser::parseAtomDataKeysLine(string line, int offset) {
     342void FormatParser< tremolo >::parseAtomDataKeysLine(string line, int offset) {
    334343  string keyword;
    335344  stringstream lineStream;
     
    353362 *  \a atomdata_string.
    354363 *
    355  *  We just call \sa TremoloParser::parseAtomDataKeysLine() which is left
     364 *  We just call \sa  FormatParser< tremolo >::parseAtomDataKeysLine() which is left
    356365 *  private.,
    357366 *
    358367 * @param atomdata_string line to parse with space-separated values
    359368 */
    360 void TremoloParser::setAtomData(const std::string &atomdata_string)
     369void FormatParser< tremolo >::setAtomData(const std::string &atomdata_string)
    361370{
    362371  parseAtomDataKeysLine(atomdata_string, 0);
     
    371380 * \param *newmol molecule to add atom to
    372381 */
    373 void TremoloParser::readAtomDataLine(string line, molecule *newmol = NULL) {
     382void FormatParser< tremolo >::readAtomDataLine(string line, molecule *newmol = NULL) {
    374383  vector<string>::iterator it;
    375384  stringstream lineStream;
     
    389398  tokenizer tokens(line, whitespacesep);
    390399  ASSERT(tokens.begin() != tokens.end(),
    391       "TremoloParser::readAtomDataLine - empty string, need at least ' '!");
     400      "FormatParser< tremolo >::readAtomDataLine - empty string, need at least ' '!");
    392401  tokenizer::iterator tok_iter = tokens.begin();
    393402  // then associate each token to each file
     
    401410        // for the moment, assume there are always three dimensions
    402411        for (int i=0;i<NDIM;i++) {
    403           ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for x["+toString(i)+"]!");
     412          ASSERT(tok_iter != tokens.end(), "FormatParser< tremolo >::readAtomDataLine() - no value for x["+toString(i)+"]!");
    404413          DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl);
    405414          newAtom->set(i, toDouble(*tok_iter));
     
    410419        // for the moment, assume there are always three dimensions
    411420        for (int i=0;i<NDIM;i++) {
    412           ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for u["+toString(i)+"]!");
     421          ASSERT(tok_iter != tokens.end(), "FormatParser< tremolo >::readAtomDataLine() - no value for u["+toString(i)+"]!");
    413422          DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl);
    414423          tempVector[i] = toDouble(*tok_iter);
     
    419428      case TremoloKey::type :
    420429      {
    421         ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for "+keyName+"!");
     430        ASSERT(tok_iter != tokens.end(), "FormatParser< tremolo >::readAtomDataLine() - no value for "+keyName+"!");
    422431        DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl);
    423432        std::string element(knownTypes[(*tok_iter)]);
     
    431440      }
    432441      case TremoloKey::Id :
    433         ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for "+keyName+"!");
     442        ASSERT(tok_iter != tokens.end(), "FormatParser< tremolo >::readAtomDataLine() - no value for "+keyName+"!");
    434443        DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl);
    435444        atomIdMap[toInt(*tok_iter)] = newAtom->getId();
     
    438447      case TremoloKey::neighbors :
    439448        for (int i=0;i<atoi(it->substr(it->find("=") + 1, 1).c_str());i++) {
    440           ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for "+keyName+"!");
     449          ASSERT(tok_iter != tokens.end(), "FormatParser< tremolo >::readAtomDataLine() - no value for "+keyName+"!");
    441450          DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl);
    442451          lineStream << *tok_iter << "\t";
     
    447456        break;
    448457      default :
    449         ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for "+keyName+"!");
     458        ASSERT(tok_iter != tokens.end(), "FormatParser< tremolo >::readAtomDataLine() - no value for "+keyName+"!");
    450459        DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl);
    451460        atomInfo->set(currentField, *tok_iter);
     
    467476 * \param atomid world id of the atom the information belongs to
    468477 */
    469 void TremoloParser::readNeighbors(stringstream* line, int numberOfNeighbors, int atomId) {
     478void FormatParser< tremolo >::readNeighbors(stringstream* line, int numberOfNeighbors, int atomId) {
    470479  int neighborId = 0;
    471480  for (int i = 0; i < numberOfNeighbors; i++) {
     
    489498 * \return true if the field name is used
    490499 */
    491 bool TremoloParser::isUsedField(string fieldName) {
     500bool FormatParser< tremolo >::isUsedField(string fieldName) {
    492501  bool fieldNameExists = false;
    493502  for (vector<string>::iterator usedField = usedFields.begin(); usedField != usedFields.end(); usedField++) {
     
    505514 * Id found in the parsed file.
    506515 */
    507 void TremoloParser::processNeighborInformation() {
     516void FormatParser< tremolo >::processNeighborInformation() {
    508517  if (!isUsedField("neighbors")) {
    509518    return;
     
    538547 * \return input string with modified atom IDs
    539548 */
    540 string TremoloParser::adaptIdDependentDataString(string data) {
     549std::string FormatParser< tremolo >::adaptIdDependentDataString(string data) {
    541550  // there might be no IDs
    542551  if (data == "-") {
     
    563572 * as they might differ from the originally read IDs.
    564573 */
    565 void TremoloParser::adaptImprData() {
     574void FormatParser< tremolo >::adaptImprData() {
    566575  if (!isUsedField("imprData")) {
    567576    return;
     
    579588 * as they might differ from the originally read IDs.
    580589 */
    581 void TremoloParser::adaptTorsion() {
     590void FormatParser< tremolo >::adaptTorsion() {
    582591  if (!isUsedField("torsion")) {
    583592    return;
     
    594603 *
    595604 */
    596 void TremoloParser::createKnownTypesByIdentity()
     605void FormatParser< tremolo >::createKnownTypesByIdentity()
    597606{
    598607  // remove old mapping
     
    611620 * @param file input stream of .potentials file
    612621 */
    613 void TremoloParser::parseKnownTypes(std::istream &file)
     622void FormatParser< tremolo >::parseKnownTypes(std::istream &file)
    614623{
    615624  const periodentafel *periode = World::getInstance().getPeriode();
     
    632641      tokenizer tokens(line, tokensep);
    633642      ASSERT(tokens.begin() != tokens.end(),
    634           "TremoloParser::parseKnownTypes() - line with 'particle:' but no particles separated by comma.");
     643          "FormatParser< tremolo >::parseKnownTypes() - line with 'particle:' but no particles separated by comma.");
    635644      // look for particle_type
    636645      std::string particle_type("NULL");
     
    643652          tokenizer token((*tok_iter), equalitysep);
    644653          ASSERT(token.begin() != token.end(),
    645                     "TremoloParser::parseKnownTypes() - could not split particle_type by equality sign");
     654                    "FormatParser< tremolo >::parseKnownTypes() - could not split particle_type by equality sign");
    646655          tokenizer::iterator particle_iter = token.begin();
    647656          particle_iter++;
     
    652661          tokenizer token((*tok_iter), equalitysep);
    653662          ASSERT(token.begin() != token.end(),
    654                     "TremoloParser::parseKnownTypes() - could not split particle_type by equality sign");
     663                    "FormatParser< tremolo >::parseKnownTypes() - could not split particle_type by equality sign");
    655664          tokenizer::iterator element_iter = token.begin();
    656665          element_iter++;
  • src/Parser/TremoloParser.hpp

    rfa9d1d r360c8b  
    1414#endif
    1515
     16#include <string>
    1617
    17 #include <string>
    18 #include "Parser/FormatParser.hpp"
     18#include "FormatParser.hpp"
     19#include "FormatParserTrait.hpp"
     20#include "FormatParserInterface.hpp"
     21#include "FormatParser_common.hpp"
     22#include "ParserTypes.hpp"
    1923
    2024#include "TremoloKey.hpp"
     
    2327class molecule;
    2428
     29// declaration of specialized FormatParserTrait
     30template<>
     31struct FormatParserTrait<tremolo>
     32{
     33  //!> Name of the parser
     34  static const std::string name;
     35  //!> suffix of the files the parser understands to read and write
     36  static const std::string suffix;
     37  //!> ParserTypes enumeration for the parser
     38  static const enum ParserTypes type;
     39};
     40
    2541/**
    2642 * Loads a tremolo file into the World and saves the World as a tremolo file.
    2743 */
    28 class TremoloParser : public FormatParser
     44template <>
     45class FormatParser< tremolo >  : virtual public FormatParserInterface, public FormatParser_common
    2946{
    3047public:
    31   TremoloParser();
    32   virtual ~TremoloParser();
     48  FormatParser();
     49  virtual ~FormatParser();
    3350  void load(std::istream* file);
    3451  void save(std::ostream* file, const std::vector<atom *> &atoms);
     
    4461
    4562private:
    46   void readAtomDataLine(string line);
    47   void readAtomDataLine(string line, molecule *newmol);
    48   void parseAtomDataKeysLine(string line, int offset);
     63  void readAtomDataLine(std::string line);
     64  void readAtomDataLine(std::string line, molecule *newmol);
     65  void parseAtomDataKeysLine(std::string line, int offset);
    4966  void readNeighbors(std::stringstream* line, int numberOfNeighbors, int atomId);
    5067  void processNeighborInformation();
  • src/Parser/XyzParser.cpp

    rfa9d1d r360c8b  
    3333using namespace std;
    3434
     35// declare specialized static variables
     36const std::string FormatParserTrait<xyz>::name = "xyz";
     37const std::string FormatParserTrait<xyz>::suffix = "xyz";
     38const ParserTypes FormatParserTrait<xyz>::type = xyz;
     39
    3540/**
    3641 * Constructor.
    3742 */
    38 XyzParser::XyzParser() :
     43FormatParser< xyz >::FormatParser() :
     44  FormatParser_common(NULL),
    3945  comment("")
    4046{}
     
    4349 * Destructor.
    4450 */
    45 XyzParser::~XyzParser() {
    46 }
     51FormatParser< xyz >::~FormatParser()
     52{}
    4753
    4854/**
     
    5157 * \param XYZ file
    5258 */
    53 void XyzParser::load(istream* file)
     59void FormatParser< xyz >::load(istream* file)
    5460{
    5561  atom* newAtom = NULL;
     
    99105        LOG(5, "INFO: Using present atom " << *newAtom << " from " << i << " th component of AddedAtoms.");
    100106        ASSERT(newAtom->getType() == World::getInstance().getPeriode()->FindElement(type),
    101             "XyzParser::load() - atom has different type "+newAtom->getType()->getSymbol()+" than parsed now "+type+", mixed up order?");
     107            "FormatParser< xyz >::load() - atom has different type "+newAtom->getType()->getSymbol()+" than parsed now "+type+", mixed up order?");
    102108      }
    103109      newAtom->setPositionAtStep(step, tempVector);
     
    129135 * \param atoms atoms to store
    130136 */
    131 void XyzParser::save(ostream* file, const std::vector<atom *> &atoms) {
     137void FormatParser< xyz >::save(ostream* file, const std::vector<atom *> &atoms) {
    132138  DoLog(0) && (Log() << Verbose(0) << "Saving changes to xyz." << std::endl);
    133139
     
    145151  }
    146152  ASSERT((min_trajectories == max_trajectories) || (min_trajectories == 1),
    147       "XyzParser::save() - not all atoms have same number of trajectories.");
     153      "FormatParser< xyz >::save() - not all atoms have same number of trajectories.");
    148154  LOG(2, "INFO: There are " << max_trajectories << " to save.");
    149155
  • src/Parser/XyzParser.hpp

    rfa9d1d r360c8b  
    1414#endif
    1515
     16#include <string>
    1617
    17 #include <string>
    18 #include "Parser/FormatParser.hpp"
     18
     19#include "FormatParser.hpp"
     20#include "FormatParserTrait.hpp"
     21#include "FormatParserInterface.hpp"
     22#include "FormatParser_common.hpp"
     23#include "ParserTypes.hpp"
     24
     25// declaration of specialized FormatParserTrait
     26template<>
     27struct FormatParserTrait<xyz>
     28{
     29  //!> Name of the parser
     30  static const std::string name;
     31  //!> suffix of the files the parser understands to read and write
     32  static const std::string suffix;
     33  //!> ParserTypes enumeration for the parser
     34  static const enum ParserTypes type;
     35};
    1936
    2037/**
    2138 * Parser for XYZ files.
    2239 */
    23 class XyzParser : public FormatParser {
     40template <>
     41class FormatParser< xyz >  : virtual public FormatParserInterface, public FormatParser_common
     42{
    2443public:
    25   XyzParser();
    26   virtual ~XyzParser();
     44  FormatParser();
     45  virtual ~FormatParser();
    2746  void load(std::istream* file);
    2847  void save(std::ostream* file, const std::vector<atom *> &atoms);
  • src/Parser/unittests/Makefile.am

    rfa9d1d r360c8b  
    22# Also indentation by a single tab
    33
     4include ../../src/Parser/Parameters/unittests/Makefile.am
    45
    56PARSERTESTSSOURCES = \
     
    78        ../Parser/unittests/ParserPcpUnitTest.cpp \
    89        ../Parser/unittests/ParserPdbUnitTest.cpp \
     10        ../Parser/unittests/ParserPsi3UnitTest.cpp \
    911        ../Parser/unittests/ParserTremoloUnitTest.cpp \
    1012        ../Parser/unittests/ParserXyzUnitTest.cpp
     
    1416        ../Parser/unittests/ParserPcpUnitTest.hpp \
    1517        ../Parser/unittests/ParserPdbUnitTest.hpp \
     18        ../Parser/unittests/ParserPsi3UnitTest.hpp \
    1619        ../Parser/unittests/ParserTremoloUnitTest.hpp \
    1720        ../Parser/unittests/ParserXyzUnitTest.hpp
     
    2124  ParserPcpUnitTest \
    2225  ParserPdbUnitTest \
     26  ParserPsi3UnitTest \
    2327  ParserTremoloUnitTest \
    2428  ParserXyzUnitTest
     
    3337        ${CodePatterns_LIBS}
    3438#       $(BOOST_LIB)
    35 
    3639
    3740
     
    5154ParserPdbUnitTest_LDADD = ${PARSERLIBS}
    5255
     56ParserPsi3UnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
     57        ../Parser/unittests/ParserPsi3UnitTest.cpp \
     58        ../Parser/unittests/ParserPsi3UnitTest.hpp
     59ParserPsi3UnitTest_LDADD = ${PARSERLIBS}
     60
    5361ParserTremoloUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
    5462        ../Parser/unittests/ParserTremoloUnitTest.cpp \
  • src/Parser/unittests/ParserMpqcUnitTest.cpp

    rfa9d1d r360c8b  
    3232#include "Descriptors/AtomTypeDescriptor.hpp"
    3333#include "CodePatterns/Assert.hpp"
     34#include "Parser/ChangeTracker.hpp"
     35#include "Parser/MpqcParser.hpp"
    3436
    3537#ifdef HAVE_TESTRUNNER
     
    156158)\n"; // basically tested with mpqc 3.0.0-alpha (no parse errors but did not calculate due to missing code)
    157159
    158 void ParserMpqcUnitTest::setUp() {
    159   mpqc = new MpqcParser();
     160void ParserMpqcUnitTest::setUp()
     161{
     162  // failing asserts should be thrown
     163  ASSERT_DO(Assert::Throw);
     164
     165  parser = new FormatParser<mpqc>();
    160166
    161167  World::getInstance();
     
    168174}
    169175
    170 void ParserMpqcUnitTest::tearDown() {
    171   delete mpqc;
     176void ParserMpqcUnitTest::tearDown()
     177{
     178  delete parser;
    172179  ChangeTracker::purgeInstance();
    173180  World::purgeInstance();
     
    176183/************************************ tests ***********************************/
    177184
    178 void ParserMpqcUnitTest::ParameterTypeTest() {
    179   // check types in boost::any map
    180   CPPUNIT_ASSERT(mpqc->getParams().params[MpqcParser_Parameters::hessianParam].type() == typeid(bool));
    181   CPPUNIT_ASSERT(mpqc->getParams().params[MpqcParser_Parameters::hessianParam].type() != typeid(int));
    182   CPPUNIT_ASSERT(mpqc->getParams().params[MpqcParser_Parameters::savestateParam].type() == typeid(bool));
    183   CPPUNIT_ASSERT(mpqc->getParams().params[MpqcParser_Parameters::do_gradientParam].type() == typeid(bool));
    184   CPPUNIT_ASSERT(mpqc->getParams().params[MpqcParser_Parameters::maxiterParam].type() == typeid(int));
    185   CPPUNIT_ASSERT(mpqc->getParams().params[MpqcParser_Parameters::memoryParam].type() == typeid(int));
    186   CPPUNIT_ASSERT(mpqc->getParams().params[MpqcParser_Parameters::stdapproxParam].type() == typeid(std::string));
    187   CPPUNIT_ASSERT(mpqc->getParams().params[MpqcParser_Parameters::nfzcParam].type() == typeid(int));
    188   CPPUNIT_ASSERT(mpqc->getParams().params[MpqcParser_Parameters::basisParam].type() == typeid(std::string));
    189   CPPUNIT_ASSERT(mpqc->getParams().params[MpqcParser_Parameters::aux_basisParam].type() == typeid(std::string));
    190   CPPUNIT_ASSERT(mpqc->getParams().params[MpqcParser_Parameters::integrationParam].type() == typeid(MpqcParser_Parameters::IntegralCints));
    191   CPPUNIT_ASSERT(mpqc->getParams().params[MpqcParser_Parameters::theoryParam].type() == typeid(MpqcParser_Parameters::MBPT2));
    192 }
    193 
    194185void ParserMpqcUnitTest::ParameterDefaultTest() {
    195186  // check default values
    196   CPPUNIT_ASSERT(mpqc->getParams().getString(MpqcParser_Parameters::hessianParam) == "no");
    197   CPPUNIT_ASSERT(!mpqc->getParams().getBool(MpqcParser_Parameters::hessianParam));
    198   CPPUNIT_ASSERT(mpqc->getParams().getString(MpqcParser_Parameters::savestateParam) == "no");
    199   CPPUNIT_ASSERT(!mpqc->getParams().getBool(MpqcParser_Parameters::savestateParam));
    200   CPPUNIT_ASSERT(mpqc->getParams().getString(MpqcParser_Parameters::do_gradientParam) == "yes");
    201   CPPUNIT_ASSERT(mpqc->getParams().getBool(MpqcParser_Parameters::do_gradientParam));
    202   CPPUNIT_ASSERT(mpqc->getParams().getInt(MpqcParser_Parameters::maxiterParam) == 1000);
    203   CPPUNIT_ASSERT(mpqc->getParams().getInt(MpqcParser_Parameters::memoryParam) == 16000000);
    204   CPPUNIT_ASSERT(mpqc->getParams().getString(MpqcParser_Parameters::stdapproxParam) == "A'");
    205   CPPUNIT_ASSERT(mpqc->getParams().getInt(MpqcParser_Parameters::nfzcParam) == 1);
    206   CPPUNIT_ASSERT(mpqc->getParams().getString(MpqcParser_Parameters::basisParam) == "3-21G");
    207   CPPUNIT_ASSERT(mpqc->getParams().getString(MpqcParser_Parameters::aux_basisParam) == "aug-cc-pVDZ");
    208   CPPUNIT_ASSERT(mpqc->getParams().getString(MpqcParser_Parameters::integrationParam) == "IntegralCints");
    209   CPPUNIT_ASSERT(mpqc->getParams().getString(MpqcParser_Parameters::theoryParam) == "MBPT2");
    210   CPPUNIT_ASSERT(mpqc->getParams().getTheory() == MpqcParser_Parameters::MBPT2);
    211   CPPUNIT_ASSERT(mpqc->getParams().getIntegration() == MpqcParser_Parameters::IntegralCints);
    212 
    213   // check that values are not removed
    214   CPPUNIT_ASSERT(!mpqc->getParams().params[MpqcParser_Parameters::theoryParam].empty());
    215 
    216   // check throw, for the moment aren't, are caught in getInt()
    217   CPPUNIT_ASSERT_THROW(mpqc->getParams().getInt(MpqcParser_Parameters::integrationParam), boost::bad_any_cast);
    218   CPPUNIT_ASSERT_THROW(mpqc->getParams().getInt(MpqcParser_Parameters::theoryParam), boost::bad_any_cast);
    219 
     187  CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::hessianParam) == std::string("no"));
     188  CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::savestateParam) == std::string("no"));
     189  CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::do_gradientParam) == std::string("yes"));
     190  CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::maxiterParam) == std::string("1000"));
     191  CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::memoryParam) == std::string("16000000"));
     192  CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::stdapproxParam) == std::string("A'"));
     193  CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::nfzcParam) == std::string("1"));
     194  CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::basisParam) == std::string("3-21G"));
     195  CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::aux_basisParam) == std::string("aug-cc-pVDZ"));
     196  CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::integrationParam) == std::string("IntegralCints"));
     197  CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::theoryParam) == std::string("MBPT2"));
    220198}
    221199
    222200void ParserMpqcUnitTest::ParameterCloneTest() {
    223   FormatParser_Parameters *clone = mpqc->getParams().clone();
    224   CPPUNIT_ASSERT(mpqc->getParams().getString(MpqcParser_Parameters::theoryParam) == "MBPT2");
     201  FormatParser_Parameters *clone = parser->getParams().clone();
     202  CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::theoryParam) == std::string("MBPT2"));
    225203  std::stringstream setvalue("theory = CLHF");
    226   setvalue >> mpqc->getParams();
    227   CPPUNIT_ASSERT(mpqc->getParams().getString(MpqcParser_Parameters::theoryParam) == "CLHF");
    228   mpqc->getParams().makeClone(*clone);
    229   CPPUNIT_ASSERT(mpqc->getParams().getString(MpqcParser_Parameters::theoryParam) == "MBPT2");
     204  setvalue >> parser->getParams();
     205  CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::theoryParam) == std::string("CLHF"));
     206  parser->getParams().makeClone(*clone);
     207  CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::theoryParam) == std::string("MBPT2"));
    230208}
    231209
     
    234212  {
    235213    std::stringstream setvalue("theory = CLHF");
    236     setvalue >> mpqc->getParams();
     214    setvalue >> parser->getParams();
    237215//    std::cout << "integration method is "
    238 //        << mpqc->getParams().getString(MpqcParser_Parameters::theoryParam) << std::endl;
    239     CPPUNIT_ASSERT(mpqc->getParams().getString(MpqcParser_Parameters::theoryParam) == "CLHF");
     216//        << parser->getParams().getString(MpqcParser_Parameters::theoryParam) << std::endl;
     217    CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::theoryParam) == std::string("CLHF"));
    240218  }
    241219  // test a bool
    242220  {
    243221    std::stringstream setvalue("Hessian = yes");
    244     setvalue >> mpqc->getParams();
     222    setvalue >> parser->getParams();
    245223//    std::cout << "Hessian is "
    246 //        << mpqc->getParams().getString(MpqcParser_Parameters::hessianParam) << std::endl;
    247     CPPUNIT_ASSERT(mpqc->getParams().getString(MpqcParser_Parameters::hessianParam) == "yes");
     224//        << parser->getParams().getString(MpqcParser_Parameters::hessianParam) << std::endl;
     225    CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::hessianParam) == std::string("yes"));
    248226  }
    249227  // test int
    250228  {
    251229    std::stringstream setvalue("maxiter = 500");
    252     setvalue >> mpqc->getParams();
     230    setvalue >> parser->getParams();
    253231//    std::cout << "maxiter is "
    254 //        << mpqc->getParams().getString(MpqcParser_Parameters::maxiterParam) << std::endl;
    255     CPPUNIT_ASSERT(mpqc->getParams().getInt(MpqcParser_Parameters::maxiterParam) == 500);
     232//        << parser->getParams().getString(MpqcParser_Parameters::maxiterParam) << std::endl;
     233    CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::maxiterParam) == std::string("500"));
    256234  }
    257235  // test whether unknown key fails
     
    261239#ifndef NDEBUG
    262240    ASSERT_DO(Assert::Throw);
    263     CPPUNIT_ASSERT_THROW(setvalue >> mpqc->getParams(), Assert::AssertionFailure);
     241    CPPUNIT_ASSERT_THROW(setvalue >> parser->getParams(), Assert::AssertionFailure);
    264242#else
    265     setvalue >> mpqc->getParams();
     243    setvalue >> parser->getParams();
    266244#endif
    267245//    std::cout << "Hessian is still "
    268 //        << mpqc->getParams().getString(MpqcParser_Parameters::hessianParam) << std::endl;
    269     CPPUNIT_ASSERT(mpqc->getParams().getString(MpqcParser_Parameters::hessianParam) == "yes");
     246//        << parser->getParams().getString(MpqcParser_Parameters::hessianParam) << std::endl;
     247    CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::hessianParam) == std::string("yes"));
    270248  }
    271249}
     
    273251void ParserMpqcUnitTest::readMpqcTest() {
    274252  stringstream input(waterMpqc_CLHF);
    275   mpqc->getParams().setTheory(MpqcParser_Parameters::CLHF);
    276   mpqc->load(&input);
     253  parser->getParams().setParameter(
     254      MpqcParser_Parameters::theoryParam,
     255      parser->getParams().getTheoryName(MpqcParser_Parameters::CLHF)
     256          );
     257  parser->load(&input);
    277258
    278259  CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms());
     
    301282    // compare both configs for CLHF
    302283    stringstream output;
    303     mpqc->getParams().setTheory(MpqcParser_Parameters::CLHF);
    304     mpqc->save(&output, atoms);
     284    parser->getParams().setParameter(
     285        MpqcParser_Parameters::theoryParam,
     286        parser->getParams().getTheoryName(MpqcParser_Parameters::CLHF)
     287            );
     288    parser->save(&output, atoms);
    305289    stringstream input(waterMpqc_CLHF);
     290    // check for non-empty streams
     291    input.peek();
     292    output.peek();
     293    CPPUNIT_ASSERT(input.good() && output.good());
     294    // check equality of streams per line (for debugging)
    306295    for (; std::getline(input, first) && std::getline(output, second); ) {
    307296      //std::cout << "Comparing '" << first << "' to '" << second << "'" << std::endl;
     
    312301    // compare both configs for CLKS
    313302    stringstream output;
    314     mpqc->getParams().setTheory(MpqcParser_Parameters::CLKS);
    315     mpqc->save(&output, atoms);
     303    parser->getParams().setParameter(
     304        MpqcParser_Parameters::theoryParam,
     305        parser->getParams().getTheoryName(MpqcParser_Parameters::CLKS)
     306            );
     307    parser->save(&output, atoms);
    316308    stringstream input(waterMpqc_CLKS);
     309    // check for non-empty streams
     310    input.peek();
     311    output.peek();
     312    CPPUNIT_ASSERT(input.good() && output.good());
     313    // check equality of streams per line (for debugging)
    317314    for (; std::getline(input, first) && std::getline(output, second); ) {
    318315      //std::cout << "Comparing '" << first << "' to '" << second << "'" << std::endl;
     
    323320    // compare both configs for MBPT2
    324321    stringstream output;
    325     mpqc->getParams().setTheory(MpqcParser_Parameters::MBPT2);
    326     mpqc->save(&output, atoms);
     322    parser->getParams().setParameter(
     323        MpqcParser_Parameters::theoryParam,
     324        parser->getParams().getTheoryName(MpqcParser_Parameters::MBPT2)
     325            );
     326    parser->save(&output, atoms);
    327327    stringstream input(waterMpqc_MBPT2);
     328    // check for non-empty streams
     329    input.peek();
     330    output.peek();
     331    CPPUNIT_ASSERT(input.good() && output.good());
     332    // check equality of streams per line (for debugging)
    328333    for (; std::getline(input, first) && std::getline(output, second); ) {
    329334      //std::cout << "Comparing '" << first << "' to '" << second << "'" << std::endl;
     
    334339    // compare both configs for MBPT2_R12
    335340    stringstream output;
    336     mpqc->getParams().setTheory(MpqcParser_Parameters::MBPT2_R12);
    337     mpqc->save(&output, atoms);
     341    parser->getParams().setParameter(
     342        MpqcParser_Parameters::theoryParam,
     343        parser->getParams().getTheoryName(MpqcParser_Parameters::MBPT2_R12)
     344            );
     345    parser->save(&output, atoms);
    338346    stringstream input(waterMpqc_MBPT2_R12);
     347    // check for non-empty streams
     348    input.peek();
     349    output.peek();
     350    CPPUNIT_ASSERT(input.good() && output.good());
     351    // check equality of streams per line (for debugging)
    339352    for (; std::getline(input, first) && std::getline(output, second); ) {
    340353      //std::cout << "Comparing '" << first << "' to '" << second << "'" << std::endl;
  • src/Parser/unittests/ParserMpqcUnitTest.hpp

    rfa9d1d r360c8b  
    2121{
    2222  CPPUNIT_TEST_SUITE( ParserMpqcUnitTest ) ;
    23   CPPUNIT_TEST ( ParameterTypeTest );
    2423  CPPUNIT_TEST ( ParameterDefaultTest );
    2524  CPPUNIT_TEST ( ParameterSetterTest );
     
    3332  void tearDown();
    3433
    35   void ParameterTypeTest();
    3634  void ParameterDefaultTest();
    3735  void ParameterSetterTest();
     
    4139
    4240private:
    43   MpqcParser *mpqc;
     41  FormatParser<mpqc> *parser;
    4442};
    4543
  • src/Parser/unittests/ParserPcpUnitTest.cpp

    rfa9d1d r360c8b  
    2424#include <cppunit/ui/text/TestRunner.h>
    2525
    26 #include "Parser/PcpParser.hpp"
    2726#include "World.hpp"
    2827#include "atom.hpp"
     
    3130#include "CodePatterns/Log.hpp"
    3231#include "Descriptors/AtomTypeDescriptor.hpp"
     32#include "Parser/ChangeTracker.hpp"
     33#include "Parser/PcpParser.hpp"
    3334
    3435#ifdef HAVE_TESTRUNNER
     
    119120  World::getInstance();
    120121
     122  parser = new FormatParser<pcp>();
     123
    121124  setVerbosity(2);
    122125
     
    126129}
    127130
    128 void ParserPcpUnitTest::tearDown() {
     131void ParserPcpUnitTest::tearDown()
     132{
     133  delete parser;
    129134  ChangeTracker::purgeInstance();
    130135  World::purgeInstance();
     
    135140void ParserPcpUnitTest::readwritePcpTest() {
    136141  stringstream input(waterPcp);
    137   PcpParser* testParser = new PcpParser();
    138   testParser->load(&input);
     142  parser->load(&input);
    139143  input.clear();
    140144
     
    142146
    143147  // check that equality function is ok
    144   CPPUNIT_ASSERT(*testParser == *testParser);
     148  CPPUNIT_ASSERT(*parser == *parser);
    145149
    146150  stringstream output;
    147151  std::vector<atom *> atoms = World::getInstance().getAllAtoms();
    148   testParser->save(&output, atoms);
     152  parser->save(&output, atoms);
    149153
    150154  input << output.str();
    151   PcpParser* testParser2 = new PcpParser();
    152   testParser2->load(&input);
     155  FormatParser<pcp>* parser2 = new FormatParser<pcp>();
     156  parser2->load(&input);
    153157
    154158  CPPUNIT_ASSERT_EQUAL(6, World::getInstance().numAtoms());
    155159
    156   CPPUNIT_ASSERT(*testParser == *testParser2);
     160  CPPUNIT_ASSERT(*parser == *parser2);
     161
     162  delete parser2;
    157163}
  • src/Parser/unittests/ParserPcpUnitTest.hpp

    rfa9d1d r360c8b  
    1313#endif
    1414
     15#include "Parser/PcpParser.hpp"
    1516
    1617#include <cppunit/extensions/HelperMacros.h>
     
    2829
    2930  void readwritePcpTest();
     31
     32private:
     33  FormatParser<pcp> *parser;
    3034};
    3135
  • src/Parser/unittests/ParserPdbUnitTest.cpp

    rfa9d1d r360c8b  
    2424#include <cppunit/ui/text/TestRunner.h>
    2525
    26 #include "Parser/PdbParser.hpp"
    2726#include "World.hpp"
    2827#include "atom.hpp"
     
    3130#include "CodePatterns/Log.hpp"
    3231#include "Descriptors/AtomTypeDescriptor.hpp"
     32#include "Parser/ChangeTracker.hpp"
     33#include "Parser/PdbParser.hpp"
    3334
    3435#ifdef HAVE_TESTRUNNER
     
    6364  World::getInstance();
    6465
     66  parser = new FormatParser<pdb>();
     67
    6568  setVerbosity(2);
    6669
     
    7073}
    7174
    72 void ParserPdbUnitTest::tearDown() {
     75void ParserPdbUnitTest::tearDown()
     76{
     77  delete parser;
    7378  ChangeTracker::purgeInstance();
    7479  World::purgeInstance();
     
    8085  stringstream input;
    8186  input << waterPdb;
    82   PdbParser* testParser = new PdbParser();
    83   testParser->load(&input);
     87  parser->load(&input);
    8488  input.clear();
    8589
     
    8892  stringstream output;
    8993  std::vector<atom *> atoms = World::getInstance().getAllAtoms();
    90   testParser->save(&output, atoms);
     94  parser->save(&output, atoms);
    9195
    9296//  std::cout << "Save PDB is:" << std::endl;
     
    9498
    9599  input << output.str();
    96   PdbParser* testParser2 = new PdbParser();
    97   testParser2->load(&input);
     100  FormatParser<pdb>* parser2 = new FormatParser<pdb>();
     101  parser2->load(&input);
    98102
    99103  CPPUNIT_ASSERT_EQUAL(12, World::getInstance().numAtoms());
     104
     105  delete parser2;
    100106}
  • src/Parser/unittests/ParserPdbUnitTest.hpp

    rfa9d1d r360c8b  
    1313#endif
    1414
     15#include "Parser/PdbParser.hpp"
    1516
    1617#include <cppunit/extensions/HelperMacros.h>
     
    2829
    2930  void readwritePdbTest();
     31
     32private:
     33  FormatParser<pdb> *parser;
    3034};
    3135
  • src/Parser/unittests/ParserTremoloUnitTest.cpp

    rfa9d1d r360c8b  
    2727#include "Descriptors/AtomTypeDescriptor.hpp"
    2828#include "Element/element.hpp"
    29 #include "Parser/MpqcParser.hpp"
    30 #include "Parser/PdbParser.hpp"
    31 #include "Parser/PcpParser.hpp"
     29#include "Element/periodentafel.hpp"
    3230#include "Parser/TremoloParser.hpp"
    33 #include "Parser/XyzParser.hpp"
    34 #include "Element/periodentafel.hpp"
     31#include "Parser/ChangeTracker.hpp"
    3532#include "World.hpp"
    3633#include "WorldTime.hpp"
     
    8582  World::getInstance();
    8683
     84  parser = new FormatParser<tremolo>();
     85
    8786  // we need hydrogens and oxygens in the following tests
    8887  CPPUNIT_ASSERT(World::getInstance().getPeriode()->FindElement(1) != NULL);
     
    9089}
    9190
    92 void ParserTremoloUnitTest::tearDown() {
     91void ParserTremoloUnitTest::tearDown()
     92{
     93  delete parser;
    9394  ChangeTracker::purgeInstance();
    9495  World::purgeInstance();
     
    99100void ParserTremoloUnitTest::readTremoloPreliminaryCommentsTest() {
    100101  cout << "Testing the tremolo parser." << endl;
    101   TremoloParser* testParser = new TremoloParser();
    102102  stringstream input, output;
    103103
     
    105105  {
    106106    input << Tremolo_Atomdata1;
    107     testParser->load(&input);
    108     std::vector<atom *> atoms = World::getInstance().getAllAtoms();
    109     testParser->save(&output, atoms);
     107    parser->load(&input);
     108    std::vector<atom *> atoms = World::getInstance().getAllAtoms();
     109    parser->save(&output, atoms);
    110110//    std::cout << output.str() << std::endl;
    111111//    std::cout << Tremolo_Atomdata1 << std::endl;
     
    118118  {
    119119    input << Tremolo_Atomdata2;
    120     testParser->load(&input);
    121     std::vector<atom *> atoms = World::getInstance().getAllAtoms();
    122     testParser->save(&output, atoms);
     120    parser->load(&input);
     121    std::vector<atom *> atoms = World::getInstance().getAllAtoms();
     122    parser->save(&output, atoms);
    123123    std::cout << output.str() << std::endl;
    124124    CPPUNIT_ASSERT(output.str().find("hydrogen") != string::npos);
     
    129129  // Invalid key in Atomdata line
    130130  input << Tremolo_invalidkey;
    131   testParser->load(&input);
     131  parser->load(&input);
    132132  //TODO: prove invalidity
    133133  input.clear();
     
    135135
    136136void ParserTremoloUnitTest::readTremoloCoordinatesTest() {
    137   TremoloParser* testParser = new TremoloParser();
    138137  stringstream input;
    139138
    140139  // One simple data line
    141140  input << Tremolo_Atomdata2;
    142   testParser->load(&input);
     141  parser->load(&input);
    143142  CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->at(0) == 3.0);
    144143  input.clear();
     
    146145
    147146void ParserTremoloUnitTest::readTremoloVelocityTest() {
    148   TremoloParser* testParser = new TremoloParser();
    149147  stringstream input;
    150148
    151149  // One simple data line
    152150  input << Tremolo_velocity;
    153   testParser->load(&input);
     151  parser->load(&input);
    154152  CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->getAtomicVelocity()[0] == 3.0);
    155153  input.clear();
     
    157155
    158156void ParserTremoloUnitTest::readTremoloNeighborInformationTest() {
    159   TremoloParser* testParser = new TremoloParser();
    160157  stringstream input;
    161158
    162159  // Neighbor data
    163160  input << Tremolo_neighbours;
    164   testParser->load(&input);
     161  parser->load(&input);
    165162
    166163  CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms());
     
    171168
    172169void ParserTremoloUnitTest::readAndWriteTremoloImprDataInformationTest() {
    173   TremoloParser* testParser = new TremoloParser();
    174170  stringstream input, output;
    175171
     
    177173  {
    178174    input << Tremolo_improper;
    179     testParser->load(&input);
    180     std::vector<atom *> atoms = World::getInstance().getAllAtoms();
    181     testParser->save(&output, atoms);
     175    parser->load(&input);
     176    std::vector<atom *> atoms = World::getInstance().getAllAtoms();
     177    parser->save(&output, atoms);
    182178    CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms());
    183179    std::cout << output.str() << std::endl;
     
    189185
    190186void ParserTremoloUnitTest::readAndWriteTremoloTorsionInformationTest() {
    191   TremoloParser* testParser = new TremoloParser();
    192187  stringstream input, output;
    193188
     
    195190  {
    196191    input << Tremolo_torsion;
    197     testParser->load(&input);
    198     std::vector<atom *> atoms = World::getInstance().getAllAtoms();
    199     testParser->save(&output, atoms);
     192    parser->load(&input);
     193    std::vector<atom *> atoms = World::getInstance().getAllAtoms();
     194    parser->save(&output, atoms);
    200195    CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms());
    201196    std::cout << output.str() << std::endl;
     
    207202
    208203void ParserTremoloUnitTest::writeTremoloTest() {
    209   TremoloParser* testParser = new TremoloParser();
    210204  stringstream output;
    211205
     
    214208    atom* newAtom = World::getInstance().createAtom();
    215209    newAtom->setType(1);
    216     testParser->setFieldsForSave("x=3 u=3 F stress Id neighbors=5 imprData GroupMeasureTypeNo type extType name resName chainID resSeq occupancy tempFactor segID Charge charge GrpTypeNo torsion");
    217     std::vector<atom *> atoms = World::getInstance().getAllAtoms();
    218     testParser->save(&output, atoms);
     210    parser->setFieldsForSave("x=3 u=3 F stress Id neighbors=5 imprData GroupMeasureTypeNo type extType name resName chainID resSeq occupancy tempFactor segID Charge charge GrpTypeNo torsion");
     211    std::vector<atom *> atoms = World::getInstance().getAllAtoms();
     212    parser->save(&output, atoms);
    219213    CPPUNIT_ASSERT(output.str() == Tremolo_full);
    220214  }
     
    222216  cout << "testing the tremolo parser is done" << endl;
    223217}
     218
  • src/Parser/unittests/ParserTremoloUnitTest.hpp

    rfa9d1d r360c8b  
    1313#endif
    1414
     15#include "Parser/TremoloParser.hpp"
    1516
    1617#include <cppunit/extensions/HelperMacros.h>
     
    4041  void readAndWriteTremoloTorsionInformationTest();
    4142  void writeTremoloTest();
     43
     44private:
     45  FormatParser<tremolo> *parser;
    4246};
    4347
  • src/Parser/unittests/ParserXyzUnitTest.cpp

    rfa9d1d r360c8b  
    2424#include <cppunit/ui/text/TestRunner.h>
    2525
    26 #include "Parser/XyzParser.hpp"
    2726#include "World.hpp"
    2827#include "atom.hpp"
     
    3130#include "CodePatterns/Log.hpp"
    3231#include "Descriptors/AtomTypeDescriptor.hpp"
     32#include "Parser/ChangeTracker.hpp"
     33#include "Parser/XyzParser.hpp"
    3334
    3435#ifdef HAVE_TESTRUNNER
     
    6263  World::getInstance();
    6364
     65  parser = new FormatParser<xyz>();
     66
    6467  setVerbosity(2);
    6568
     
    6972}
    7073
    71 void ParserXyzUnitTest::tearDown() {
     74void ParserXyzUnitTest::tearDown()
     75{
     76  delete parser;
    7277  ChangeTracker::purgeInstance();
    7378  World::purgeInstance();
     
    7883void ParserXyzUnitTest::rewriteAnXyzTest() {
    7984  cout << "Testing the XYZ parser." << endl;
    80   XyzParser* testParser = new XyzParser();
    8185  stringstream input;
    8286  input << waterXyz;
    83   testParser->load(&input);
     87  parser->load(&input);
    8488  input.clear();
    8589
     
    9094    stringstream output;
    9195    std::vector<atom *> atoms = World::getInstance().getAllAtoms();
    92     testParser->save(&output, atoms);
     96    parser->save(&output, atoms);
    9397    input << output.str();
    94     testParser->load(&input);
     98    parser->load(&input);
    9599  }
    96100
     
    115119void ParserXyzUnitTest::readMultiXyzTest() {
    116120  cout << "Testing the multi time step XYZ parser." << endl;
    117   XyzParser* testParser = new XyzParser();
    118121  stringstream input;
    119122  input << waterMultiXyz;
    120   testParser->load(&input);
     123  parser->load(&input);
    121124  input.clear();
    122125
     
    130133
    131134void ParserXyzUnitTest::writeMultiXyzTest() {
    132   XyzParser* testParser = new XyzParser();
    133135  stringstream input;
    134136  input << waterMultiXyz;
    135   testParser->load(&input);
     137  parser->load(&input);
    136138  input.clear();
    137139
     
    143145    stringstream output;
    144146    std::vector<atom *> atoms = World::getInstance().getAllAtoms();
    145     testParser->save(&output, atoms);
     147    parser->save(&output, atoms);
    146148    input << output.str();
    147     testParser->load(&input);
     149    parser->load(&input);
    148150  }
    149151
  • src/Parser/unittests/ParserXyzUnitTest.hpp

    rfa9d1d r360c8b  
    1313#endif
    1414
     15#include "Parser/XyzParser.hpp"
    1516
    1617#include <cppunit/extensions/HelperMacros.h>
     
    3233  void readMultiXyzTest();
    3334  void writeMultiXyzTest();
     35
     36private:
     37  FormatParser<xyz> *parser;
    3438};
    3539
  • src/atom.cpp

    rfa9d1d r360c8b  
    201201};
    202202
     203void atom::OutputPsi3Line(ostream * const out, const Vector *center) const
     204{
     205  Vector recentered(getPosition());
     206  recentered -= *center;
     207  *out << "\t( " << getType()->getSymbol() << "\t" << recentered[0] << "\t" << recentered[1] << "\t" << recentered[2] << " )" << endl;
     208};
     209
    203210bool atom::Compare(const atom &ptr) const
    204211{
  • src/atom.hpp

    rfa9d1d r360c8b  
    113113   */
    114114  void OutputMPQCLine(ostream * const out, const Vector *center) const;
     115
     116  /** Outputs the Psi3 configuration line for this atom.
     117   * \param *out output stream
     118   * \param *center center of molecule subtracted from position
     119   * \param *AtomNo pointer to atom counter that is increased by one
     120   */
     121  void OutputPsi3Line(ostream * const out, const Vector *center) const;
    115122
    116123  /** Initialises the component number array.
  • src/moleculelist.cpp

    rfa9d1d r360c8b  
    626626//      atoms.resize((*ListRunner)->getAtomCount());
    627627//      std::copy((*ListRunner)->begin(), (*ListRunner)->end(), atoms.begin());
    628       FormatParserStorage::getInstance().getMpqc().save(&outfile, atoms);
     628      FormatParserStorage::getInstance().get(mpqc).save(&outfile, atoms);
    629629//      if ((intermediateResult = World::getInstance().getConfig()->SaveMPQC(FragmentName.c_str(), (*ListRunner))))
    630630        output << " done.";
  • src/unittests/BoxUnitTest.cpp

    rfa9d1d r360c8b  
    3939
    4040void BoxUnittest::setUp(){
     41  // failing asserts should be thrown
    4142  ASSERT_DO(Assert::Throw);
     43
    4244  unit = new RealSpaceMatrix;
    4345  unit->setIdentity();
  • src/unittests/FormulaUnitTest.cpp

    rfa9d1d r360c8b  
    3535CPPUNIT_TEST_SUITE_REGISTRATION( FormulaUnittest );
    3636
    37 void FormulaUnittest::setUp(){}
    38 void FormulaUnittest::tearDown(){
     37void FormulaUnittest::setUp()
     38{
     39  // failing asserts should be thrown
     40  ASSERT_DO(Assert::Throw);
     41}
     42
     43void FormulaUnittest::tearDown()
     44{
    3945  World::purgeInstance();
    4046}
  • tests/regression/Makefile.am

    rfa9d1d r360c8b  
    106106        $(srcdir)/Parser/Pdb/testsuite-parser-pdb-save.at \
    107107        $(srcdir)/Parser/Pdb/testsuite-parser-pdb-with-conects.at \
     108        $(srcdir)/Parser/Psi3/testsuite-parser-psi3-empty.at \
     109        $(srcdir)/Parser/Psi3/testsuite-parser-psi3-load.at \
     110        $(srcdir)/Parser/Psi3/testsuite-parser-psi3-save.at \
    108111        $(srcdir)/Parser/Tremolo/testsuite-parser-tremolo-empty.at \
    109112        $(srcdir)/Parser/Tremolo/testsuite-parser-tremolo-load.at \
  • tests/regression/Parser/testsuite-parser.at

    rfa9d1d r360c8b  
    3030m4_include([Parser/Pdb/testsuite-parser-pdb-load-various.at])
    3131
     32# parsing mpqc
     33m4_include([Parser/Psi3/testsuite-parser-psi3-empty.at])
     34m4_include([Parser/Psi3/testsuite-parser-psi3-load.at])
     35m4_include([Parser/Psi3/testsuite-parser-psi3-save.at])
     36
    3237# parsing tremolo
    3338m4_include([Parser/Tremolo/testsuite-parser-tremolo-empty.at])
Note: See TracChangeset for help on using the changeset viewer.