source: src/CodePatterns/Observer/UnobservedIterator.hpp@ 084729c

Action_Thermostats Add_AtomRandomPerturbation Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_ChronosMutex Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids_IntegrationTest JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg ThirdParty_MPQC_rebuilt_buildsystem TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes stable
Last change on this file since 084729c was 084729c, checked in by Frederik Heber <heber@…>, 8 years ago

Squashed 'ThirdParty/CodePatterns/' content from commit c1e1041

git-subtree-dir: ThirdParty/CodePatterns
git-subtree-split: c1e10418c454f98be2f43d93167642b0008428fc

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/*
2 * UnobservedIterator.hpp
3 *
4 * Created on: Dec 13, 2015
5 * Author: heber
6 */
7
8
9#ifndef UNOBSERVEDITERATOR_HPP_
10#define UNOBSERVEDITERATOR_HPP_
11
12// include config.h
13#ifdef HAVE_CONFIG_H
14#include <config.h>
15#endif
16
17#include <iterator>
18
19class Observable;
20
21/** This is a mock of UnobservedIterator that does not observe.
22 *
23 * The only thing we need to add here is another cstor to be signature compatible
24 * for use in ObservedContainer.
25 */
26template<class _Set>
27class UnobservedIterator
28 : public std::iterator<typename std::iterator_traits<typename _Set::iterator>::iterator_category,
29 typename std::iterator_traits<typename _Set::iterator>::value_type,
30 typename std::iterator_traits<typename _Set::iterator>::difference_type,
31 typename std::iterator_traits<typename _Set::iterator>::pointer,
32 typename std::iterator_traits<typename _Set::iterator>::reference>
33{
34public:
35 // Some typedefs to conform to STL-Iterator structure
36 typedef typename _Set::iterator _Iter;
37 typedef typename _Iter::value_type value_type;
38 typedef typename _Iter::difference_type difference_type;
39 typedef typename _Iter::pointer pointer;
40 typedef typename _Iter::reference reference;
41 typedef typename _Iter::iterator_category iterator_category;
42
43 UnobservedIterator()
44 {}
45
46 UnobservedIterator(_Iter iter,Observable *obs) :
47 iter(iter)
48 {}
49
50 UnobservedIterator(const UnobservedIterator &dest) :
51 iter(dest.iter)
52 {}
53
54 // standard Iterator methods
55 UnobservedIterator& operator=(const UnobservedIterator& dest){
56 if(&dest !=this)
57 iter = dest.iter;
58 return *this;
59 }
60
61 virtual ~UnobservedIterator() {}
62
63 UnobservedIterator& operator++() // prefix
64 {
65 ++iter;
66 return *this;
67 }
68
69 UnobservedIterator operator++(int) // postfix with the dummy int parameter
70 {
71 UnobservedIterator ret(*this);
72 ++(*this);
73 return ret;
74 }
75
76 UnobservedIterator& operator--() // prefix
77 {
78 --iter;
79 return *this;
80 }
81
82 UnobservedIterator operator--(int) // postfix with the dummy int parameter
83 {
84 UnobservedIterator ret(*this);
85 --(*this);
86 return ret;
87 }
88
89 bool operator==(const UnobservedIterator &rhs) const
90 {
91 return iter==rhs.iter;
92 }
93
94 bool operator!=(const UnobservedIterator &rhs) const
95 {
96 return iter!=rhs.iter;
97 }
98
99 /** Returns the value_type this iterator represents.
100 *
101 * @return value_type of iterator
102 */
103 value_type operator*() const {
104 return (*iter);
105 }
106
107 /** Returns pointer to value_type this iterator represents.
108 *
109 * @return pointer to value_type of iterator
110 */
111 value_type *operator->() const {
112 return &(*iter);
113 }
114
115 operator typename _Set::const_iterator() {
116 return iter;
117 }
118
119// bool operator==(const UnobservedIterator &dest)
120// { return static_cast<_Iter>(*this) == static_cast<_Iter>(dest); }
121//
122// bool operator!=(const UnobservedIterator &dest)
123// { return !(*this == dest); }
124
125private:
126 _Iter iter;
127};
128
129#endif /* UNOBSERVEDITERATOR_HPP_ */
Note: See TracBrowser for help on using the repository browser.