source: src/Parameters/StreamOperators.hpp@ f10b0c

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 f10b0c was f10b0c, checked in by Frederik Heber <heber@…>, 13 years ago

disastrously big and ugly commit

  • using new Parameter<T> classes:
    • Actions
    • Queries (all UIs)
  • TODO:
    • actions crash cause Value is unset
    • no query<BoxVector>
  • Property mode set to 100644
File size: 4.0 KB
Line 
1/*
2 * StreamOperators.hpp
3 *
4 * Created on: Apr 16, 2012
5 * Author: ankele
6 */
7
8#ifndef STREAMOPERATORS_HPP_
9#define STREAMOPERATORS_HPP_
10
11
12
13
14// include config.h
15#ifdef HAVE_CONFIG_H
16#include <config.h>
17#endif
18
19#include <string>
20#include <iosfwd>
21
22#include "LinearAlgebra/Vector.hpp"
23#include "LinearAlgebra/RealSpaceMatrix.hpp"
24#include "Box.hpp"
25#include "Element/element.hpp"
26#include "molecule.hpp"
27
28#include "CodePatterns/Assert.hpp"
29
30class Vector;
31class Box;
32class RealSpaceMatrix;
33class molecule;
34class element;
35
36inline std::istream& operator>>(std::istream& ist, Vector& m)
37{
38
39 std::string line;
40 getline(ist,line);
41
42 if (!line.empty() && line[0] == '(')
43 line.erase(0, 1);
44 if (!line.empty() && line[line.size() - 1] == ')')
45 line.erase(line.size() - 1, 1);
46 Vector temp_vector;
47
48 // dissect by ","
49 double coord = 0.;
50 int counter = 0;
51 std::string::iterator olditer = line.begin();
52 for(std::string::iterator iter = line.begin(); (iter != line.end()) && (counter != 3); ++iter) {
53 if ((*iter == ',') || (*iter == ' ')) {
54 std::istringstream stream(std::string(olditer, iter));
55
56 stream >> coord;
57
58 temp_vector[counter++] = coord;
59
60 olditer = iter + 1;
61 }
62 }
63 if ((olditer != line.begin()) && (counter != 3)) { // insert last part also
64
65 std::istringstream stream(std::string(olditer, line.end()));
66 stream >> coord;
67 temp_vector[counter++] = coord;
68 }
69 m = temp_vector;
70 return ist;
71};
72
73inline std::istream& operator>>(std::istream& ist, RealSpaceMatrix& m)
74{
75
76 std::string line;
77 getline(ist,line);
78
79 if (!line.empty() && line[0] == '(')
80 line.erase(0, 1);
81 if (!line.empty() && line[line.size() - 1] == ')')
82 line.erase(line.size() - 1, 1);
83 double temp[6];
84
85 // dissect by ","
86 double coord = 0.;
87 int counter = 0;
88 std::string::iterator olditer = line.begin();
89 for(std::string::iterator iter = line.begin(); (iter != line.end()) && (counter != 6); ++iter) {
90 if ((*iter == ',') || (*iter == ' ')) {
91 std::istringstream stream(std::string(olditer, iter));
92
93 stream >> coord;
94
95 temp[counter++] = coord;
96
97 olditer = iter + 1;
98 }
99 }
100 if ((olditer != line.begin()) && (counter != 6)) { // insert last part also
101
102 std::istringstream stream(std::string(olditer, line.end()));
103 stream >> coord;
104 temp[counter++] = coord;
105 }
106 m.set(0,0, temp[0]);
107 m.set(0,1, temp[1]);
108 m.set(0,2, temp[2]);
109 m.set(1,0, temp[1]);
110 m.set(1,1, temp[3]);
111 m.set(1,2, temp[4]);
112 m.set(2,0, temp[2]);
113 m.set(2,1, temp[4]);
114 m.set(2,2, temp[5]);
115 return ist;
116};
117
118inline std::istream& operator>>(std::istream& ist, Box& m)
119{
120 RealSpaceMatrix M;
121 ist >> M;
122 m.setM(M);
123 return ist;
124};
125
126
127inline std::istream& operator>>(std::istream& ist, const molecule* & m)
128{
129 std::cout << "=============== operator >> (istream, const element *) not implemented!\n";
130 ASSERT(0, "operator >> (istream, const element *) not implemented!");
131 return ist;
132}
133
134
135inline std::istream& operator>>(std::istream& ist, const element* & m)
136{
137 std::cout << "=============== operator >> (istream, const element *) not implemented!\n";
138 ASSERT(0, "operator >> (istream, const element *) not implemented!");
139 return ist;
140}
141
142
143inline std::istream& operator>>(std::istream& ist, std::vector<const molecule*> & m)
144{
145 std::cout << "=============== operator >> (istream, std::vector<const element *>) not implemented!\n";
146 ASSERT(0, "operator >> (istream, std::vector<const element *>) not implemented!");
147 return ist;
148}
149
150
151inline std::istream& operator>>(std::istream& ist, std::vector<const element*> & m)
152{
153 std::cout << "=============== operator >> (istream, std::vector<const element *>) not implemented!\n";
154 ASSERT(0, "operator >> (istream, std::vector<const element *>) not implemented!");
155 return ist;
156}
157
158
159inline std::istream& operator>>(std::istream& ist, std::vector<std::string> & m)
160{
161 std::cout << "=============== operator >> (istream, std::vector<std::string>) not implemented!\n";
162 ASSERT(0, "operator >> (istream, std::vector<std::string>) not implemented!");
163 return ist;
164}
165
166
167#endif /* STREAMOPERATORS_HPP_ */
Note: See TracBrowser for help on using the repository browser.