| [a80f419] | 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 |  | 
|---|
| [70672e3] | 11 | // include config.h | 
|---|
|  | 12 | #ifdef HAVE_CONFIG_H | 
|---|
|  | 13 | #include <config.h> | 
|---|
|  | 14 | #endif | 
|---|
|  | 15 |  | 
|---|
| [a80f419] | 16 | #include <utility> | 
|---|
| [9098f9] | 17 | #include "ObservedIterator.hpp" | 
|---|
| [a80f419] | 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 | */ | 
|---|
|  | 26 | template <class Container> | 
|---|
|  | 27 | class ObservedContainer | 
|---|
|  | 28 | { | 
|---|
|  | 29 | public: | 
|---|
|  | 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; | 
|---|
| [d3926b5] | 39 | typedef typename std::reverse_iterator<iterator>              reverse_iterator; | 
|---|
| [a80f419] | 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(); | 
|---|
|  | 86 | private: | 
|---|
|  | 87 | set_t content; | 
|---|
|  | 88 | Observable *obs; | 
|---|
|  | 89 | }; | 
|---|
|  | 90 |  | 
|---|
|  | 91 | #endif /* OBSERVEDCONTAINER_HPP_ */ | 
|---|