Active_Map_Manager_T.inl

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Active_Map_Manager_T.inl,v 4.2 2005/10/28 16:14:51 ossama Exp
00004 
00005 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00006 
00007 template <class T> ACE_INLINE int
00008 ACE_Active_Map_Manager<T>::bind (ACE_Active_Map_Manager_Key &key,
00009                                  T *&internal_value)
00010 {
00011   ACE_UINT32 slot_index;
00012   int result = this->next_free (slot_index);
00013 
00014   if (result == 0)
00015     {
00016       // Move from free list to occupied list
00017       this->move_from_free_list_to_occupied_list (slot_index);
00018 
00019       // Reset the key.
00020       this->search_structure_[slot_index].ext_id_.increment_slot_generation_count ();
00021       this->search_structure_[slot_index].ext_id_.slot_index (slot_index);
00022 
00023       // Copy the key for the user.
00024       key = this->search_structure_[slot_index].ext_id_;
00025 
00026       // This is where the user should place the value.
00027       internal_value = &this->search_structure_[slot_index].int_id_;
00028 
00029       // Update the current size.
00030       ++this->cur_size_;
00031     }
00032 
00033   return result;
00034 }
00035 
00036 template <class T> ACE_INLINE int
00037 ACE_Active_Map_Manager<T>::bind (const T &value,
00038                                  ACE_Active_Map_Manager_Key &key)
00039 {
00040   T *internal_value = 0;
00041   int result = this->bind (key,
00042                            internal_value);
00043 
00044   if (result == 0)
00045     {
00046       // Store new value.
00047       *internal_value = value;
00048     }
00049 
00050   return result;
00051 }
00052 
00053 template <class T> ACE_INLINE int
00054 ACE_Active_Map_Manager<T>::bind (const T &value)
00055 {
00056   ACE_Active_Map_Manager_Key key;
00057   return this->bind (value, key);
00058 }
00059 
00060 template <class T> ACE_INLINE int
00061 ACE_Active_Map_Manager<T>::find (const ACE_Active_Map_Manager_Key &key,
00062                                  T *&internal_value) const
00063 {
00064   ACE_UINT32 slot_index = key.slot_index ();
00065   ACE_UINT32 slot_generation = key.slot_generation ();
00066 
00067   if (slot_index > this->total_size_ ||
00068 #if defined (ACE_HAS_LAZY_MAP_MANAGER)
00069       this->search_structure_[slot_index].free_ ||
00070 #endif /* ACE_HAS_LAZY_MAP_MANAGER */
00071       this->search_structure_[slot_index].ext_id_.slot_generation () != slot_generation ||
00072       this->search_structure_[slot_index].ext_id_.slot_index () ==
00073                  (ACE_UINT32)this->free_list_id ())
00074     {
00075       return -1;
00076     }
00077   else
00078     {
00079       // This is where the user value is.
00080       internal_value = &this->search_structure_[slot_index].int_id_;
00081     }
00082 
00083   return 0;
00084 }
00085 
00086 template <class T> ACE_INLINE int
00087 ACE_Active_Map_Manager<T>::find (const ACE_Active_Map_Manager_Key &key) const
00088 {
00089   T *internal_value = 0;
00090   return this->find (key,
00091                      internal_value);
00092 }
00093 
00094 template <class T> ACE_INLINE int
00095 ACE_Active_Map_Manager<T>::find (const ACE_Active_Map_Manager_Key &key,
00096                                  T &value) const
00097 {
00098   T *internal_value = 0;
00099   int result = this->find (key,
00100                            internal_value);
00101 
00102   if (result == 0)
00103     value = *internal_value;
00104 
00105   return result;
00106 }
00107 
00108 template <class T> ACE_INLINE int
00109 ACE_Active_Map_Manager<T>::rebind (const ACE_Active_Map_Manager_Key &key,
00110                                    const T &value)
00111 {
00112   int result = this->find (key);
00113 
00114   if (result == 0)
00115     {
00116       // Store new value.
00117       this->search_structure_[key.slot_index ()].int_id_ = value;
00118     }
00119 
00120   return result;
00121 }
00122 
00123 template <class T> ACE_INLINE int
00124 ACE_Active_Map_Manager<T>::rebind (const ACE_Active_Map_Manager_Key &key,
00125                                    const T &value,
00126                                    T &old_value)
00127 {
00128   int result = this->find (key);
00129 
00130   if (result == 0)
00131     {
00132       // Copy old value.
00133       old_value = this->search_structure_[key.slot_index ()].int_id_;
00134 
00135       // Store new value.
00136       this->search_structure_[key.slot_index ()].int_id_ = value;
00137     }
00138 
00139   return result;
00140 }
00141 
00142 template <class T> ACE_INLINE int
00143 ACE_Active_Map_Manager<T>::rebind (const ACE_Active_Map_Manager_Key &key,
00144                                    const T &value,
00145                                    ACE_Active_Map_Manager_Key &old_key,
00146                                    T &old_value)
00147 {
00148   int result = this->find (key);
00149 
00150   if (result == 0)
00151     {
00152       // Copy old key.
00153       old_key = this->search_structure_[key.slot_index ()].ext_id_;
00154 
00155       // Copy old value.
00156       old_value = this->search_structure_[key.slot_index ()].int_id_;
00157 
00158       // Store new value.
00159       this->search_structure_[key.slot_index ()].int_id_ = value;
00160     }
00161 
00162   return result;
00163 }
00164 
00165 template <class T> ACE_INLINE int
00166 ACE_Active_Map_Manager<T>::unbind (const ACE_Active_Map_Manager_Key &key,
00167                                    T *&internal_value)
00168 {
00169   int result = this->find (key,
00170                            internal_value);
00171 
00172   if (result == 0)
00173     {
00174       ACE_UINT32 slot_index = key.slot_index ();
00175 
00176 #if defined (ACE_HAS_LAZY_MAP_MANAGER)
00177 
00178       //
00179       // In the case of lazy map managers, the movement of free slots
00180       // from the occupied list to the free list is delayed until we
00181       // run out of free slots in the free list.
00182       //
00183 
00184       this->search_structure_[slot_index].free_ = 1;
00185 
00186 #else
00187 
00188       // Move from occupied list to free list.
00189       this->move_from_occupied_list_to_free_list (slot_index);
00190 
00191 #endif /* ACE_HAS_LAZY_MAP_MANAGER */
00192 
00193       // Reset the slot_index.  This will tell us that this entry is free.
00194       this->search_structure_[slot_index].ext_id_.slot_index (this->free_list_id ());
00195 
00196       // Update the current size.
00197       --this->cur_size_;
00198     }
00199 
00200   return result;
00201 }
00202 
00203 template <class T> ACE_INLINE int
00204 ACE_Active_Map_Manager<T>::unbind (const ACE_Active_Map_Manager_Key &key,
00205                                    T &value)
00206 {
00207   T *internal_value;
00208   int result = this->unbind (key,
00209                              internal_value);
00210 
00211   if (result == 0)
00212     {
00213       // Copy old value.
00214       value = *internal_value;
00215     }
00216 
00217   return result;
00218 }
00219 
00220 template <class T> ACE_INLINE int
00221 ACE_Active_Map_Manager<T>::unbind (const ACE_Active_Map_Manager_Key &key)
00222 {
00223   T *internal_value;
00224   return this->unbind (key,
00225                        internal_value);
00226 }
00227 
00228 template <class T> ACE_INLINE
00229 ACE_Active_Map_Manager<T>::ACE_Active_Map_Manager (ACE_Allocator *alloc)
00230   : ACE_AMM_BASE (alloc)
00231 {
00232 }
00233 
00234 template <class T> ACE_INLINE
00235 ACE_Active_Map_Manager<T>::ACE_Active_Map_Manager (size_t size,
00236                                                    ACE_Allocator *alloc)
00237   : ACE_AMM_BASE (size,
00238                   alloc)
00239 {
00240 }
00241 
00242 template <class T> ACE_INLINE
00243 ACE_Active_Map_Manager<T>::~ACE_Active_Map_Manager (void)
00244 {
00245 }
00246 
00247 template <class T> ACE_INLINE int
00248 ACE_Active_Map_Manager<T>::open (size_t length,
00249                                  ACE_Allocator *alloc)
00250 {
00251   return ACE_AMM_BASE::open (length, alloc);
00252 }
00253 
00254 template <class T> ACE_INLINE int
00255 ACE_Active_Map_Manager<T>::close (void)
00256 {
00257   return ACE_AMM_BASE::close ();
00258 }
00259 
00260 template <class T> ACE_INLINE size_t
00261 ACE_Active_Map_Manager<T>::current_size (void) const
00262 {
00263   return ACE_AMM_BASE::current_size ();
00264 }
00265 
00266 template <class T> ACE_INLINE size_t
00267 ACE_Active_Map_Manager<T>::total_size (void) const
00268 {
00269   return ACE_AMM_BASE::total_size ();
00270 }
00271 
00272 /* static */
00273 template <class T> ACE_INLINE const ACE_Active_Map_Manager_Key
00274 ACE_Active_Map_Manager<T>::npos (void)
00275 {
00276   return ACE_Active_Map_Manager_Key (~0, ~0);
00277 }
00278 
00279 template <class T> ACE_INLINE void
00280 ACE_Active_Map_Manager<T>::dump (void) const
00281 {
00282 #if defined (ACE_HAS_DUMP)
00283   ACE_AMM_BASE::dump ();
00284 #endif /* ACE_HAS_DUMP */
00285 }
00286 
00287 template <class T> ACE_Map_Iterator<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex>
00288 ACE_Active_Map_Manager<T>::begin (void)
00289 {
00290   return ACE_AMM_BASE::begin ();
00291 }
00292 
00293 template <class T> ACE_INLINE ACE_Map_Iterator<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex>
00294 ACE_Active_Map_Manager<T>::end (void)
00295 {
00296   return ACE_AMM_BASE::end ();
00297 }
00298 
00299 template <class T> ACE_INLINE ACE_Map_Reverse_Iterator<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex>
00300 ACE_Active_Map_Manager<T>::rbegin (void)
00301 {
00302   return ACE_AMM_BASE::rbegin ();
00303 }
00304 
00305 template <class T> ACE_INLINE ACE_Map_Reverse_Iterator<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex>
00306 ACE_Active_Map_Manager<T>::rend (void)
00307 {
00308   return ACE_AMM_BASE::rend ();
00309 }
00310 
00311 ACE_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 09:41:45 2006 for ACE by doxygen 1.3.6