source: src/CodePatterns/Observer/ObservedContainer.hpp@ b09709

Last change on this file since b09709 was 9b8fa4, checked in by Frederik Heber <heber@…>, 14 years ago

Huge update of file structure to place installation header files into right folder.

  • The problem ist that we desire use as include "CodePatterns/...". For this to work, especially with the new Observer subfolder structure, it has been necessary to place all header files away from their source files into a distinct folder called CodePatterns. This emulates the later, after make install present structure.
  • essentially all source and header files had to be changed to adapt the include.
  • all Makefile.am's had to be changed.
  • nobase_ ... was removed such that header files are installed flat and not creating their subfolder along the process.
  • We placed Observer into its own convenience library and own folder Observer away from Patterns.

Some other changes:

  • FIX: MemDebug.hpp inclusion has been removed in all stubs.
  • Property mode set to 100644
File size: 2.8 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 <utility>
17#include "CodePatterns/Observer/ObservedIterator.hpp"
18
19/**
20 * Forward to std::map<atomId_t,atom*> that allows production of observed and
21 * unobserved iterators to all atoms.
22 *
23 * Imported via typedef into class World. Defined here to avoid bloating of the
24 * World class
25 */
26template <class Container>
27class ObservedContainer
28{
29public:
30 typedef Container set_t;
31 // this iterator can be used for internal purposes...
32 // no lock used here
33 typedef typename set_t::iterator internal_iterator;
34 typedef typename std::reverse_iterator<internal_iterator> reverse_internal_iterator;
35
36 // typedefs for iterator structure
37 typedef ObservedIterator<set_t> iterator;
38 typedef typename set_t::const_iterator const_iterator;
39 typedef typename std::reverse_iterator<iterator> reverse_iterator;
40 typedef typename std::reverse_iterator<const_iterator> const_reverse_iterator;
41
42 // some more typedefs for STL-Structure
43 typedef typename set_t::key_type key_type;
44 typedef typename set_t::mapped_type mapped_type;
45 typedef typename set_t::value_type value_type;
46 typedef typename set_t::key_compare key_compare;
47 typedef typename set_t::allocator_type allocator_type;
48
49 ObservedContainer(Observable*);
50 ObservedContainer(const ObservedContainer&);
51 virtual ~ObservedContainer();
52
53 // all the functions from STL-map (forwards to content)
54 ObservedContainer& operator=(const ObservedContainer&);
55
56 iterator begin();
57 const_iterator begin() const;
58 iterator end();
59 const_iterator end() const;
60 reverse_iterator rbegin();
61 const_reverse_iterator rbegin() const;
62 reverse_iterator rend();
63 const_reverse_iterator rend() const;
64
65 bool empty() const;
66 size_t size() const;
67 size_t max_size() const;
68
69 mapped_type &operator[](const key_type&);
70
71 std::pair<iterator,bool> insert (const value_type&);
72
73 size_t erase ( const key_type& x );
74 void clear();
75
76 iterator find ( const key_type& x );
77 const_iterator find ( const key_type& x ) const;
78
79 size_t count ( const key_type& x ) const;
80 internal_iterator begin_internal();
81 internal_iterator end_internal();
82 reverse_internal_iterator rbegin_internal();
83 reverse_internal_iterator rend_internal();
84
85 set_t &getContent();
86private:
87 set_t content;
88 Observable *obs;
89};
90
91#endif /* OBSERVEDCONTAINER_HPP_ */
Note: See TracBrowser for help on using the repository browser.