ACE_Active_Map_Manager< T > Class Template Reference

Define a map abstraction that associates system generated keys with user specified values. More...

#include <Active_Map_Manager_T.h>

Inheritance diagram for ACE_Active_Map_Manager< T >:

Inheritance graph
[legend]
Collaboration diagram for ACE_Active_Map_Manager< T >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_Active_Map_Manager_Key key_type
typedef T mapped_type
typedef ACE_Map_Entry< ACE_Active_Map_Manager_Key,
T > 
ENTRY
typedef ACE_Map_Iterator<
ACE_Active_Map_Manager_Key,
T, ACE_Null_Mutex
ITERATOR
typedef ACE_Map_Reverse_Iterator<
ACE_Active_Map_Manager_Key,
T, ACE_Null_Mutex
REVERSE_ITERATOR
typedef ENTRY entry
typedef ITERATOR iterator
typedef REVERSE_ITERATOR reverse_iterator

Public Member Functions

 ACE_Active_Map_Manager (ACE_Allocator *alloc=0)
 Initialize a with the .

 ACE_Active_Map_Manager (size_t size, ACE_Allocator *alloc=0)
 Initialize a with entries.

 ~ACE_Active_Map_Manager (void)
int open (size_t length=ACE_DEFAULT_MAP_SIZE, ACE_Allocator *alloc=0)
 Initialize a with size .

int close (void)
int bind (const T &value, ACE_Active_Map_Manager_Key &key)
int bind (const T &value)
int bind (ACE_Active_Map_Manager_Key &key, T *&internal_value)
int rebind (const ACE_Active_Map_Manager_Key &key, const T &value)
int rebind (const ACE_Active_Map_Manager_Key &key, const T &value, T &old_value)
int rebind (const ACE_Active_Map_Manager_Key &key, const T &value, ACE_Active_Map_Manager_Key &old_key, T &old_value)
int find (const ACE_Active_Map_Manager_Key &key, T &value) const
 Locate associated with .

int find (const ACE_Active_Map_Manager_Key &key) const
 Is in the map?

int find (const ACE_Active_Map_Manager_Key &key, T *&internal_value) const
int unbind (const ACE_Active_Map_Manager_Key &key)
 Remove from the map.

int unbind (const ACE_Active_Map_Manager_Key &key, T &value)
int unbind (const ACE_Active_Map_Manager_Key &key, T *&internal_value)
size_t current_size (void) const
 Return the current size of the map.

size_t total_size (void) const
 Return the total size of the map.

void dump (void) const
 Dump the state of an object.

ACE_Map_Iterator< ACE_Active_Map_Manager_Key,
T, ACE_Null_Mutex
begin (void)
 Return forward iterator.

ACE_Map_Iterator< ACE_Active_Map_Manager_Key,
T, ACE_Null_Mutex
end (void)
ACE_Map_Reverse_Iterator<
ACE_Active_Map_Manager_Key,
T, ACE_Null_Mutex
rbegin (void)
 Return reverse iterator.

ACE_Map_Reverse_Iterator<
ACE_Active_Map_Manager_Key,
T, ACE_Null_Mutex
rend (void)

Static Public Member Functions

const ACE_Active_Map_Manager_Key npos (void)
 Returns a key that cannot be found in the map.


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.


Protected Types

typedef ACE_Map_Manager< ACE_Active_Map_Manager_Key,
T, ACE_Null_Mutex
ACE_AMM_BASE
 Private base class.


Private Member Functions

void operator= (const ACE_Active_Map_Manager< T > &)
 ACE_Active_Map_Manager (const ACE_Active_Map_Manager< T > &)

Detailed Description

template<class T>
class ACE_Active_Map_Manager< T >

Define a map abstraction that associates system generated keys with user specified values.

Since the key is system generated, searches are very fast and take a constant amount of time.

Definition at line 39 of file Active_Map_Manager_T.h.


Member Typedef Documentation

template<class T>
typedef ACE_Map_Manager<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex> ACE_Active_Map_Manager< T >::ACE_AMM_BASE [protected]
 

Private base class.

Definition at line 187 of file Active_Map_Manager_T.h.

Referenced by ACE_Active_Map_Manager< T >::ACE_Active_Map_Manager().

template<class T>
typedef ENTRY ACE_Active_Map_Manager< T >::entry
 

Definition at line 51 of file Active_Map_Manager_T.h.

template<class T>
typedef ACE_Map_Entry<ACE_Active_Map_Manager_Key, T> ACE_Active_Map_Manager< T >::ENTRY
 

Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.

Definition at line 47 of file Active_Map_Manager_T.h.

template<class T>
typedef ITERATOR ACE_Active_Map_Manager< T >::iterator
 

Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.

Definition at line 52 of file Active_Map_Manager_T.h.

template<class T>
typedef ACE_Map_Iterator<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex> ACE_Active_Map_Manager< T >::ITERATOR
 

Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.

Definition at line 48 of file Active_Map_Manager_T.h.

template<class T>
typedef ACE_Active_Map_Manager_Key ACE_Active_Map_Manager< T >::key_type
 

Definition at line 44 of file Active_Map_Manager_T.h.

template<class T>
typedef T ACE_Active_Map_Manager< T >::mapped_type
 

Definition at line 45 of file Active_Map_Manager_T.h.

template<class T>
typedef REVERSE_ITERATOR ACE_Active_Map_Manager< T >::reverse_iterator
 

Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.

Definition at line 53 of file Active_Map_Manager_T.h.

template<class T>
typedef ACE_Map_Reverse_Iterator<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex> ACE_Active_Map_Manager< T >::REVERSE_ITERATOR
 

Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.

Definition at line 49 of file Active_Map_Manager_T.h.


Constructor & Destructor Documentation

template<class T>
ACE_INLINE ACE_Active_Map_Manager< T >::ACE_Active_Map_Manager ACE_Allocator alloc = 0  ) 
 

Initialize a with the .

Definition at line 229 of file Active_Map_Manager_T.inl.

References ACE_Active_Map_Manager< T >::ACE_AMM_BASE.

00230   : ACE_AMM_BASE (alloc)
00231 {
00232 }

template<class T>
ACE_INLINE ACE_Active_Map_Manager< T >::ACE_Active_Map_Manager size_t  size,
ACE_Allocator alloc = 0
 

Initialize a with entries.

Definition at line 235 of file Active_Map_Manager_T.inl.

References ACE_Active_Map_Manager< T >::ACE_AMM_BASE.

00237   : ACE_AMM_BASE (size,
00238                   alloc)
00239 {
00240 }

template<class T>
ACE_INLINE ACE_Active_Map_Manager< T >::~ACE_Active_Map_Manager void   ) 
 

Close down a and release dynamically allocated resources.

Definition at line 243 of file Active_Map_Manager_T.inl.

00244 {
00245 }

template<class T>
ACE_Active_Map_Manager< T >::ACE_Active_Map_Manager const ACE_Active_Map_Manager< T > &   )  [private]
 


Member Function Documentation

template<class T>
ACE_Map_Iterator< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex > ACE_Active_Map_Manager< T >::begin void   ) 
 

Return forward iterator.

Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.

Definition at line 288 of file Active_Map_Manager_T.inl.

00289 {
00290   return ACE_AMM_BASE::begin ();
00291 }

template<class T>
ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int ACE_Active_Map_Manager< T >::bind ACE_Active_Map_Manager_Key key,
T *&  internal_value
 

Reserves a slot in the internal structure and returns the key and a pointer to the value. User should place their into <*internal_value>. This method is useful in reducing the number of copies required in some cases. Note that is only a temporary pointer and will change when the map resizes. Therefore, the user should use the pointer immediately and not hold on to it.

Definition at line 8 of file Active_Map_Manager_T.inl.

References ACE_Map_Entry< ACE_Active_Map_Manager_Key, T >::ext_id_, ACE_Active_Map_Manager_Key::increment_slot_generation_count(), ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >::move_from_free_list_to_occupied_list(), ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >::next_free(), and ACE_Active_Map_Manager_Key::slot_index().

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 }

template<class T>
ACE_INLINE int ACE_Active_Map_Manager< T >::bind const T &  value  ) 
 

Add to the map. The user does not care about the corresponding key produced by the Active_Map_Manager.

Definition at line 54 of file Active_Map_Manager_T.inl.

References ACE_Active_Map_Manager< T >::bind().

00055 {
00056   ACE_Active_Map_Manager_Key key;
00057   return this->bind (value, key);
00058 }

template<class T>
ACE_INLINE int ACE_Active_Map_Manager< T >::bind const T &  value,
ACE_Active_Map_Manager_Key key
 

Add to the map, and the corresponding key produced by the Active_Map_Manager is returned through .

Definition at line 37 of file Active_Map_Manager_T.inl.

Referenced by ACE_Active_Map_Manager< T >::bind().

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 }

template<class T>
ACE_INLINE int ACE_Active_Map_Manager< T >::close void   ) 
 

Close down a and release dynamically allocated resources.

Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.

Definition at line 255 of file Active_Map_Manager_T.inl.

00256 {
00257   return ACE_AMM_BASE::close ();
00258 }

template<class T>
ACE_INLINE size_t ACE_Active_Map_Manager< T >::current_size void   )  const
 

Return the current size of the map.

Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.

Definition at line 261 of file Active_Map_Manager_T.inl.

00262 {
00263   return ACE_AMM_BASE::current_size ();
00264 }

template<class T>
ACE_INLINE void ACE_Active_Map_Manager< T >::dump void   )  const
 

Dump the state of an object.

Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.

Definition at line 280 of file Active_Map_Manager_T.inl.

00281 {
00282 #if defined (ACE_HAS_DUMP)
00283   ACE_AMM_BASE::dump ();
00284 #endif /* ACE_HAS_DUMP */
00285 }

template<class T>
ACE_INLINE ACE_Map_Iterator< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex > ACE_Active_Map_Manager< T >::end void   ) 
 

Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.

Definition at line 294 of file Active_Map_Manager_T.inl.

00295 {
00296   return ACE_AMM_BASE::end ();
00297 }

template<class T>
ACE_INLINE int ACE_Active_Map_Manager< T >::find const ACE_Active_Map_Manager_Key key,
T *&  internal_value
const
 

Locate associated with . The value is returned via and hence a copy is saved. Note that is only a temporary pointer and will change when the map resizes. Therefore, the user should use the pointer immediately and not hold on to it.

Definition at line 61 of file Active_Map_Manager_T.inl.

References ACE_Map_Entry< ACE_Active_Map_Manager_Key, T >::ext_id_, ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >::free_list_id(), ACE_Map_Entry< ACE_Active_Map_Manager_Key, T >::int_id_, ACE_Active_Map_Manager_Key::slot_generation(), and ACE_Active_Map_Manager_Key::slot_index().

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 }

template<class T>
ACE_INLINE int ACE_Active_Map_Manager< T >::find const ACE_Active_Map_Manager_Key key  )  const
 

Is in the map?

Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.

Definition at line 87 of file Active_Map_Manager_T.inl.

References ACE_Active_Map_Manager< T >::find().

00088 {
00089   T *internal_value = 0;
00090   return this->find (key,
00091                      internal_value);
00092 }

template<class T>
ACE_INLINE int ACE_Active_Map_Manager< T >::find const ACE_Active_Map_Manager_Key key,
T &  value
const
 

Locate associated with .

Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.

Definition at line 95 of file Active_Map_Manager_T.inl.

Referenced by ACE_Active_Map_Manager< T >::find(), ACE_Active_Map_Manager< T >::rebind(), and ACE_Active_Map_Manager< T >::unbind().

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 }

template<class T>
ACE_INLINE const ACE_Active_Map_Manager_Key ACE_Active_Map_Manager< T >::npos void   )  [static]
 

Returns a key that cannot be found in the map.

Definition at line 274 of file Active_Map_Manager_T.inl.

00275 {
00276   return ACE_Active_Map_Manager_Key (~0, ~0);
00277 }

template<class T>
ACE_INLINE int ACE_Active_Map_Manager< T >::open size_t  length = ACE_DEFAULT_MAP_SIZE,
ACE_Allocator alloc = 0
 

Initialize a with size .

Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.

Definition at line 248 of file Active_Map_Manager_T.inl.

00250 {
00251   return ACE_AMM_BASE::open (length, alloc);
00252 }

template<class T>
void ACE_Active_Map_Manager< T >::operator= const ACE_Active_Map_Manager< T > &   )  [private]
 

template<class T>
ACE_INLINE ACE_Map_Reverse_Iterator< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex > ACE_Active_Map_Manager< T >::rbegin void   ) 
 

Return reverse iterator.

Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.

Definition at line 300 of file Active_Map_Manager_T.inl.

00301 {
00302   return ACE_AMM_BASE::rbegin ();
00303 }

template<class T>
ACE_INLINE int ACE_Active_Map_Manager< T >::rebind const ACE_Active_Map_Manager_Key key,
const T &  value,
ACE_Active_Map_Manager_Key old_key,
T &  old_value
 

Reassociate with , storing the old key and value into the "out" parameter and . The function fails if is not in the map.

Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.

Definition at line 143 of file Active_Map_Manager_T.inl.

References ACE_Map_Entry< ACE_Active_Map_Manager_Key, T >::ext_id_, ACE_Active_Map_Manager< T >::find(), and ACE_Active_Map_Manager_Key::slot_index().

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 }

template<class T>
ACE_INLINE int ACE_Active_Map_Manager< T >::rebind const ACE_Active_Map_Manager_Key key,
const T &  value,
T &  old_value
 

Reassociate with , storing the old value into the "out" parameter . The function fails if is not in the map.

Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.

Definition at line 124 of file Active_Map_Manager_T.inl.

References ACE_Active_Map_Manager< T >::find(), ACE_Map_Entry< ACE_Active_Map_Manager_Key, T >::int_id_, and ACE_Active_Map_Manager_Key::slot_index().

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 }

template<class T>
ACE_INLINE int ACE_Active_Map_Manager< T >::rebind const ACE_Active_Map_Manager_Key key,
const T &  value
 

Reassociate with . The function fails if is not in the map.

Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.

Definition at line 109 of file Active_Map_Manager_T.inl.

References ACE_Active_Map_Manager< T >::find(), ACE_Map_Entry< ACE_Active_Map_Manager_Key, T >::int_id_, and ACE_Active_Map_Manager_Key::slot_index().

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 }

template<class T>
ACE_INLINE ACE_Map_Reverse_Iterator< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex > ACE_Active_Map_Manager< T >::rend void   ) 
 

Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.

Definition at line 306 of file Active_Map_Manager_T.inl.

00307 {
00308   return ACE_AMM_BASE::rend ();
00309 }

template<class T>
ACE_INLINE size_t ACE_Active_Map_Manager< T >::total_size void   )  const
 

Return the total size of the map.

Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.

Definition at line 267 of file Active_Map_Manager_T.inl.

00268 {
00269   return ACE_AMM_BASE::total_size ();
00270 }

template<class T>
ACE_INLINE int ACE_Active_Map_Manager< T >::unbind const ACE_Active_Map_Manager_Key key,
T *&  internal_value
 

Locate associated with . The value is returned via and hence a copy is saved. Note that is only a temporary pointer and will change when the map resizes or when this slot is reused. Therefore, the user should use the pointer immediately and not hold on to it.

Definition at line 166 of file Active_Map_Manager_T.inl.

References ACE_Map_Entry< ACE_Active_Map_Manager_Key, T >::ext_id_, ACE_Active_Map_Manager< T >::find(), ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >::move_from_occupied_list_to_free_list(), and ACE_Active_Map_Manager_Key::slot_index().

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 }

template<class T>
ACE_INLINE int ACE_Active_Map_Manager< T >::unbind const ACE_Active_Map_Manager_Key key,
T &  value
 

Remove from the map, and return the associated with .

Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.

Definition at line 204 of file Active_Map_Manager_T.inl.

References ACE_Active_Map_Manager< T >::unbind().

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 }

template<class T>
ACE_INLINE int ACE_Active_Map_Manager< T >::unbind const ACE_Active_Map_Manager_Key key  ) 
 

Remove from the map.

Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.

Definition at line 221 of file Active_Map_Manager_T.inl.

Referenced by ACE_Active_Map_Manager< T >::unbind().

00222 {
00223   T *internal_value;
00224   return this->unbind (key,
00225                        internal_value);
00226 }


Member Data Documentation

template<class T>
ACE_Active_Map_Manager< T >::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented from ACE_Map_Manager< ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex >.

Definition at line 182 of file Active_Map_Manager_T.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:19:04 2006 for ACE by doxygen 1.3.6