Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Active_Map_Manager_T.i

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

Generated on Mon Jun 16 11:19:03 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002