source: src/Descriptors/SelectiveIterator_impl.hpp@ ad011c

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 ad011c was 952f38, checked in by Frederik Heber <heber@…>, 14 years ago

created LibMolecuilderHelpers.

  • is shared
  • renamed log.[ch]pp -> Log.[ch]pp
  • renamed verbose.[ch]pp -> Verbose.[ch]pp
  • renamed info.[ch]pp -> Info.[ch]pp
  • contains: Assert, MemDebug, Log, logger, errorlogger, Verbose, Info
  • had to change includes practically everywhere.
  • Property mode set to 100644
File size: 4.8 KB
Line 
1/*
2 * SelectiveIterator_impl.hpp
3 *
4 * Created on: Mar 17, 2010
5 * Author: crueger
6 */
7
8#ifndef SELECTIVEITERATOR_IMPL_HPP_
9#define SELECTIVEITERATOR_IMPL_HPP_
10
11#include "Helpers/helpers.hpp"
12
13template<class _Target,
14 class _Container,
15 class _Descriptor>
16SelectiveIterator<_Target,_Container,_Descriptor>::SelectiveIterator(_Descriptor _descr, _Container &_content) :
17 descr(_descr.get_impl()),
18 index(0),
19 content(_content)
20{
21 state = content.begin();
22 advanceState();
23}
24
25template<class _Target,
26 class _Container,
27 class _Descriptor>
28SelectiveIterator<_Target,_Container,_Descriptor>::SelectiveIterator(_Descriptor _descr, _Container &_content, SelectiveIterator<_Target,_Container,_Descriptor>::Iter _state) :
29 state(_state),
30 descr(_descr.get_impl()),
31 index(0),
32 content(_content)
33{
34 advanceState();
35}
36
37template<class _Target,
38 class _Container,
39 class _Descriptor>
40SelectiveIterator<_Target,_Container,_Descriptor>::SelectiveIterator(const SelectiveIterator<_Target,_Container,_Descriptor>& rhs) :
41 state(rhs.state),
42 descr(rhs.descr),
43 index(rhs.index),
44 content(rhs.content)
45 {}
46
47template<class _Target,
48 class _Container,
49 class _Descriptor>
50SelectiveIterator<_Target,_Container,_Descriptor>& SelectiveIterator<_Target,_Container,_Descriptor>::operator=(const SelectiveIterator<_Target,_Container,_Descriptor>& rhs)
51{
52 if(&rhs!=this){
53 state=rhs.state;
54 descr=rhs.descr;
55 index=rhs.index;
56 }
57 return *this;
58}
59
60template<class _Target,
61 class _Container,
62 class _Descriptor>
63SelectiveIterator<_Target,_Container,_Descriptor>&
64 SelectiveIterator<_Target,_Container,_Descriptor>::operator++(){
65 ++state;
66 ++index;
67 advanceState();
68 return *this;
69 }
70
71template<class _Target,
72 class _Container,
73 class _Descriptor>
74SelectiveIterator<_Target,_Container,_Descriptor> SelectiveIterator<_Target,_Container,_Descriptor>::operator++(int){
75 SelectiveIterator<_Target,_Container,_Descriptor> res = SelectiveIterator<_Target,_Container,_Descriptor>(*this);
76 ++(*this);
77 return res;
78 }
79
80template<class _Target,
81 class _Container,
82 class _Descriptor>
83bool
84 SelectiveIterator<_Target,_Container,_Descriptor>::operator==(const SelectiveIterator<_Target,_Container,_Descriptor>& rhs){
85 return state==rhs.state;
86 }
87
88template<class _Target,
89 class _Container,
90 class _Descriptor>
91bool
92 SelectiveIterator<_Target,_Container,_Descriptor>::operator!=(const SelectiveIterator<_Target,_Container,_Descriptor>& rhs){
93 return state!=rhs.state;
94 }
95
96template<class _Target,
97 class _Container,
98 class _Descriptor>
99typename SelectiveIterator<_Target,_Container,_Descriptor>::Target
100 SelectiveIterator<_Target,_Container,_Descriptor>::operator*(){
101 return _take<_Target,value_type>::get(*state);
102 }
103
104template<class _Target,
105 class _Container,
106 class _Descriptor>
107void
108 SelectiveIterator<_Target,_Container,_Descriptor>::advanceState(){
109 // go forward until we have a matching atom or the end is reached
110 while((state!=content.end()) && (!descr->predicate(*state))){
111 ++state;
112 ++index;
113 }
114 }
115
116template<class _Target,
117 class _Container,
118 class _Descriptor>
119int
120 SelectiveIterator<_Target,_Container,_Descriptor>::getCount(){
121 return index;
122 }
123
124
125#define CONSTRUCT_SELECTIVE_ITERATOR(_Target,_Container,_Descriptor) \
126 template SelectiveIterator<_Target,_Container,_Descriptor>::SelectiveIterator(_Descriptor, _Container&); \
127 template SelectiveIterator<_Target,_Container,_Descriptor>::SelectiveIterator(_Descriptor, _Container&, SelectiveIterator<_Target,_Container,_Descriptor>::Iter); \
128 template SelectiveIterator<_Target,_Container,_Descriptor>::SelectiveIterator(const SelectiveIterator<_Target,_Container,_Descriptor>&); \
129 template SelectiveIterator<_Target,_Container,_Descriptor>& SelectiveIterator<_Target,_Container,_Descriptor>::operator=(const SelectiveIterator<_Target,_Container,_Descriptor>&); \
130 template SelectiveIterator<_Target,_Container,_Descriptor>& SelectiveIterator<_Target,_Container,_Descriptor>::operator++(); \
131 template SelectiveIterator<_Target,_Container,_Descriptor> SelectiveIterator<_Target,_Container,_Descriptor>::operator++(int); \
132 template bool SelectiveIterator<_Target,_Container,_Descriptor>::operator==(const SelectiveIterator<_Target,_Container,_Descriptor>&); \
133 template bool SelectiveIterator<_Target,_Container,_Descriptor>::operator!=(const SelectiveIterator<_Target,_Container,_Descriptor>&); \
134 template SelectiveIterator<_Target,_Container,_Descriptor>::Target SelectiveIterator<_Target,_Container,_Descriptor>::operator*(); \
135 template int SelectiveIterator<_Target,_Container,_Descriptor>::getCount();
136
137#endif /* SELECTIVEITERATOR_IMPL_HPP_ */
Note: See TracBrowser for help on using the repository browser.