source: src/Parser/XmlParser.hpp@ c3ecde

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since c3ecde was 3d0892, checked in by Frederik Heber <heber@…>, 13 years ago

Added an additionalAtomInfo container to XmlParser.

  • this stores the parser-specific information such as charge, ...
  • Property mode set to 100644
File size: 3.5 KB
Line 
1/*
2 * XmlParser.hpp
3 *
4 * Created on: Mar 23, 2012
5 * Author: heber
6 */
7
8#ifndef XMLPARSER_HPP_
9#define XMLPARSER_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16#include <map>
17#include <string>
18
19#include "FormatParser.hpp"
20#include "FormatParserTrait.hpp"
21#include "FormatParserInterface.hpp"
22#include "FormatParser_common.hpp"
23#include "ParserTypes.hpp"
24
25#include "LinearAlgebra/RealSpaceMatrix.hpp"
26#include "LinearAlgebra/Vector.hpp"
27
28// declaration of specialized FormatParserTrait
29template<>
30struct FormatParserTrait<xml>
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
40class ParserXmlUnitTest;
41
42/**
43 * Parser for XYZ files.
44 */
45template <>
46class FormatParser< xml > : virtual public FormatParserInterface, public FormatParser_common
47{
48 //!> grant unit test access to private parts
49 friend class ParserXmlUnitTest;
50public:
51 FormatParser();
52 virtual ~FormatParser();
53 void load(std::istream* file);
54 void save(std::ostream* file, const std::vector<atom *> &atoms);
55
56protected:
57 void AtomInserted(atomId_t);
58 void AtomRemoved(atomId_t);
59
60private:
61 //!> structure that contains all information from the xml file
62 struct scafacos {
63 std::string name;
64 std::string description;
65 std::string reference_method;
66 double error_potential;
67 double error_field;
68 struct configuration {
69 Vector offset;
70 RealSpaceMatrix box;
71 bool periodicity[NDIM];
72 std::string epsilon;
73
74 struct particle {
75 Vector position;
76 double q;
77 double potential;
78 Vector field;
79
80 bool operator==(const particle &p) const;
81 bool operator!=(const particle &p) const {
82 return !((*this) == p);
83 }
84 };
85 std::vector<struct particle> p;
86
87 bool operator==(const configuration &c) const;
88 bool operator!=(const configuration &c) const {
89 return !((*this) == c);
90 }
91 } config;
92
93 bool operator==(const scafacos &s) const;
94 bool operator!=(const scafacos &s) const {
95 return !((*this) == s);
96 }
97 } data;
98
99 //!> additional parser-specific information for an atom.
100 struct additionalAtomInfo {
101 /** Default constructor for additionalAtomInfo.
102 *
103 * Sets all parser-specific values to zero.
104 */
105 additionalAtomInfo() :
106 charge(0.),
107 potential(0),
108 field(zeroVec)
109 {}
110
111 /** Default constructor for additionalAtomInfo.
112 *
113 */
114 additionalAtomInfo(double _charge, double _potential, const Vector& _field) :
115 charge(_charge),
116 potential(_potential),
117 field(_field)
118 {}
119
120 //!> charge of the atom
121 double charge;
122 //!> potential at position of atom
123 double potential;
124 //!> field at position of atom
125 Vector field;
126 };
127
128 //!> typedef for map to associate additional parser-specific information to each atom.
129 typedef std::map< atomId_t, additionalAtomInfo> AtomInfoMap_t;
130
131 //!> map to associate additional parser-specific information to each atom.
132 AtomInfoMap_t additionalAtomData;
133
134 //!> static instance with default additional atom information
135 static additionalAtomInfo defaultAtomInfo;
136
137 /** Getter for additionalAtomInfo.
138 *
139 * @param _atom constant ref to atom
140 * @return constant reference to additional atom info container,
141 * otherwise to default atom info
142 */
143 const additionalAtomInfo& getAtomData(const atom &_atom) const;
144};
145
146
147#endif /* XMLPARSER_HPP_ */
Note: See TracBrowser for help on using the repository browser.