source: src/CodePatterns/Observer/ObservedContainer.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: 2.9 KB
Line 
1/*
2 * AtomSet.hpp
3 *
4 * Created on: Jul 8, 2010
5 * Author: crueger
6 */
7
8#ifndef OBSERVEDCONTAINER_HPP_
9#define OBSERVEDCONTAINER_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16#include <iterator>
17#include <utility>
18
19#include "CodePatterns/Observer/ObservedIterator.hpp"
20#include "CodePatterns/Observer/UnobservedIterator.hpp"
21
22/**
23 * Forward to std::map<atomId_t,atom*> that allows production of observed and
24 * unobserved iterators to all atoms.
25 *
26 * Imported via typedef into class World. Defined here to avoid bloating of the
27 * World class
28 */
29template <class Container, class Iterator = ObservedIterator<Container> >
30class ObservedContainer
31{
32public:
33 typedef Container set_t;
34 // this iterator can be used for internal purposes...
35 // no lock used here
36 typedef typename set_t::iterator internal_iterator;
37 typedef typename std::reverse_iterator<internal_iterator> reverse_internal_iterator;
38
39 typedef Iterator iterator;
40 // typedefs for iterator structure
41 typedef typename set_t::const_iterator const_iterator;
42 typedef typename std::reverse_iterator<iterator> reverse_iterator;
43 typedef typename std::reverse_iterator<const_iterator> const_reverse_iterator;
44
45 // some more typedefs for STL-Structure
46 typedef typename set_t::key_type key_type;
47 typedef typename set_t::mapped_type mapped_type;
48 typedef typename set_t::value_type value_type;
49 typedef typename set_t::key_compare key_compare;
50 typedef typename set_t::allocator_type allocator_type;
51
52 ObservedContainer(Observable*);
53 ObservedContainer(const ObservedContainer&);
54 virtual ~ObservedContainer();
55
56 // all the functions from STL-map (forwards to content)
57 ObservedContainer& operator=(const ObservedContainer&);
58
59 iterator begin();
60 const_iterator begin() const;
61 iterator end();
62 const_iterator end() const;
63 reverse_iterator rbegin();
64 const_reverse_iterator rbegin() const;
65 reverse_iterator rend();
66 const_reverse_iterator rend() const;
67
68 bool empty() const;
69 size_t size() const;
70 size_t max_size() const;
71
72 mapped_type &operator[](const key_type&);
73
74 std::pair<iterator,bool> insert (const value_type&);
75
76 size_t erase ( const key_type& x );
77 void clear();
78
79 iterator find ( const key_type& x );
80 const_iterator find ( const key_type& x ) const;
81
82 size_t count ( const key_type& x ) const;
83 internal_iterator begin_internal();
84 internal_iterator end_internal();
85 reverse_internal_iterator rbegin_internal();
86 reverse_internal_iterator rend_internal();
87
88 set_t &getContent();
89private:
90 set_t content;
91 Observable *obs;
92};
93
94#endif /* OBSERVEDCONTAINER_HPP_ */
Note: See TracBrowser for help on using the repository browser.