[b99bf3] | 1 | /*
|
---|
| 2 | * AtomSet_impl.hpp
|
---|
| 3 | *
|
---|
| 4 | * Created on: Jul 8, 2010
|
---|
| 5 | * Author: crueger
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #ifndef OBSERVEDCONTAINER_IMPL_HPP_
|
---|
| 9 | #define OBSERVEDCONTAINER_IMPL_HPP_
|
---|
| 10 |
|
---|
| 11 | #include "Patterns/ObservedContainer.hpp"
|
---|
| 12 |
|
---|
| 13 | template <class Container>
|
---|
| 14 | inline ObservedContainer<Container>::ObservedContainer(Observable* _obs) :
|
---|
| 15 | obs(_obs)
|
---|
| 16 | {}
|
---|
| 17 |
|
---|
| 18 | template <class Container>
|
---|
[d6e719] | 19 | inline ObservedContainer<Container>::ObservedContainer(const ObservedContainer<Container> &src) :
|
---|
[b99bf3] | 20 | content(src.content),
|
---|
| 21 | obs(src.obs)
|
---|
| 22 | {}
|
---|
| 23 |
|
---|
| 24 | template <class Container>
|
---|
| 25 | inline ObservedContainer<Container>::~ObservedContainer()
|
---|
| 26 | {}
|
---|
| 27 |
|
---|
| 28 | template <class Container>
|
---|
| 29 | inline
|
---|
| 30 | ObservedContainer<Container>&
|
---|
[d6e719] | 31 | ObservedContainer<Container>::operator=(const ObservedContainer<Container> &rhs){
|
---|
[b99bf3] | 32 | content=rhs.content;
|
---|
| 33 | return *this;
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | template <class Container>
|
---|
| 37 | inline
|
---|
| 38 | typename ObservedContainer<Container>::iterator
|
---|
| 39 | ObservedContainer<Container>::begin(){
|
---|
| 40 | return ObservedContainer<Container>::iterator(content.begin(),obs);
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | template <class Container>
|
---|
| 44 | inline
|
---|
| 45 | typename ObservedContainer<Container>::const_iterator
|
---|
| 46 | ObservedContainer<Container>::begin() const{
|
---|
| 47 | return content.begin();
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | template <class Container>
|
---|
| 51 | inline
|
---|
| 52 | typename ObservedContainer<Container>::iterator
|
---|
| 53 | ObservedContainer<Container>::end(){
|
---|
| 54 | return ObservedContainer<Container>::iterator(content.end(),obs);
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | template <class Container>
|
---|
| 58 | inline
|
---|
| 59 | typename ObservedContainer<Container>::const_iterator
|
---|
| 60 | ObservedContainer<Container>::end() const{
|
---|
| 61 | return content.end();
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | template <class Container>
|
---|
| 65 | inline
|
---|
| 66 | typename ObservedContainer<Container>::reverse_iterator
|
---|
| 67 | ObservedContainer<Container>::rbegin(){
|
---|
| 68 | return reverse_iterator(begin());
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | template <class Container>
|
---|
| 72 | inline
|
---|
| 73 | typename ObservedContainer<Container>::const_reverse_iterator
|
---|
| 74 | ObservedContainer<Container>::rbegin() const{
|
---|
| 75 | return const_reverse_iterator(begin());
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | template <class Container>
|
---|
| 79 | inline
|
---|
| 80 | typename ObservedContainer<Container>::reverse_iterator
|
---|
| 81 | ObservedContainer<Container>::rend(){
|
---|
| 82 | return reverse_iterator(end());
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | template <class Container>
|
---|
| 86 | inline
|
---|
| 87 | typename ObservedContainer<Container>::const_reverse_iterator
|
---|
| 88 | ObservedContainer<Container>::rend() const{
|
---|
| 89 | return const_reverse_iterator(end());
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 | template <class Container>
|
---|
| 93 | inline bool ObservedContainer<Container>::empty() const{
|
---|
| 94 | return content.empty();
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 | template <class Container>
|
---|
| 98 | inline size_t ObservedContainer<Container>::size() const{
|
---|
| 99 | return content.size();
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | template <class Container>
|
---|
| 103 | inline size_t ObservedContainer<Container>::max_size() const{
|
---|
| 104 | return content.max_size();
|
---|
| 105 | }
|
---|
| 106 |
|
---|
| 107 | template <class Container>
|
---|
| 108 | inline
|
---|
| 109 | typename ObservedContainer<Container>::mapped_type &
|
---|
| 110 | ObservedContainer<Container>::operator[](const key_type &key){
|
---|
| 111 | return content[key];
|
---|
| 112 | }
|
---|
| 113 |
|
---|
| 114 | template <class Container>
|
---|
| 115 | inline
|
---|
| 116 | std::pair<typename ObservedContainer<Container>::iterator,bool>
|
---|
| 117 | ObservedContainer<Container>::insert (const value_type &value){
|
---|
| 118 | std::pair<typename set_t::iterator,bool> res = content.insert(value);
|
---|
| 119 | return std::make_pair(iterator(res.first,obs),res.second);
|
---|
| 120 | }
|
---|
| 121 |
|
---|
| 122 | template <class Container>
|
---|
| 123 | inline size_t ObservedContainer<Container>::erase ( const key_type& x ){
|
---|
| 124 | return content.erase(x);
|
---|
| 125 | }
|
---|
| 126 |
|
---|
| 127 | template <class Container>
|
---|
| 128 | inline void ObservedContainer<Container>::clear(){
|
---|
| 129 | content.clear();
|
---|
| 130 | }
|
---|
| 131 |
|
---|
| 132 | template <class Container>
|
---|
| 133 | inline
|
---|
| 134 | typename ObservedContainer<Container>::iterator
|
---|
| 135 | ObservedContainer<Container>::find ( const key_type& x ){
|
---|
| 136 | return iterator(content.find(x),obs);
|
---|
| 137 | }
|
---|
| 138 |
|
---|
| 139 | template <class Container>
|
---|
| 140 | inline
|
---|
| 141 | typename ObservedContainer<Container>::const_iterator
|
---|
| 142 | ObservedContainer<Container>::find ( const key_type& x ) const{
|
---|
| 143 | return content.find(x);
|
---|
| 144 | }
|
---|
| 145 |
|
---|
| 146 | template <class Container>
|
---|
| 147 | inline size_t ObservedContainer<Container>::count ( const key_type& x ) const{
|
---|
| 148 | return content.count(x);
|
---|
| 149 | }
|
---|
| 150 |
|
---|
| 151 | /************ Unprotected access ***************/
|
---|
| 152 |
|
---|
| 153 | template <class Container>
|
---|
| 154 | inline
|
---|
| 155 | typename ObservedContainer<Container>::internal_iterator
|
---|
| 156 | ObservedContainer<Container>::begin_internal(){
|
---|
| 157 | return content.begin();
|
---|
| 158 | }
|
---|
| 159 |
|
---|
| 160 | template <class Container>
|
---|
| 161 | inline
|
---|
| 162 | typename ObservedContainer<Container>::internal_iterator
|
---|
| 163 | ObservedContainer<Container>::end_internal(){
|
---|
| 164 | return content.end();
|
---|
| 165 | }
|
---|
| 166 |
|
---|
| 167 | template <class Container>
|
---|
| 168 | inline
|
---|
| 169 | typename ObservedContainer<Container>::reverse_internal_iterator
|
---|
| 170 | ObservedContainer<Container>::rbegin_internal(){
|
---|
| 171 | return content.rbegin();
|
---|
| 172 | }
|
---|
| 173 |
|
---|
| 174 | template <class Container>
|
---|
| 175 | inline
|
---|
| 176 | typename ObservedContainer<Container>::reverse_internal_iterator
|
---|
| 177 | ObservedContainer<Container>::rend_internal(){
|
---|
| 178 | return content.rend();
|
---|
| 179 | }
|
---|
| 180 |
|
---|
| 181 | template <class Container>
|
---|
| 182 | inline
|
---|
| 183 | typename ObservedContainer<Container>::set_t &
|
---|
| 184 | ObservedContainer<Container>::getContent(){
|
---|
| 185 | return content;
|
---|
| 186 | }
|
---|
| 187 |
|
---|
[5f1d5b8] | 188 | /************ Explicit instantiation ***************/
|
---|
| 189 |
|
---|
| 190 | #define CONSTRUCT_OBSERVEDCONTAINER(name) \
|
---|
| 191 | template ObservedContainer< name >& ObservedContainer< name >::operator=(const ObservedContainer< name >&); \
|
---|
| 192 | template ObservedContainer< name >::iterator ObservedContainer< name >::begin(); \
|
---|
| 193 | template ObservedContainer< name >::const_iterator ObservedContainer< name >::begin() const; \
|
---|
| 194 | template ObservedContainer< name >::iterator ObservedContainer< name >::end(); \
|
---|
| 195 | template ObservedContainer< name >::const_iterator ObservedContainer< name >::end() const; \
|
---|
| 196 | template ObservedContainer< name >::reverse_iterator ObservedContainer< name >::rbegin(); \
|
---|
| 197 | template ObservedContainer< name >::const_reverse_iterator ObservedContainer< name >::rbegin() const; \
|
---|
| 198 | template ObservedContainer< name >::reverse_iterator ObservedContainer< name >::rend(); \
|
---|
| 199 | template ObservedContainer< name >::const_reverse_iterator ObservedContainer< name >::rend() const; \
|
---|
| 200 | template bool ObservedContainer< name >::empty() const; \
|
---|
| 201 | template size_t ObservedContainer< name >::size() const; \
|
---|
| 202 | template size_t ObservedContainer< name >::max_size() const; \
|
---|
| 203 | template ObservedContainer< name >::mapped_type &ObservedContainer< name >::operator[](const key_type&); \
|
---|
| 204 | template std::pair<ObservedContainer< name >::iterator,bool> ObservedContainer< name >::insert (const value_type&); \
|
---|
| 205 | template size_t ObservedContainer< name >::erase ( const key_type& x ); \
|
---|
| 206 | template void ObservedContainer< name >::clear(); \
|
---|
| 207 | template ObservedContainer< name >::iterator ObservedContainer< name >::find ( const key_type& x ); \
|
---|
| 208 | template ObservedContainer< name >::const_iterator ObservedContainer< name >::find ( const key_type& x ) const; \
|
---|
| 209 | template size_t ObservedContainer< name >::count ( const key_type& x ) const; \
|
---|
| 210 | template ObservedContainer< name >::internal_iterator ObservedContainer< name >::begin_internal(); \
|
---|
| 211 | template ObservedContainer< name >::reverse_internal_iterator ObservedContainer< name >::rbegin_internal(); \
|
---|
| 212 | template ObservedContainer< name >::internal_iterator ObservedContainer< name >::end_internal(); \
|
---|
| 213 | template ObservedContainer< name >::reverse_internal_iterator ObservedContainer< name >::rend_internal(); \
|
---|
| 214 |
|
---|
[b99bf3] | 215 | #endif /* OBSERVEDCONTAINER_IMPL_HPP_ */
|
---|