/* * TremoloParser.hpp * * Created on: Mar 2, 2010 * Author: metzler */ #ifndef TREMOLOPARSER_HPP_ #define TREMOLOPARSER_HPP_ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include #include "FormatParser.hpp" #include "FormatParserTrait.hpp" #include "FormatParserInterface.hpp" #include "FormatParser_common.hpp" #include "ParserTypes.hpp" #include "TremoloKey.hpp" #include "TremoloAtomInfoContainer.hpp" class molecule; // declaration of specialized FormatParserTrait template<> struct FormatParserTrait { //!> Name of the parser static const std::string name; //!> suffix of the files the parser understands to read and write static const std::string suffix; //!> ParserTypes enumeration for the parser static const enum ParserTypes type; }; /** * Loads a tremolo file into the World and saves the World as a tremolo file. */ template <> class FormatParser< tremolo > : virtual public FormatParserInterface, public FormatParser_common { public: FormatParser(); virtual ~FormatParser(); void load(std::istream* file); void save(std::ostream* file, const std::vector &atoms); void setFieldsForSave(std::string atomDataLine); void parseKnownTypes(std::istream &file); void createKnownTypesByIdentity(); void setAtomData(const std::string &atomdata_string); protected: void AtomInserted(atomId_t); void AtomRemoved(atomId_t); private: void readAtomDataLine(std::string line); void readAtomDataLine(std::string line, molecule *newmol); void parseAtomDataKeysLine(std::string line, int offset); void readNeighbors(std::stringstream* line, int numberOfNeighbors, int atomId); void processNeighborInformation(); void adaptImprData(); void adaptTorsion(); std::string adaptIdDependentDataString(std::string data); bool isUsedField(std::string fieldName); void writeNeighbors(std::ostream* file, int numberOfNeighbors, atom* currentAtom); void saveLine(std::ostream* file, atom* currentAtom); /** * Map to associate the elements with stuff in "type", e.g. OC2 -> O. */ std::map knownTypes; /** * Map to associate the known keys with numbers. */ std::map knownKeys; /** * Inverse Map to have a name to each known keys. */ std::map knownKeyNames; /** * Fields used in the tremolo file. */ std::vector usedFields; /** * Data which is currently not stored in atoms but was provided by the input * file. */ std::map additionalAtomData; /** * Default additional atom data. */ TremoloAtomInfoContainer defaultAdditionalData; /** * Maps original atom IDs received from the parsed file to atom IDs in the * world. */ std::map atomIdMap; }; #endif /* TREMOLOPARSER_HPP_ */