source: src/Formula.hpp@ 00bb38

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 00bb38 was 255829, checked in by Frederik Heber <heber@…>, 14 years ago

Removed Helpers.hpp, deleted Helpers.cpp and libMoleCuilderHelpers.la is history.

  • defs.cpp is now compiled into libmolecuilder.la.
  • ShapeUnitTest alone needs defs.cpp.
  • Most changes are removal of Helpers/helpers.hpp.
  • performCriticalExit() now inline function in Helpers/helpers.hpp.
  • also inclusion possible where performCriticalExit() is needed.
  • Helpers/helpers.hpp does not include defs.hpp anymore and this causes lots of missing Helpers/defs.hpp, CodePatterns/Log.hpp and alikes.
  • removed src/Helpers from configure.ac.
  • Property mode set to 100644
File size: 3.5 KB
Line 
1/*
2 * Formula.hpp
3 *
4 * Created on: Jul 21, 2010
5 * Author: crueger
6 */
7
8#ifndef FORMULA_HPP_
9#define FORMULA_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16
17#include <vector>
18#include <iosfwd>
19#include <iterator>
20
21#include "Exceptions/FormulaStringParseException.hpp"
22
23#include "types.hpp"
24
25#include "CodePatterns/enumeration.hpp"
26
27class element;
28
29
30class Formula
31{
32public:
33 typedef const element* key_type;
34 typedef unsigned int mapped_type;
35 typedef std::pair<key_type, mapped_type> value_type;
36 typedef std::vector<unsigned int> set_t;
37
38 template <class result_type>
39 class _iterator : public std::iterator <std::bidirectional_iterator_tag,
40 result_type>
41 {
42 public:
43 _iterator(set_t&);
44 _iterator(set_t&,size_t);
45 _iterator(const _iterator &rhs);
46 ~_iterator();
47 _iterator &operator=(const _iterator &);
48 bool operator==(const _iterator&);
49 bool operator!=(const _iterator&);
50 _iterator operator++();
51 _iterator operator++(int);
52 _iterator operator--();
53 _iterator operator--(int);
54 result_type operator*();
55 result_type *operator->();
56 private:
57 set_t *set;
58 size_t pos; // cannot use an iterator, because we need a position to access the element
59 };
60
61 typedef _iterator<value_type> iterator;
62 typedef _iterator<const value_type> const_iterator;
63
64 Formula();
65 Formula(const std::string&);
66 Formula(const Formula&);
67 virtual ~Formula();
68
69 Formula &operator=(const Formula&);
70
71 std::string toString() const;
72 void fromString(const std::string&) throw(FormulaStringParseException);
73 bool checkOut(std::ostream*) const;
74
75 unsigned int getElementCount() const;
76 bool hasElement(key_type) const;
77 bool hasElement(atomicNumber_t) const;
78 bool hasElement(const std::string&) const;
79
80 void operator+=(key_type);
81 void operator+=(atomicNumber_t);
82 void operator+=(const std::string&);
83
84 void operator-=(key_type);
85 void operator-=(atomicNumber_t);
86 void operator-=(const std::string&);
87
88 void addElements(key_type,unsigned int);
89 void addElements(atomicNumber_t,unsigned int);
90 void addElements(const std::string&,unsigned int);
91
92 void addFormula(const Formula&,unsigned int);
93
94 enumeration<key_type> enumerateElements() const;
95
96 // only const versions, because someone might try to increment a previously
97 // not set element
98 const unsigned int operator[](key_type) const;
99 const unsigned int operator[](atomicNumber_t) const;
100 const unsigned int operator[](std::string) const;
101
102 bool operator==(const Formula&) const;
103 bool operator!=(const Formula&) const;
104
105 iterator begin();
106 const_iterator begin() const;
107 iterator end();
108 const_iterator end() const;
109
110 void clear();
111
112private:
113 void parseFromString(std::string::const_iterator&,std::string::const_iterator&,char) throw(FormulaStringParseException);
114 int parseMaybeNumber(std::string::const_iterator &it,std::string::const_iterator &end) throw(FormulaStringParseException);
115 // this contains all counts of elements in the formula
116 // the size of the actual structure might be used in comparisons
117 // so be sure not to keep any zero elements at the end
118 // e.g. {5;4;0;0;0;2;1} or {0;1;0;0;2} are ok, but {1;2;3;0;0;0} is bad
119 set_t elementCounts;
120 unsigned int numElements;
121};
122
123std::ostream &operator<<(std::ostream&,const Formula&);
124
125#endif /* FORMULA_HPP_ */
Note: See TracBrowser for help on using the repository browser.