source: src/Descriptors/SelectiveIterator_impl.hpp@ 1a6bda

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 1a6bda was 56f73b, checked in by Frederik Heber <heber@…>, 14 years ago

Added config.h also to all header files, code check test ascertain this in the future.

  • as we want to use config.h to pass stuff such as MEMDEBUG, NDEBUG, LOG_OBSERVER, we have to make sure that it is present in each and every file.
  • split up CodeChecks/testsuite.at: each test has its own .at file.
  • 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 config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16
17#include "Helpers/helpers.hpp"
18
19template<class _Target,
20 class _Container,
21 class _Descriptor>
22SelectiveIterator<_Target,_Container,_Descriptor>::SelectiveIterator(_Descriptor _descr, _Container &_content) :
23 descr(_descr.get_impl()),
24 index(0),
25 content(_content)
26{
27 state = content.begin();
28 advanceState();
29}
30
31template<class _Target,
32 class _Container,
33 class _Descriptor>
34SelectiveIterator<_Target,_Container,_Descriptor>::SelectiveIterator(_Descriptor _descr, _Container &_content, SelectiveIterator<_Target,_Container,_Descriptor>::Iter _state) :
35 state(_state),
36 descr(_descr.get_impl()),
37 index(0),
38 content(_content)
39{
40 advanceState();
41}
42
43template<class _Target,
44 class _Container,
45 class _Descriptor>
46SelectiveIterator<_Target,_Container,_Descriptor>::SelectiveIterator(const SelectiveIterator<_Target,_Container,_Descriptor>& rhs) :
47 state(rhs.state),
48 descr(rhs.descr),
49 index(rhs.index),
50 content(rhs.content)
51 {}
52
53template<class _Target,
54 class _Container,
55 class _Descriptor>
56SelectiveIterator<_Target,_Container,_Descriptor>& SelectiveIterator<_Target,_Container,_Descriptor>::operator=(const SelectiveIterator<_Target,_Container,_Descriptor>& rhs)
57{
58 if(&rhs!=this){
59 state=rhs.state;
60 descr=rhs.descr;
61 index=rhs.index;
62 }
63 return *this;
64}
65
66template<class _Target,
67 class _Container,
68 class _Descriptor>
69SelectiveIterator<_Target,_Container,_Descriptor>&
70 SelectiveIterator<_Target,_Container,_Descriptor>::operator++(){
71 ++state;
72 ++index;
73 advanceState();
74 return *this;
75 }
76
77template<class _Target,
78 class _Container,
79 class _Descriptor>
80SelectiveIterator<_Target,_Container,_Descriptor> SelectiveIterator<_Target,_Container,_Descriptor>::operator++(int){
81 SelectiveIterator<_Target,_Container,_Descriptor> res = SelectiveIterator<_Target,_Container,_Descriptor>(*this);
82 ++(*this);
83 return res;
84 }
85
86template<class _Target,
87 class _Container,
88 class _Descriptor>
89bool
90 SelectiveIterator<_Target,_Container,_Descriptor>::operator==(const SelectiveIterator<_Target,_Container,_Descriptor>& rhs){
91 return state==rhs.state;
92 }
93
94template<class _Target,
95 class _Container,
96 class _Descriptor>
97bool
98 SelectiveIterator<_Target,_Container,_Descriptor>::operator!=(const SelectiveIterator<_Target,_Container,_Descriptor>& rhs){
99 return state!=rhs.state;
100 }
101
102template<class _Target,
103 class _Container,
104 class _Descriptor>
105typename SelectiveIterator<_Target,_Container,_Descriptor>::Target
106 SelectiveIterator<_Target,_Container,_Descriptor>::operator*(){
107 return _take<_Target,value_type>::get(*state);
108 }
109
110template<class _Target,
111 class _Container,
112 class _Descriptor>
113void
114 SelectiveIterator<_Target,_Container,_Descriptor>::advanceState(){
115 // go forward until we have a matching atom or the end is reached
116 while((state!=content.end()) && (!descr->predicate(*state))){
117 ++state;
118 ++index;
119 }
120 }
121
122template<class _Target,
123 class _Container,
124 class _Descriptor>
125int
126 SelectiveIterator<_Target,_Container,_Descriptor>::getCount(){
127 return index;
128 }
129
130
131#define CONSTRUCT_SELECTIVE_ITERATOR(_Target,_Container,_Descriptor) \
132 template SelectiveIterator<_Target,_Container,_Descriptor>::SelectiveIterator(_Descriptor, _Container&); \
133 template SelectiveIterator<_Target,_Container,_Descriptor>::SelectiveIterator(_Descriptor, _Container&, SelectiveIterator<_Target,_Container,_Descriptor>::Iter); \
134 template SelectiveIterator<_Target,_Container,_Descriptor>::SelectiveIterator(const SelectiveIterator<_Target,_Container,_Descriptor>&); \
135 template SelectiveIterator<_Target,_Container,_Descriptor>& SelectiveIterator<_Target,_Container,_Descriptor>::operator=(const SelectiveIterator<_Target,_Container,_Descriptor>&); \
136 template SelectiveIterator<_Target,_Container,_Descriptor>& SelectiveIterator<_Target,_Container,_Descriptor>::operator++(); \
137 template SelectiveIterator<_Target,_Container,_Descriptor> SelectiveIterator<_Target,_Container,_Descriptor>::operator++(int); \
138 template bool SelectiveIterator<_Target,_Container,_Descriptor>::operator==(const SelectiveIterator<_Target,_Container,_Descriptor>&); \
139 template bool SelectiveIterator<_Target,_Container,_Descriptor>::operator!=(const SelectiveIterator<_Target,_Container,_Descriptor>&); \
140 template SelectiveIterator<_Target,_Container,_Descriptor>::Target SelectiveIterator<_Target,_Container,_Descriptor>::operator*(); \
141 template int SelectiveIterator<_Target,_Container,_Descriptor>::getCount();
142
143#endif /* SELECTIVEITERATOR_IMPL_HPP_ */
Note: See TracBrowser for help on using the repository browser.