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

Active_Map_Manager_T.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Active_Map_Manager_T.h
00006  *
00007  *  $Id: Active_Map_Manager_T.h,v 1.1.1.3 2001/12/04 14:32:59 chad Exp $
00008  *
00009  *  @author Irfan Pyarali
00010  */
00011 //=============================================================================
00012 
00013 
00014 #ifndef ACE_ACTIVE_MAP_MANAGER_T_H
00015 #define ACE_ACTIVE_MAP_MANAGER_T_H
00016 #include "ace/pre.h"
00017 
00018 #include "ace/Map_Manager.h"
00019 #include "ace/Active_Map_Manager.h"
00020 
00021 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00022 # pragma once
00023 #endif /* ACE_LACKS_PRAGMA_ONCE */
00024 
00025 /**
00026  * @class ACE_Active_Map_Manager
00027  *
00028  * @brief Define a map abstraction that associates system generated
00029  * keys with user specified values.
00030  *
00031  * Since the key is system generated, searches are very fast and
00032  * take a constant amount of time.
00033  */
00034 template <class T>
00035 class ACE_Active_Map_Manager : public ACE_Map_Manager<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex>
00036 {
00037 public:
00038 
00039   // = Traits.
00040   typedef ACE_Active_Map_Manager_Key key_type;
00041   typedef T mapped_type;
00042 
00043   typedef ACE_Map_Entry<ACE_Active_Map_Manager_Key, T> ENTRY;
00044   typedef ACE_Map_Iterator<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex> ITERATOR;
00045   typedef ACE_Map_Reverse_Iterator<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex> REVERSE_ITERATOR;
00046 
00047   typedef ENTRY entry;
00048   typedef ITERATOR iterator;
00049   typedef REVERSE_ITERATOR reverse_iterator;
00050 
00051   // = Initialization and termination methods.
00052   /// Initialize a <Active_Map_Manager> with the <ACE_DEFAULT_MAP_SIZE>.
00053   ACE_Active_Map_Manager (ACE_Allocator *alloc = 0);
00054 
00055   /// Initialize a <Active_Map_Manager> with <size> entries.
00056   ACE_Active_Map_Manager (size_t size,
00057                           ACE_Allocator *alloc = 0);
00058 
00059   /// Close down a <Active_Map_Manager> and release dynamically
00060   /// allocated resources.
00061   ~ACE_Active_Map_Manager (void);
00062 
00063   /// Initialize a <Active_Map_Manager> with size <length>.
00064   int open (size_t length = ACE_DEFAULT_MAP_SIZE,
00065             ACE_Allocator *alloc = 0);
00066 
00067   /// Close down a <Active_Map_Manager> and release dynamically
00068   /// allocated resources.
00069   int close (void);
00070 
00071   /// Add <value> to the map, and the corresponding key produced by the
00072   /// Active_Map_Manager is returned through <key>.
00073   int bind (const T &value,
00074             ACE_Active_Map_Manager_Key &key);
00075 
00076   /// Add <value> to the map.  The user does not care about the
00077   /// corresponding key produced by the Active_Map_Manager.
00078   int bind (const T &value);
00079 
00080   /**
00081    * Reserves a slot in the internal structure and returns the key and
00082    * a pointer to the value.  User should place their <value> into
00083    * <*internal_value>.  This method is useful in reducing the number
00084    * of copies required in some cases.  Note that <internal_value> is
00085    * only a temporary pointer and will change when the map resizes.
00086    * Therefore, the user should use the pointer immediately and not
00087    * hold on to it.
00088    */
00089   int bind (ACE_Active_Map_Manager_Key &key,
00090             T *&internal_value);
00091 
00092   /// Reassociate <key> with <value>. The function fails if <key> is
00093   /// not in the map.
00094   int rebind (const ACE_Active_Map_Manager_Key &key,
00095               const T &value);
00096 
00097   /**
00098    * Reassociate <key> with <value>, storing the old value into the
00099    * "out" parameter <old_value>.  The function fails if <key> is not
00100    * in the map.
00101    */
00102   int rebind (const ACE_Active_Map_Manager_Key &key,
00103               const T &value,
00104               T &old_value);
00105 
00106   /**
00107    * Reassociate <key> with <value>, storing the old key and value
00108    * into the "out" parameter <old_key> and <old_value>.  The function
00109    * fails if <key> is not in the map.
00110    */
00111   int rebind (const ACE_Active_Map_Manager_Key &key,
00112               const T &value,
00113               ACE_Active_Map_Manager_Key &old_key,
00114               T &old_value);
00115 
00116   /// Locate <value> associated with <key>.
00117   int find (const ACE_Active_Map_Manager_Key &key,
00118             T &value) const;
00119 
00120   /// Is <key> in the map?
00121   int find (const ACE_Active_Map_Manager_Key &key) const;
00122 
00123   /**
00124    * Locate <value> associated with <key>.  The value is returned via
00125    * <internal_value> and hence a copy is saved.  Note that
00126    * <internal_value> is only a temporary pointer and will change when
00127    * the map resizes.  Therefore, the user should use the pointer
00128    * immediately and not hold on to it.
00129    */
00130   int find (const ACE_Active_Map_Manager_Key &key,
00131             T *&internal_value) const;
00132 
00133   // Creates a key.  User should place their <value> into
00134   // <*internal_value>.  This method is useful in reducing the number
00135   // of copies required in some cases.
00136 
00137   /// Remove <key> from the map.
00138   int unbind (const ACE_Active_Map_Manager_Key &key);
00139 
00140   /// Remove <key> from the map, and return the <value> associated with
00141   /// <key>.
00142   int unbind (const ACE_Active_Map_Manager_Key &key,
00143               T &value);
00144 
00145   /**
00146    * Locate <value> associated with <key>.  The value is returned via
00147    * <internal_value> and hence a copy is saved.  Note that
00148    * <internal_value> is only a temporary pointer and will change when
00149    * the map resizes or when this slot is reused.  Therefore, the user
00150    * should use the pointer immediately and not hold on to it.
00151    */
00152   int unbind (const ACE_Active_Map_Manager_Key &key,
00153               T *&internal_value);
00154 
00155   /// Return the current size of the map.
00156   size_t current_size (void) const;
00157 
00158   /// Return the total size of the map.
00159   size_t total_size (void) const;
00160 
00161   /// Returns a key that cannot be found in the map.
00162   static const ACE_Active_Map_Manager_Key npos (void);
00163 
00164   /// Dump the state of an object.
00165   void dump (void) const;
00166 
00167   // = STL styled iterator factory functions.
00168 
00169   /// Return forward iterator.
00170   ACE_Map_Iterator<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex> begin (void);
00171   ACE_Map_Iterator<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex> end (void);
00172 
00173   /// Return reverse iterator.
00174   ACE_Map_Reverse_Iterator<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex> rbegin (void);
00175   ACE_Map_Reverse_Iterator<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex> rend (void);
00176 
00177   /// Declare the dynamic allocation hooks.
00178   ACE_ALLOC_HOOK_DECLARE;
00179 
00180 protected:
00181 
00182   /// Private base class
00183   typedef ACE_Map_Manager<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex> ACE_AMM_BASE;
00184 
00185 private:
00186 
00187   // = Disallow these operations.
00188   ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Active_Map_Manager<T> &))
00189   ACE_UNIMPLEMENTED_FUNC (ACE_Active_Map_Manager (const ACE_Active_Map_Manager<T> &))
00190 };
00191 
00192 #if defined (__ACE_INLINE__)
00193 #include "ace/Active_Map_Manager_T.i"
00194 #endif /* __ACE_INLINE__ */
00195 
00196 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
00197 #include "ace/Active_Map_Manager_T.cpp"
00198 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
00199 
00200 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
00201 #pragma implementation ("Active_Map_Manager_T.cpp")
00202 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
00203 
00204 #include "ace/post.h"
00205 #endif /* ACE_ACTIVE_MAP_MANAGER_T_H */

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