Map_T.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Map_T.h
00006  *
00007  *  Map_T.h,v 4.25 2005/10/28 16:14:53 ossama Exp
00008  *
00009  *  @author Irfan Pyarali <irfan@cs.wustl.edu>
00010  */
00011 //=============================================================================
00012 
00013 #ifndef ACE_MAP_T_H
00014 #define ACE_MAP_T_H
00015 #include /**/ "ace/pre.h"
00016 
00017 #include "ace/Pair_T.h"
00018 #include "ace/Map_Manager.h"
00019 #include "ace/Hash_Map_Manager_T.h"
00020 #include "ace/Active_Map_Manager.h"
00021 
00022 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00023 # pragma once
00024 #endif /* ACE_LACKS_PRAGMA_ONCE */
00025 
00026 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00027 
00028 /**
00029  * @class ACE_Noop_Key_Generator
00030  *
00031  * @brief Defines a noop key generator.
00032  */
00033 template <class T>
00034 class ACE_Noop_Key_Generator
00035 {
00036 public:
00037 
00038   /// Functor method: generates a new key.
00039   int operator () (T &);
00040 };
00041 
00042 /**
00043  * @class ACE_Incremental_Key_Generator
00044  *
00045  * @brief Defines a simple incremental key generator.
00046  *
00047  * Generates a new key of type T by incrementing current
00048  * value. Requirements on T are:
00049  * - Constructor that accepts 0 in the constructor.
00050  * - Prefix increment.
00051  * - Assignment.
00052  * Note that a primitive types such as u_long, int, etc., are
00053  * suitable for this class.
00054  */
00055 template <class T>
00056 class ACE_Incremental_Key_Generator
00057 {
00058 public:
00059 
00060   /// Constructor.
00061   ACE_Incremental_Key_Generator (void);
00062 
00063   /// Functor method: generates a new key.
00064   int operator () (T &t);
00065 
00066   /// Returns the current value.
00067   const T& current_value (void) const;
00068 
00069 protected:
00070 
00071   /// Current value.
00072   T t_;
00073 };
00074 
00075 /**
00076  * @class ACE_Iterator_Impl
00077  *
00078  * @brief Defines a abstract iterator.
00079  *
00080  * Implementation to be provided by subclasses.
00081  */
00082 template <class T>
00083 class ACE_Iterator_Impl
00084 {
00085 public:
00086 
00087   /// Destructor.
00088   virtual ~ACE_Iterator_Impl (void);
00089 
00090   /// Clone.
00091   virtual ACE_Iterator_Impl<T> *clone (void) const = 0;
00092 
00093   /// Comparison.
00094   virtual int compare (const ACE_Iterator_Impl<T> &rhs) const = 0;
00095 
00096   /// Dereference.
00097   virtual T dereference (void) const = 0;
00098 
00099   /// Advance.
00100   virtual void plus_plus (void) = 0;
00101 
00102   /// Reverse.
00103   virtual void minus_minus (void) = 0;
00104 };
00105 
00106 /**
00107  * @class ACE_Reverse_Iterator_Impl
00108  *
00109  * @brief Defines a abstract reverse iterator.
00110  *
00111  * Implementation to be provided by subclasses.
00112  */
00113 template <class T>
00114 class ACE_Reverse_Iterator_Impl
00115 {
00116 public:
00117 
00118   /// Destructor.
00119   virtual ~ACE_Reverse_Iterator_Impl (void);
00120 
00121   /// Clone.
00122   virtual ACE_Reverse_Iterator_Impl<T> *clone (void) const = 0;
00123 
00124   /// Comparison.
00125   virtual int compare (const ACE_Reverse_Iterator_Impl<T> &rhs) const = 0;
00126 
00127   /// Dereference.
00128   virtual T dereference (void) const = 0;
00129 
00130   /// Advance.
00131   virtual void plus_plus (void) = 0;
00132 
00133   /// Reverse.
00134   virtual void minus_minus (void) = 0;
00135 };
00136 
00137 /**
00138  * @class ACE_Iterator
00139  *
00140  * @brief Defines the iterator interface.
00141  *
00142  * Implementation to be provided by forwarding.
00143  */
00144 template <class T>
00145 class ACE_Iterator
00146 {
00147 public:
00148 
00149   // = Traits.
00150   typedef T value_type;
00151   typedef ACE_Iterator_Impl<T> implementation;
00152 
00153   /// Constructor.
00154   ACE_Iterator (ACE_Iterator_Impl<T> *impl);
00155 
00156   /// Copy constructor.
00157   ACE_Iterator (const ACE_Iterator<T> &rhs);
00158 
00159   /// Destructor.
00160   ~ACE_Iterator (void);
00161 
00162   /// Assignment operator.
00163   ACE_Iterator<T> &operator= (const ACE_Iterator<T> &rhs);
00164 
00165   /// Comparison operators.
00166   bool operator== (const ACE_Iterator<T> &rhs) const;
00167   bool operator!= (const ACE_Iterator<T> &rhs) const;
00168 
00169   /// Dereference operator.
00170   T operator *() const;
00171 
00172   /// Prefix advance.
00173   ACE_Iterator<T> &operator++ (void);
00174 
00175   /// Postfix advance.
00176   ACE_Iterator<T> operator++ (int);
00177 
00178   /// Prefix reverse.
00179   ACE_Iterator<T> &operator-- (void);
00180 
00181   /// Postfix reverse.
00182   ACE_Iterator<T> operator-- (int);
00183 
00184   /// Accessor to implementation object.
00185   ACE_Iterator_Impl<T> &impl (void);
00186 
00187 protected:
00188 
00189   /// Implementation pointer.
00190   ACE_Iterator_Impl<T> *implementation_;
00191 };
00192 
00193 /**
00194  * @class ACE_Reverse_Iterator
00195  *
00196  * @brief Defines the reverse iterator interface.
00197  *
00198  * Implementation to be provided by forwarding.
00199  */
00200 template <class T>
00201 class ACE_Reverse_Iterator
00202 {
00203 public:
00204 
00205   // = Traits.
00206   typedef T value_type;
00207   typedef ACE_Reverse_Iterator_Impl<T> implementation;
00208 
00209   /// Constructor.
00210   ACE_Reverse_Iterator (ACE_Reverse_Iterator_Impl<T> *impl);
00211 
00212   /// Copy constructor.
00213   ACE_Reverse_Iterator (const ACE_Reverse_Iterator<T> &rhs);
00214 
00215   /// Destructor.
00216   ~ACE_Reverse_Iterator (void);
00217 
00218   /// Assignment operator.
00219   ACE_Reverse_Iterator<T> &operator= (const ACE_Reverse_Iterator<T> &rhs);
00220 
00221   /**
00222    * @name Comparison Operators
00223    *
00224    * The usual equality operators.
00225    */
00226   //@{
00227   bool operator== (const ACE_Reverse_Iterator<T> &rhs) const;
00228   bool operator!= (const ACE_Reverse_Iterator<T> &rhs) const;
00229   //@}
00230 
00231   /// Dereference operator.
00232   T operator *() const;
00233 
00234   /// Prefix advance.
00235   ACE_Reverse_Iterator<T> &operator++ (void);
00236 
00237   /// Postfix advance.
00238   ACE_Reverse_Iterator<T> operator++ (int);
00239 
00240   /// Prefix reverse.
00241   ACE_Reverse_Iterator<T> &operator-- (void);
00242 
00243   /// Postfix reverse.
00244   ACE_Reverse_Iterator<T> operator-- (int);
00245 
00246   /// Accessor to implementation object.
00247   ACE_Reverse_Iterator_Impl<T> &impl (void);
00248 
00249 protected:
00250 
00251   /// Implementation pointer.
00252   ACE_Reverse_Iterator_Impl<T> *implementation_;
00253 };
00254 
00255 /**
00256  * @class ACE_Map
00257  *
00258  * @brief Defines a map interface.
00259  *
00260  * Implementation to be provided by subclasses.
00261  */
00262 template <class KEY, class VALUE>
00263 class ACE_Map
00264 {
00265 public:
00266 
00267   // = Traits.
00268   typedef KEY
00269           key_type;
00270   typedef VALUE
00271           mapped_type;
00272   typedef ACE_Reference_Pair<const KEY, VALUE>
00273           value_type;
00274   typedef ACE_Iterator<value_type>
00275           iterator;
00276   typedef ACE_Reverse_Iterator<value_type>
00277           reverse_iterator;
00278   typedef ACE_Iterator_Impl<value_type>
00279           iterator_implementation;
00280   typedef ACE_Reverse_Iterator_Impl<value_type>
00281           reverse_iterator_implementation;
00282 
00283   /// Close down and release dynamically allocated resources.
00284   virtual ~ACE_Map (void);
00285 
00286   /// Initialize a <Map> with size <length>.
00287   virtual int open (size_t length = ACE_DEFAULT_MAP_SIZE,
00288                     ACE_Allocator *alloc = 0) = 0;
00289 
00290   /// Close down a <Map> and release dynamically allocated resources.
00291   virtual int close (void) = 0;
00292 
00293   /**
00294    * Add <key>/<value> pair to the map.  If <key> is already in the
00295    * map then no changes are made and 1 is returned.  Returns 0 on a
00296    * successful addition.  This function fails for maps that do not
00297    * allow user specified keys. <key> is an "in" parameter.
00298    */
00299   virtual int bind (const KEY &key,
00300                     const VALUE &value) = 0;
00301 
00302   /**
00303    * Add <key>/<value> pair to the map.  <key> is an "inout" parameter
00304    * and maybe modified/extended by the map to add additional
00305    * information.  To recover original key, call the <recover_key>
00306    * method.
00307    */
00308   virtual int bind_modify_key (const VALUE &value,
00309                                KEY &key) = 0;
00310 
00311   /**
00312    * Produce a key and return it through <key> which is an "out"
00313    * parameter.  For maps that do not naturally produce keys, the map
00314    * adapters will use the <KEY_GENERATOR> class to produce a key.
00315    * However, the users are responsible for not jeopardizing this key
00316    * production scheme by using user specified keys with keys produced
00317    * by the key generator.
00318    */
00319   virtual int create_key (KEY &key) = 0;
00320 
00321   /**
00322    * Add <value> to the map, and the corresponding key produced by the
00323    * Map is returned through <key> which is an "out" parameter.  For
00324    * maps that do not naturally produce keys, the map adapters will
00325    * use the <KEY_GENERATOR> class to produce a key.  However, the
00326    * users are responsible for not jeopardizing this key production
00327    * scheme by using user specified keys with keys produced by the key
00328    * generator.
00329    */
00330   virtual int bind_create_key (const VALUE &value,
00331                                KEY &key) = 0;
00332 
00333   /**
00334    * Add <value> to the map.  The user does not care about the
00335    * corresponding key produced by the Map. For maps that do not
00336    * naturally produce keys, the map adapters will use the
00337    * <KEY_GENERATOR> class to produce a key.  However, the users are
00338    * responsible for not jeopardizing this key production scheme by
00339    * using user specified keys with keys produced by the key
00340    * generator.
00341    */
00342   virtual int bind_create_key (const VALUE &value) = 0;
00343 
00344   /// Recovers the original key potentially modified by the map during
00345   /// <bind_modify_key>.
00346   virtual int recover_key (const KEY &modified_key,
00347                            KEY &original_key) = 0;
00348 
00349   /**
00350    * Reassociate <key> with <value>. The function fails if <key> is
00351    * not in the map for maps that do not allow user specified keys.
00352    * However, for maps that allow user specified keys, if the key is
00353    * not in the map, a new <key>/<value> association is created.
00354    */
00355   virtual int rebind (const KEY &key,
00356                       const VALUE &value) = 0;
00357 
00358   /**
00359    * Reassociate <key> with <value>, storing the old value into the
00360    * "out" parameter <old_value>.  The function fails if <key> is not
00361    * in the map for maps that do not allow user specified keys.
00362    * However, for maps that allow user specified keys, if the key is
00363    * not in the map, a new <key>/<value> association is created.
00364    */
00365   virtual int rebind (const KEY &key,
00366                       const VALUE &value,
00367                       VALUE &old_value) = 0;
00368 
00369   /**
00370    * Reassociate <key> with <value>, storing the old key and value
00371    * into the "out" parameters <old_key> and <old_value>.  The
00372    * function fails if <key> is not in the map for maps that do not
00373    * allow user specified keys.  However, for maps that allow user
00374    * specified keys, if the key is not in the map, a new <key>/<value>
00375    * association is created.
00376    */
00377   virtual int rebind (const KEY &key,
00378                       const VALUE &value,
00379                       KEY &old_key,
00380                       VALUE &old_value) = 0;
00381 
00382   /**
00383    * Associate <key> with <value> if and only if <key> is not in the
00384    * map.  If <key> is already in the map, then the <value> parameter
00385    * is overwritten with the existing value in the map. Returns 0 if a
00386    * new <key>/<value> association is created.  Returns 1 if an
00387    * attempt is made to bind an existing entry.  This function fails
00388    * for maps that do not allow user specified keys.
00389    */
00390   virtual int trybind (const KEY &key,
00391                        VALUE &value) = 0;
00392 
00393   /// Locate <value> associated with <key>.
00394   virtual int find (const KEY &key,
00395                     VALUE &value) = 0;
00396 
00397   /// Is <key> in the map?
00398   virtual int find (const KEY &key) = 0;
00399 
00400   /// Remove <key> from the map.
00401   virtual int unbind (const KEY &key) = 0;
00402 
00403   /// Remove <key> from the map, and return the <value> associated with
00404   /// <key>.
00405   virtual int unbind (const KEY &key,
00406                       VALUE &value) = 0;
00407 
00408   /// Return the current size of the map.
00409   virtual size_t current_size (void) const = 0;
00410 
00411   /// Return the total size of the map.
00412   virtual size_t total_size (void) const = 0;
00413 
00414   /// Dump the state of an object.
00415   virtual void dump (void) const = 0;
00416 
00417   // = STL styled iterator factory functions.
00418 
00419   /// Return forward iterator.
00420   iterator begin (void);
00421   iterator end (void);
00422 
00423   /// Return reverse iterator.
00424   reverse_iterator rbegin (void);
00425   reverse_iterator rend (void);
00426 
00427 protected:
00428 
00429   // = Protected no-op constructor.
00430   ACE_Map (void);
00431 
00432   /// Return forward iterator.
00433   virtual ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *begin_impl (void) = 0;
00434   virtual ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *end_impl (void) = 0;
00435 
00436   /// Return reverse iterator.
00437   virtual ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *rbegin_impl (void) = 0;
00438   virtual ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *rend_impl (void) = 0;
00439 
00440 private:
00441 
00442   // = Disallow these operations.
00443   ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Map<KEY, VALUE> &))
00444   ACE_UNIMPLEMENTED_FUNC (ACE_Map (const ACE_Map<KEY, VALUE> &))
00445 };
00446 
00447 /**
00448  * @class ACE_Map_Impl_Iterator_Adapter
00449  *
00450  * @brief Defines a iterator implementation for the Map_Impl class.
00451  *
00452  * Implementation to be provided by <IMPLEMENTATION>.
00453  */
00454 template <class T, class IMPLEMENTATION, class ENTRY>
00455 class ACE_Map_Impl_Iterator_Adapter : public ACE_Iterator_Impl<T>
00456 {
00457 public:
00458 
00459   // = Traits.
00460   typedef IMPLEMENTATION
00461           implementation;
00462 
00463   /// Constructor.
00464   ACE_Map_Impl_Iterator_Adapter (const IMPLEMENTATION &impl);
00465 
00466   /// Destructor.
00467   virtual ~ACE_Map_Impl_Iterator_Adapter (void);
00468 
00469   /// Clone.
00470   virtual ACE_Iterator_Impl<T> *clone (void) const;
00471 
00472   /// Comparison.
00473   virtual int compare (const ACE_Iterator_Impl<T> &rhs) const;
00474 
00475   /// Dereference.
00476   virtual T dereference (void) const;
00477 
00478   /// Advance.
00479   virtual void plus_plus (void);
00480 
00481   /// Reverse.
00482   virtual void minus_minus (void);
00483 
00484   /// Accessor to implementation object.
00485   IMPLEMENTATION &impl (void);
00486 
00487 protected:
00488 
00489   /// All implementation details are forwarded to this class.
00490   IMPLEMENTATION implementation_;
00491 };
00492 
00493 /**
00494  * @class ACE_Map_Impl_Reverse_Iterator_Adapter
00495  *
00496  * @brief Defines a reverse iterator implementation for the Map_Impl class.
00497  *
00498  * Implementation to be provided by IMPLEMENTATION.
00499  */
00500 template <class T, class IMPLEMENTATION, class ENTRY>
00501 class ACE_Map_Impl_Reverse_Iterator_Adapter : public ACE_Reverse_Iterator_Impl<T>
00502 {
00503 public:
00504 
00505   // = Traits.
00506   typedef IMPLEMENTATION
00507           implementation;
00508 
00509   /// Constructor.
00510   ACE_Map_Impl_Reverse_Iterator_Adapter (const IMPLEMENTATION &impl);
00511 
00512   /// Destructor.
00513   virtual ~ACE_Map_Impl_Reverse_Iterator_Adapter (void);
00514 
00515   /// Clone.
00516   virtual ACE_Reverse_Iterator_Impl<T> *clone (void) const;
00517 
00518   /// Comparison.
00519   virtual int compare (const ACE_Reverse_Iterator_Impl<T> &rhs) const;
00520 
00521   /// Dereference.
00522   virtual T dereference (void) const;
00523 
00524   /// Advance.
00525   virtual void plus_plus (void);
00526 
00527   /// Reverse.
00528   virtual void minus_minus (void);
00529 
00530   /// Accessor to implementation object.
00531   IMPLEMENTATION &impl (void);
00532 
00533 protected:
00534 
00535   /// All implementation details are forwarded to this class.
00536   IMPLEMENTATION implementation_;
00537 };
00538 
00539 /**
00540  * @class ACE_Map_Impl
00541  *
00542  * @brief Defines a map implementation.
00543  *
00544  * Implementation to be provided by <IMPLEMENTATION>.
00545  */
00546 template <class KEY, class VALUE, class IMPLEMENTATION, class ITERATOR, class REVERSE_ITERATOR, class ENTRY>
00547 class ACE_Map_Impl : public ACE_Map<KEY, VALUE>
00548 {
00549 public:
00550 
00551   // = Traits.
00552   typedef ACE_Map_Impl_Iterator_Adapter<ACE_TYPENAME ACE_Map<KEY, VALUE>::value_type, ITERATOR, ENTRY>
00553           iterator_impl;
00554   typedef ACE_Map_Impl_Reverse_Iterator_Adapter<ACE_TYPENAME ACE_Map<KEY, VALUE>::value_type, REVERSE_ITERATOR, ENTRY>
00555           reverse_iterator_impl;
00556 
00557   typedef IMPLEMENTATION
00558           implementation;
00559 
00560   // = Initialization and termination methods.
00561   /// Initialize with the <ACE_DEFAULT_MAP_SIZE>.
00562   ACE_Map_Impl (ACE_Allocator *alloc = 0);
00563 
00564   /// Initialize with <size> entries.  The <size> parameter is ignored
00565   /// by maps for which an initialize size does not make sense.
00566   ACE_Map_Impl (size_t size,
00567                 ACE_Allocator *alloc = 0);
00568 
00569   /// Close down and release dynamically allocated resources.
00570   virtual ~ACE_Map_Impl (void);
00571 
00572   /// Initialize a <Map> with size <length>.
00573   virtual int open (size_t length = ACE_DEFAULT_MAP_SIZE,
00574                     ACE_Allocator *alloc = 0);
00575 
00576   /// Close down a <Map> and release dynamically allocated resources.
00577   virtual int close (void);
00578 
00579   /**
00580    * Add <key>/<value> pair to the map.  If <key> is already in the
00581    * map then no changes are made and 1 is returned.  Returns 0 on a
00582    * successful addition.  This function fails for maps that do not
00583    * allow user specified keys. <key> is an "in" parameter.
00584    */
00585   virtual int bind (const KEY &key,
00586                     const VALUE &value);
00587 
00588   /**
00589    * Add <key>/<value> pair to the map.  <key> is an "inout" parameter
00590    * and maybe modified/extended by the map to add additional
00591    * information.  To recover original key, call the <recover_key>
00592    * method.
00593    */
00594   virtual int bind_modify_key (const VALUE &value,
00595                                KEY &key);
00596 
00597   /**
00598    * Produce a key and return it through <key> which is an "out"
00599    * parameter.  For maps that do not naturally produce keys, the map
00600    * adapters will use the <KEY_GENERATOR> class to produce a key.
00601    * However, the users are responsible for not jeopardizing this key
00602    * production scheme by using user specified keys with keys produced
00603    * by the key generator.
00604    */
00605   virtual int create_key (KEY &key);
00606 
00607   /**
00608    * Add <value> to the map, and the corresponding key produced by the
00609    * Map is returned through <key> which is an "out" parameter.  For
00610    * maps that do not naturally produce keys, the map adapters will
00611    * use the <KEY_GENERATOR> class to produce a key.  However, the
00612    * users are responsible for not jeopardizing this key production
00613    * scheme by using user specified keys with keys produced by the key
00614    * generator.
00615    */
00616   virtual int bind_create_key (const VALUE &value,
00617                                KEY &key);
00618 
00619   /**
00620    * Add <value> to the map.  The user does not care about the
00621    * corresponding key produced by the Map. For maps that do not
00622    * naturally produce keys, the map adapters will use the
00623    * <KEY_GENERATOR> class to produce a key.  However, the users are
00624    * responsible for not jeopardizing this key production scheme by
00625    * using user specified keys with keys produced by the key
00626    * generator.
00627    */
00628   virtual int bind_create_key (const VALUE &value);
00629 
00630   /// Recovers the original key potentially modified by the map during
00631   /// <bind_modify_key>.
00632   virtual int recover_key (const KEY &modified_key,
00633                            KEY &original_key);
00634 
00635   /**
00636    * Reassociate <key> with <value>. The function fails if <key> is
00637    * not in the map for maps that do not allow user specified keys.
00638    * However, for maps that allow user specified keys, if the key is
00639    * not in the map, a new <key>/<value> association is created.
00640    */
00641   virtual int rebind (const KEY &key,
00642                       const VALUE &value);
00643 
00644   /**
00645    * Reassociate <key> with <value>, storing the old value into the
00646    * "out" parameter <old_value>.  The function fails if <key> is not
00647    * in the map for maps that do not allow user specified keys.
00648    * However, for maps that allow user specified keys, if the key is
00649    * not in the map, a new <key>/<value> association is created.
00650    */
00651   virtual int rebind (const KEY &key,
00652                       const VALUE &value,
00653                       VALUE &old_value);
00654 
00655   /**
00656    * Reassociate <key> with <value>, storing the old key and value
00657    * into the "out" parameters <old_key> and <old_value>.  The
00658    * function fails if <key> is not in the map for maps that do not
00659    * allow user specified keys.  However, for maps that allow user
00660    * specified keys, if the key is not in the map, a new <key>/<value>
00661    * association is created.
00662    */
00663   virtual int rebind (const KEY &key,
00664                       const VALUE &value,
00665                       KEY &old_key,
00666                       VALUE &old_value);
00667 
00668   /**
00669    * Associate <key> with <value> if and only if <key> is not in the
00670    * map.  If <key> is already in the map, then the <value> parameter
00671    * is overwritten with the existing value in the map. Returns 0 if a
00672    * new <key>/<value> association is created.  Returns 1 if an
00673    * attempt is made to bind an existing entry.  This function fails
00674    * for maps that do not allow user specified keys.
00675    */
00676   virtual int trybind (const KEY &key,
00677                        VALUE &value);
00678 
00679   /// Locate <value> associated with <key>.
00680   virtual int find (const KEY &key,
00681                     VALUE &value);
00682 
00683   /// Is <key> in the map?
00684   virtual int find (const KEY &key);
00685 
00686   /// Remove <key> from the map.
00687   virtual int unbind (const KEY &key);
00688 
00689   /// Remove <key> from the map, and return the <value> associated with
00690   /// <key>.
00691   virtual int unbind (const KEY &key,
00692                       VALUE &value);
00693 
00694   /// Return the current size of the map.
00695   virtual size_t current_size (void) const;
00696 
00697   /// Return the total size of the map.
00698   virtual size_t total_size (void) const;
00699 
00700   /// Dump the state of an object.
00701   virtual void dump (void) const;
00702 
00703   /// Accessor to implementation object.
00704   IMPLEMENTATION &impl (void);
00705 
00706 protected:
00707 
00708   /// All implementation details are forwarded to this class.
00709   IMPLEMENTATION implementation_;
00710 
00711   // = STL styled iterator factory functions.
00712 
00713   /// Return forward iterator.
00714   virtual ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *begin_impl (void);
00715   virtual ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *end_impl (void);
00716 
00717   /// Return reverse iterator.
00718   virtual ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *rbegin_impl (void);
00719   virtual ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *rend_impl (void);
00720 
00721 private:
00722 
00723   // = Disallow these operations.
00724   ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Map_Impl<KEY, VALUE, IMPLEMENTATION, ITERATOR, REVERSE_ITERATOR, ENTRY> &))
00725   ACE_UNIMPLEMENTED_FUNC (ACE_Map_Impl (const ACE_Map_Impl<KEY, VALUE, IMPLEMENTATION, ITERATOR, REVERSE_ITERATOR, ENTRY> &))
00726 };
00727 
00728 /**
00729  * @class ACE_Active_Map_Manager_Iterator_Adapter
00730  *
00731  * @brief Defines a iterator implementation for the Active_Map_Manager_Adapter.
00732  *
00733  * Implementation to be provided by ACE_Active_Map_Manager::iterator.
00734  */
00735 template <class T, class VALUE>
00736 class ACE_Active_Map_Manager_Iterator_Adapter : public ACE_Iterator_Impl<T>
00737 {
00738 public:
00739 
00740   // = Traits.
00741   typedef ACE_TYPENAME ACE_Active_Map_Manager<VALUE>::iterator
00742           implementation;
00743 
00744   /// Constructor.
00745   ACE_Active_Map_Manager_Iterator_Adapter (const ACE_Map_Iterator<ACE_Active_Map_Manager_Key, VALUE, ACE_Null_Mutex> &impl);
00746 
00747   /// Destructor.
00748   virtual ~ACE_Active_Map_Manager_Iterator_Adapter (void);
00749 
00750   /// Clone.
00751   virtual ACE_Iterator_Impl<T> *clone (void) const;
00752 
00753   /// Comparison.
00754   virtual int compare (const ACE_Iterator_Impl<T> &rhs) const;
00755 
00756   /// Dereference.
00757   virtual T dereference (void) const;
00758 
00759   /// Advance.
00760   virtual void plus_plus (void);
00761 
00762   /// Reverse.
00763   virtual void minus_minus (void);
00764 
00765   /// Accessor to implementation object.
00766   ACE_Map_Iterator<ACE_Active_Map_Manager_Key, VALUE, ACE_Null_Mutex> &impl (void);
00767 
00768 protected:
00769 
00770   /// All implementation details are forwarded to this class.
00771   ACE_Map_Iterator<ACE_Active_Map_Manager_Key, VALUE, ACE_Null_Mutex> implementation_;
00772 };
00773 
00774 /**
00775  * @class ACE_Active_Map_Manager_Reverse_Iterator_Adapter
00776  *
00777  * @brief Defines a reverse iterator implementation for the Active_Map_Manager_Adapter.
00778  *
00779  * Implementation to be provided by ACE_Active_Map_Manager::reverse_iterator.
00780  */
00781 template <class T, class VALUE>
00782 class ACE_Active_Map_Manager_Reverse_Iterator_Adapter : public ACE_Reverse_Iterator_Impl<T>
00783 {
00784 public:
00785 
00786   // = Traits.
00787   typedef ACE_TYPENAME ACE_Active_Map_Manager<VALUE>::reverse_iterator
00788           implementation;
00789 
00790   /// Constructor.
00791   ACE_Active_Map_Manager_Reverse_Iterator_Adapter (const ACE_Map_Reverse_Iterator<ACE_Active_Map_Manager_Key, VALUE, ACE_Null_Mutex> &impl);
00792 
00793   /// Destructor.
00794   virtual ~ACE_Active_Map_Manager_Reverse_Iterator_Adapter (void);
00795 
00796   /// Clone.
00797   virtual ACE_Reverse_Iterator_Impl<T> *clone (void) const;
00798 
00799   /// Comparison.
00800   virtual int compare (const ACE_Reverse_Iterator_Impl<T> &rhs) const;
00801 
00802   /// Dereference.
00803   virtual T dereference (void) const;
00804 
00805   /// Advance.
00806   virtual void plus_plus (void);
00807 
00808   /// Reverse.
00809   virtual void minus_minus (void);
00810 
00811   /// Accessor to implementation object.
00812   ACE_Map_Reverse_Iterator<ACE_Active_Map_Manager_Key, VALUE, ACE_Null_Mutex> &impl (void);
00813 
00814 protected:
00815 
00816   /// All implementation details are forwarded to this class.
00817   ACE_Map_Reverse_Iterator<ACE_Active_Map_Manager_Key, VALUE, ACE_Null_Mutex> implementation_;
00818 };
00819 
00820 /**
00821  * @class ACE_Active_Map_Manager_Adapter
00822  *
00823  * @brief Defines a map implementation.
00824  *
00825  * Implementation to be provided by <ACE_Active_Map_Manager>.
00826  */
00827 template <class KEY, class VALUE, class KEY_ADAPTER>
00828 class ACE_Active_Map_Manager_Adapter : public ACE_Map<KEY, VALUE>
00829 {
00830 public:
00831 
00832   // = Traits.
00833   typedef ACE_Pair<KEY, VALUE>
00834           expanded_value;
00835   typedef ACE_Active_Map_Manager_Iterator_Adapter<ACE_Reference_Pair<const KEY, VALUE>, expanded_value>
00836           iterator_impl;
00837   typedef ACE_Active_Map_Manager_Reverse_Iterator_Adapter<ACE_Reference_Pair<const KEY, VALUE>, expanded_value>
00838           reverse_iterator_impl;
00839   typedef ACE_Active_Map_Manager<expanded_value>
00840           implementation;
00841 
00842   // = Initialization and termination methods.
00843   /// Initialize with the <ACE_DEFAULT_MAP_SIZE>.
00844   ACE_Active_Map_Manager_Adapter (ACE_Allocator *alloc = 0);
00845 
00846   /// Initialize with <size> entries.  The <size> parameter is ignored
00847   /// by maps for which an initialize size does not make sense.
00848   ACE_Active_Map_Manager_Adapter (size_t size,
00849                                   ACE_Allocator *alloc = 0);
00850 
00851   /// Close down and release dynamically allocated resources.
00852   virtual ~ACE_Active_Map_Manager_Adapter (void);
00853 
00854   /// Initialize a <Map> with size <length>.
00855   virtual int open (size_t length = ACE_DEFAULT_MAP_SIZE,
00856                     ACE_Allocator *alloc = 0);
00857 
00858   /// Close down a <Map> and release dynamically allocated resources.
00859   virtual int close (void);
00860 
00861   /**
00862    * Add <key>/<value> pair to the map.  If <key> is already in the
00863    * map then no changes are made and 1 is returned.  Returns 0 on a
00864    * successful addition.  This function fails for maps that do not
00865    * allow user specified keys. <key> is an "in" parameter.
00866    */
00867   virtual int bind (const KEY &key,
00868                     const VALUE &value);
00869 
00870   /**
00871    * Add <key>/<value> pair to the map.  <key> is an "inout" parameter
00872    * and maybe modified/extended by the map to add additional
00873    * information.  To recover original key, call the <recover_key>
00874    * method.
00875    */
00876   virtual int bind_modify_key (const VALUE &value,
00877                                KEY &key);
00878 
00879   /**
00880    * Produce a key and return it through <key> which is an "out"
00881    * parameter.  For maps that do not naturally produce keys, the map
00882    * adapters will use the <KEY_GENERATOR> class to produce a key.
00883    * However, the users are responsible for not jeopardizing this key
00884    * production scheme by using user specified keys with keys produced
00885    * by the key generator.
00886    */
00887   virtual int create_key (KEY &key);
00888 
00889   /**
00890    * Add <value> to the map, and the corresponding key produced by the
00891    * Map is returned through <key> which is an "out" parameter.  For
00892    * maps that do not naturally produce keys, the map adapters will
00893    * use the <KEY_GENERATOR> class to produce a key.  However, the
00894    * users are responsible for not jeopardizing this key production
00895    * scheme by using user specified keys with keys produced by the key
00896    * generator.
00897    */
00898   virtual int bind_create_key (const VALUE &value,
00899                                KEY &key);
00900 
00901   /**
00902    * Add <value> to the map.  The user does not care about the
00903    * corresponding key produced by the Map. For maps that do not
00904    * naturally produce keys, the map adapters will use the
00905    * <KEY_GENERATOR> class to produce a key.  However, the users are
00906    * responsible for not jeopardizing this key production scheme by
00907    * using user specified keys with keys produced by the key
00908    * generator.
00909    */
00910   virtual int bind_create_key (const VALUE &value);
00911 
00912   /// Recovers the original key potentially modified by the map during
00913   /// <bind_modify_key>.
00914   virtual int recover_key (const KEY &modified_key,
00915                            KEY &original_key);
00916 
00917   /**
00918    * Reassociate <key> with <value>. The function fails if <key> is
00919    * not in the map for maps that do not allow user specified keys.
00920    * However, for maps that allow user specified keys, if the key is
00921    * not in the map, a new <key>/<value> association is created.
00922    */
00923   virtual int rebind (const KEY &key,
00924                       const VALUE &value);
00925 
00926   /**
00927    * Reassociate <key> with <value>, storing the old value into the
00928    * "out" parameter <old_value>.  The function fails if <key> is not
00929    * in the map for maps that do not allow user specified keys.
00930    * However, for maps that allow user specified keys, if the key is
00931    * not in the map, a new <key>/<value> association is created.
00932    */
00933   virtual int rebind (const KEY &key,
00934                       const VALUE &value,
00935                       VALUE &old_value);
00936 
00937   /**
00938    * Reassociate <key> with <value>, storing the old key and value
00939    * into the "out" parameters <old_key> and <old_value>.  The
00940    * function fails if <key> is not in the map for maps that do not
00941    * allow user specified keys.  However, for maps that allow user
00942    * specified keys, if the key is not in the map, a new <key>/<value>
00943    * association is created.
00944    */
00945   virtual int rebind (const KEY &key,
00946                       const VALUE &value,
00947                       KEY &old_key,
00948                       VALUE &old_value);
00949 
00950   /**
00951    * Associate <key> with <value> if and only if <key> is not in the
00952    * map.  If <key> is already in the map, then the <value> parameter
00953    * is overwritten with the existing value in the map. Returns 0 if a
00954    * new <key>/<value> association is created.  Returns 1 if an
00955    * attempt is made to bind an existing entry.  This function fails
00956    * for maps that do not allow user specified keys.
00957    */
00958   virtual int trybind (const KEY &key,
00959                        VALUE &value);
00960 
00961   /// Locate <value> associated with <key>.
00962   virtual int find (const KEY &key,
00963                     VALUE &value);
00964 
00965   /// Is <key> in the map?
00966   virtual int find (const KEY &key);
00967 
00968   /// Remove <key> from the map.
00969   virtual int unbind (const KEY &key);
00970 
00971   /// Remove <key> from the map, and return the <value> associated with
00972   /// <key>.
00973   virtual int unbind (const KEY &key,
00974                       VALUE &value);
00975 
00976   /// Return the current size of the map.
00977   virtual size_t current_size (void) const;
00978 
00979   /// Return the total size of the map.
00980   virtual size_t total_size (void) const;
00981 
00982   /// Dump the state of an object.
00983   virtual void dump (void) const;
00984 
00985   /// Accessor to implementation object.
00986   ACE_Active_Map_Manager<ACE_Pair<KEY, VALUE> > &impl (void);
00987 
00988   /// Accessor to key adapter.
00989   KEY_ADAPTER &key_adapter (void);
00990 
00991 protected:
00992 
00993   /// Find helper.
00994   virtual int find (const KEY &key,
00995                     expanded_value *&internal_value);
00996 
00997   /// Unbind helper.
00998   virtual int unbind (const KEY &key,
00999                       expanded_value *&internal_value);
01000 
01001   /// All implementation details are forwarded to this class.
01002   ACE_Active_Map_Manager<ACE_Pair<KEY, VALUE> > implementation_;
01003 
01004   /// Adapts between the user key and the Active_Map_Manager_Key.
01005   KEY_ADAPTER key_adapter_;
01006 
01007   // = STL styled iterator factory functions.
01008 
01009   /// Return forward iterator.
01010   virtual ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *begin_impl (void);
01011   virtual ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *end_impl (void);
01012 
01013   /// Return reverse iterator.
01014   virtual ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *rbegin_impl (void);
01015   virtual ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *rend_impl (void);
01016 
01017 private:
01018 
01019   // = Disallow these operations.
01020   ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER> &))
01021   ACE_UNIMPLEMENTED_FUNC (ACE_Active_Map_Manager_Adapter (const ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER> &))
01022 };
01023 
01024 /**
01025  * @class ACE_Hash_Map_Manager_Ex_Iterator_Adapter
01026  *
01027  * @brief Defines a iterator implementation for the Hash_Map_Manager_Adapter.
01028  *
01029  * Implementation to be provided by ACE_Hash_Map_Manager_Ex::iterator.
01030  */
01031 template <class T, class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS>
01032 class ACE_Hash_Map_Manager_Ex_Iterator_Adapter : public ACE_Iterator_Impl<T>
01033 {
01034 public:
01035 
01036   // = Traits.
01037   typedef ACE_TYPENAME ACE_Hash_Map_Manager_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex>::iterator
01038           implementation;
01039 
01040   /// Constructor.
01041   ACE_Hash_Map_Manager_Ex_Iterator_Adapter (const ACE_Hash_Map_Iterator_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> &impl);
01042 
01043   /// Destructor.
01044   virtual ~ACE_Hash_Map_Manager_Ex_Iterator_Adapter (void);
01045 
01046   /// Clone.
01047   virtual ACE_Iterator_Impl<T> *clone (void) const;
01048 
01049   /// Comparison.
01050   virtual int compare (const ACE_Iterator_Impl<T> &rhs) const;
01051 
01052   /// Dereference.
01053   virtual T dereference (void) const;
01054 
01055   /// Advance.
01056   virtual void plus_plus (void);
01057 
01058   /// Reverse.
01059   virtual void minus_minus (void);
01060 
01061   /// Accessor to implementation object.
01062   ACE_Hash_Map_Iterator_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> &impl (void);
01063 
01064 protected:
01065 
01066   /// All implementation details are forwarded to this class.
01067   ACE_Hash_Map_Iterator_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> implementation_;
01068 };
01069 
01070 /**
01071  * @class ACE_Hash_Map_Manager_Ex_Reverse_Iterator_Adapter
01072  *
01073  * @brief Defines a reverse iterator implementation for the Hash_Map_Manager_Adapter.
01074  *
01075  * Implementation to be provided by ACE_Hash_Map_Manager_Ex::reverse_iterator.
01076  */
01077 template <class T, class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS>
01078 class ACE_Hash_Map_Manager_Ex_Reverse_Iterator_Adapter : public ACE_Reverse_Iterator_Impl<T>
01079 {
01080 public:
01081 
01082   // = Traits.
01083   typedef ACE_TYPENAME ACE_Hash_Map_Manager_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex>::reverse_iterator
01084           implementation;
01085 
01086   /// Constructor.
01087   ACE_Hash_Map_Manager_Ex_Reverse_Iterator_Adapter (const ACE_Hash_Map_Reverse_Iterator_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> &impl);
01088 
01089   /// Destructor.
01090   virtual ~ACE_Hash_Map_Manager_Ex_Reverse_Iterator_Adapter (void);
01091 
01092   /// Clone.
01093   virtual ACE_Reverse_Iterator_Impl<T> *clone (void) const;
01094 
01095   /// Comparison.
01096   virtual int compare (const ACE_Reverse_Iterator_Impl<T> &rhs) const;
01097 
01098   /// Dereference.
01099   virtual T dereference (void) const;
01100 
01101   /// Advance.
01102   virtual void plus_plus (void);
01103 
01104   /// Reverse.
01105   virtual void minus_minus (void);
01106 
01107   /// Accessor to implementation object.
01108   ACE_Hash_Map_Reverse_Iterator_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> &impl (void);
01109 
01110 protected:
01111 
01112   /// All implementation details are forwarded to this class.
01113   ACE_Hash_Map_Reverse_Iterator_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> implementation_;
01114 };
01115 
01116 /**
01117  * @class ACE_Hash_Map_Manager_Ex_Adapter
01118  *
01119  * @brief Defines a map implementation.
01120  *
01121  * Implementation to be provided by <ACE_Hash_Map_Manager_Ex>.
01122  */
01123 template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class KEY_GENERATOR>
01124 class ACE_Hash_Map_Manager_Ex_Adapter : public ACE_Map<KEY, VALUE>
01125 {
01126 public:
01127 
01128   // = Traits.
01129   typedef ACE_Hash_Map_Manager_Ex_Iterator_Adapter<ACE_Reference_Pair<const KEY, VALUE>, KEY, VALUE, HASH_KEY, COMPARE_KEYS>
01130           iterator_impl;
01131   typedef ACE_Hash_Map_Manager_Ex_Reverse_Iterator_Adapter<ACE_Reference_Pair<const KEY, VALUE>, KEY, VALUE, HASH_KEY, COMPARE_KEYS>
01132           reverse_iterator_impl;
01133   typedef ACE_Hash_Map_Manager_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex>
01134           implementation;
01135 
01136   // = Initialization and termination methods.
01137   /// Initialize with the <ACE_DEFAULT_MAP_SIZE>.
01138   ACE_Hash_Map_Manager_Ex_Adapter (ACE_Allocator *alloc = 0);
01139 
01140   /// Initialize with <size> entries.  The <size> parameter is ignored
01141   /// by maps for which an initialize size does not make sense.
01142   ACE_Hash_Map_Manager_Ex_Adapter (size_t size,
01143                                    ACE_Allocator *alloc = 0);
01144 
01145   /// Close down and release dynamically allocated resources.
01146   virtual ~ACE_Hash_Map_Manager_Ex_Adapter (void);
01147 
01148   /// Initialize a <Map> with size <length>.
01149   virtual int open (size_t length = ACE_DEFAULT_MAP_SIZE,
01150                     ACE_Allocator *alloc = 0);
01151 
01152   /// Close down a <Map> and release dynamically allocated resources.
01153   virtual int close (void);
01154 
01155   /**
01156    * Add <key>/<value> pair to the map.  If <key> is already in the
01157    * map then no changes are made and 1 is returned.  Returns 0 on a
01158    * successful addition.  This function fails for maps that do not
01159    * allow user specified keys. <key> is an "in" parameter.
01160    */
01161   virtual int bind (const KEY &key,
01162                     const VALUE &value);
01163 
01164   /**
01165    * Add <key>/<value> pair to the map.  <key> is an "inout" parameter
01166    * and maybe modified/extended by the map to add additional
01167    * information.  To recover original key, call the <recover_key>
01168    * method.
01169    */
01170   virtual int bind_modify_key (const VALUE &value,
01171                                KEY &key);
01172 
01173   /**
01174    * Produce a key and return it through <key> which is an "out"
01175    * parameter.  For maps that do not naturally produce keys, the map
01176    * adapters will use the <KEY_GENERATOR> class to produce a key.
01177    * However, the users are responsible for not jeopardizing this key
01178    * production scheme by using user specified keys with keys produced
01179    * by the key generator.
01180    */
01181   virtual int create_key (KEY &key);
01182 
01183   /**
01184    * Add <value> to the map, and the corresponding key produced by the
01185    * Map is returned through <key> which is an "out" parameter.  For
01186    * maps that do not naturally produce keys, the map adapters will
01187    * use the <KEY_GENERATOR> class to produce a key.  However, the
01188    * users are responsible for not jeopardizing this key production
01189    * scheme by using user specified keys with keys produced by the key
01190    * generator.
01191    */
01192   virtual int bind_create_key (const VALUE &value,
01193                                KEY &key);
01194 
01195   /**
01196    * Add <value> to the map.  The user does not care about the
01197    * corresponding key produced by the Map. For maps that do not
01198    * naturally produce keys, the map adapters will use the
01199    * <KEY_GENERATOR> class to produce a key.  However, the users are
01200    * responsible for not jeopardizing this key production scheme by
01201    * using user specified keys with keys produced by the key
01202    * generator.
01203    */
01204   virtual int bind_create_key (const VALUE &value);
01205 
01206   /// Recovers the original key potentially modified by the map during
01207   /// <bind_modify_key>.
01208   virtual int recover_key (const KEY &modified_key,
01209                            KEY &original_key);
01210 
01211   /**
01212    * Reassociate <key> with <value>. The function fails if <key> is
01213    * not in the map for maps that do not allow user specified keys.
01214    * However, for maps that allow user specified keys, if the key is
01215    * not in the map, a new <key>/<value> association is created.
01216    */
01217   virtual int rebind (const KEY &key,
01218                       const VALUE &value);
01219 
01220   /**
01221    * Reassociate <key> with <value>, storing the old value into the
01222    * "out" parameter <old_value>.  The function fails if <key> is not
01223    * in the map for maps that do not allow user specified keys.
01224    * However, for maps that allow user specified keys, if the key is
01225    * not in the map, a new <key>/<value> association is created.
01226    */
01227   virtual int rebind (const KEY &key,
01228                       const VALUE &value,
01229                       VALUE &old_value);
01230 
01231   /**
01232    * Reassociate <key> with <value>, storing the old key and value
01233    * into the "out" parameters <old_key> and <old_value>.  The
01234    * function fails if <key> is not in the map for maps that do not
01235    * allow user specified keys.  However, for maps that allow user
01236    * specified keys, if the key is not in the map, a new <key>/<value>
01237    * association is created.
01238    */
01239   virtual int rebind (const KEY &key,
01240                       const VALUE &value,
01241                       KEY &old_key,
01242                       VALUE &old_value);
01243 
01244   /**
01245    * Associate <key> with <value> if and only if <key> is not in the
01246    * map.  If <key> is already in the map, then the <value> parameter
01247    * is overwritten with the existing value in the map. Returns 0 if a
01248    * new <key>/<value> association is created.  Returns 1 if an
01249    * attempt is made to bind an existing entry.  This function fails
01250    * for maps that do not allow user specified keys.
01251    */
01252   virtual int trybind (const KEY &key,
01253                        VALUE &value);
01254 
01255   /// Locate <value> associated with <key>.
01256   virtual int find (const KEY &key,
01257                     VALUE &value);
01258 
01259   /// Is <key> in the map?
01260   virtual int find (const KEY &key);
01261 
01262   /// Remove <key> from the map.
01263   virtual int unbind (const KEY &key);
01264 
01265   /// Remove <key> from the map, and return the <value> associated with
01266   /// <key>.
01267   virtual int unbind (const KEY &key,
01268                       VALUE &value);
01269 
01270   /// Return the current size of the map.
01271   virtual size_t current_size (void) const;
01272 
01273   /// Return the total size of the map.
01274   virtual size_t total_size (void) const;
01275 
01276   /// Dump the state of an object.
01277   virtual void dump (void) const;
01278 
01279   /// Accessor to implementation object.
01280   ACE_Hash_Map_Manager_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> &impl (void);
01281 
01282   /// Accessor to key generator.
01283   KEY_GENERATOR &key_generator (void);
01284 
01285 protected:
01286 
01287   /// All implementation details are forwarded to this class.
01288   ACE_Hash_Map_Manager_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> implementation_;
01289 
01290   /// Functor class used for generating key.
01291   KEY_GENERATOR key_generator_;
01292 
01293   // = STL styled iterator factory functions.
01294 
01295   /// Return forward iterator.
01296   virtual ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *begin_impl (void);
01297   virtual ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *end_impl (void);
01298 
01299   /// Return reverse iterator.
01300   virtual ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *rbegin_impl (void);
01301   virtual ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *rend_impl (void);
01302 
01303 private:
01304 
01305   // = Disallow these operations.
01306   ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Hash_Map_Manager_Ex_Adapter<KEY, VALUE, HASH_KEY, COMPARE_KEYS, KEY_GENERATOR> &))
01307   ACE_UNIMPLEMENTED_FUNC (ACE_Hash_Map_Manager_Ex_Adapter (const ACE_Hash_Map_Manager_Ex_Adapter<KEY, VALUE, HASH_KEY, COMPARE_KEYS, KEY_GENERATOR> &))
01308 };
01309 
01310 /**
01311  * @class ACE_Map_Manager_Iterator_Adapter
01312  *
01313  * @brief Defines a iterator implementation for the Map_Manager_Adapter.
01314  *
01315  * Implementation to be provided by ACE_Map_Manager::iterator.
01316  */
01317 template <class T, class KEY, class VALUE>
01318 class ACE_Map_Manager_Iterator_Adapter : public ACE_Iterator_Impl<T>
01319 {
01320 public:
01321 
01322   // = Traits.
01323   typedef ACE_TYPENAME ACE_Map_Manager<KEY, VALUE, ACE_Null_Mutex>::iterator
01324           implementation;
01325 
01326   /// Constructor.
01327   ACE_Map_Manager_Iterator_Adapter (const ACE_Map_Iterator<KEY, VALUE, ACE_Null_Mutex> &impl);
01328 
01329   /// Destructor.
01330   virtual ~ACE_Map_Manager_Iterator_Adapter (void);
01331 
01332   /// Clone.
01333   virtual ACE_Iterator_Impl<T> *clone (void) const;
01334 
01335   /// Comparison.
01336   virtual int compare (const ACE_Iterator_Impl<T> &rhs) const;
01337 
01338   /// Dereference.
01339   virtual T dereference (void) const;
01340 
01341   /// Advance.
01342   virtual void plus_plus (void);
01343 
01344   /// Reverse.
01345   virtual void minus_minus (void);
01346 
01347   /// Accessor to implementation object.
01348   ACE_Map_Iterator<KEY, VALUE, ACE_Null_Mutex> &impl (void);
01349 
01350 protected:
01351 
01352   /// All implementation details are forwarded to this class.
01353   ACE_Map_Iterator<KEY, VALUE, ACE_Null_Mutex> implementation_;
01354 };
01355 
01356 /**
01357  * @class ACE_Map_Manager_Reverse_Iterator_Adapter
01358  *
01359  * @brief Defines a reverse iterator implementation for the Map Manager.
01360  *
01361  * Implementation to be provided by ACE_Map_Manager::reverse_iterator.
01362  */
01363 template <class T, class KEY, class VALUE>
01364 class ACE_Map_Manager_Reverse_Iterator_Adapter : public ACE_Reverse_Iterator_Impl<T>
01365 {
01366 public:
01367 
01368   // = Traits.
01369   typedef ACE_TYPENAME ACE_Map_Manager<KEY, VALUE, ACE_Null_Mutex>::reverse_iterator
01370           implementation;
01371 
01372   /// Constructor.
01373   ACE_Map_Manager_Reverse_Iterator_Adapter (const ACE_Map_Reverse_Iterator<KEY, VALUE, ACE_Null_Mutex> &impl);
01374 
01375   /// Destructor.
01376   virtual ~ACE_Map_Manager_Reverse_Iterator_Adapter (void);
01377 
01378   /// Clone.
01379   virtual ACE_Reverse_Iterator_Impl<T> *clone (void) const;
01380 
01381   /// Comparison.
01382   virtual int compare (const ACE_Reverse_Iterator_Impl<T> &rhs) const;
01383 
01384   /// Dereference.
01385   virtual T dereference (void) const;
01386 
01387   /// Advance.
01388   virtual void plus_plus (void);
01389 
01390   /// Reverse.
01391   virtual void minus_minus (void);
01392 
01393   /// Accessor to implementation object.
01394   ACE_Map_Reverse_Iterator<KEY, VALUE, ACE_Null_Mutex> &impl (void);
01395 
01396 protected:
01397 
01398   /// All implementation details are forwarded to this class.
01399   ACE_Map_Reverse_Iterator<KEY, VALUE, ACE_Null_Mutex> implementation_;
01400 };
01401 
01402 /**
01403  * @class ACE_Map_Manager_Adapter
01404  *
01405  * @brief Defines a map implementation.
01406  *
01407  * Implementation to be provided by <ACE_Map_Manager>.
01408  */
01409 template <class KEY, class VALUE, class KEY_GENERATOR>
01410 class ACE_Map_Manager_Adapter : public ACE_Map<KEY, VALUE>
01411 {
01412 public:
01413 
01414   // = Traits.
01415   typedef ACE_Map_Manager_Iterator_Adapter<ACE_Reference_Pair<const KEY, VALUE>, KEY, VALUE>
01416           iterator_impl;
01417   typedef ACE_Map_Manager_Reverse_Iterator_Adapter<ACE_Reference_Pair<const KEY, VALUE>, KEY, VALUE>
01418           reverse_iterator_impl;
01419   typedef ACE_Map_Manager<KEY, VALUE, ACE_Null_Mutex>
01420           implementation;
01421 
01422   // = Initialization and termination methods.
01423   /// Initialize with the <ACE_DEFAULT_MAP_SIZE>.
01424   ACE_Map_Manager_Adapter (ACE_Allocator *alloc = 0);
01425 
01426   /// Initialize with <size> entries.  The <size> parameter is ignored
01427   /// by maps for which an initialize size does not make sense.
01428   ACE_Map_Manager_Adapter (size_t size,
01429                            ACE_Allocator *alloc = 0);
01430 
01431   /// Close down and release dynamically allocated resources.
01432   virtual ~ACE_Map_Manager_Adapter (void);
01433 
01434   /// Initialize a <Map> with size <length>.
01435   virtual int open (size_t length = ACE_DEFAULT_MAP_SIZE,
01436                     ACE_Allocator *alloc = 0);
01437 
01438   /// Close down a <Map> and release dynamically allocated resources.
01439   virtual int close (void);
01440 
01441   /**
01442    * Add <key>/<value> pair to the map.  If <key> is already in the
01443    * map then no changes are made and 1 is returned.  Returns 0 on a
01444    * successful addition.  This function fails for maps that do not
01445    * allow user specified keys. <key> is an "in" parameter.
01446    */
01447   virtual int bind (const KEY &key,
01448                     const VALUE &value);
01449 
01450   /**
01451    * Add <key>/<value> pair to the map.  <key> is an "inout" parameter
01452    * and maybe modified/extended by the map to add additional
01453    * information.  To recover original key, call the <recover_key>
01454    * method.
01455    */
01456   virtual int bind_modify_key (const VALUE &value,
01457                                KEY &key);
01458 
01459   /**
01460    * Produce a key and return it through <key> which is an "out"
01461    * parameter.  For maps that do not naturally produce keys, the map
01462    * adapters will use the <KEY_GENERATOR> class to produce a key.
01463    * However, the users are responsible for not jeopardizing this key
01464    * production scheme by using user specified keys with keys produced
01465    * by the key generator.
01466    */
01467   virtual int create_key (KEY &key);
01468 
01469   /**
01470    * Add <value> to the map, and the corresponding key produced by the
01471    * Map is returned through <key> which is an "out" parameter.  For
01472    * maps that do not naturally produce keys, the map adapters will
01473    * use the <KEY_GENERATOR> class to produce a key.  However, the
01474    * users are responsible for not jeopardizing this key production
01475    * scheme by using user specified keys with keys produced by the key
01476    * generator.
01477    */
01478   virtual int bind_create_key (const VALUE &value,
01479                                KEY &key);
01480 
01481   /**
01482    * Add <value> to the map.  The user does not care about the
01483    * corresponding key produced by the Map. For maps that do not
01484    * naturally produce keys, the map adapters will use the
01485    * <KEY_GENERATOR> class to produce a key.  However, the users are
01486    * responsible for not jeopardizing this key production scheme by
01487    * using user specified keys with keys produced by the key
01488    * generator.
01489    */
01490   virtual int bind_create_key (const VALUE &value);
01491 
01492   /// Recovers the original key potentially modified by the map during
01493   /// <bind_modify_key>.
01494   virtual int recover_key (const KEY &modified_key,
01495                            KEY &original_key);
01496 
01497   /**
01498    * Reassociate <key> with <value>. The function fails if <key> is
01499    * not in the map for maps that do not allow user specified keys.
01500    * However, for maps that allow user specified keys, if the key is
01501    * not in the map, a new <key>/<value> association is created.
01502    */
01503   virtual int rebind (const KEY &key,
01504                       const VALUE &value);
01505 
01506   /**
01507    * Reassociate <key> with <value>, storing the old value into the
01508    * "out" parameter <old_value>.  The function fails if <key> is not
01509    * in the map for maps that do not allow user specified keys.
01510    * However, for maps that allow user specified keys, if the key is
01511    * not in the map, a new <key>/<value> association is created.
01512    */
01513   virtual int rebind (const KEY &key,
01514                       const VALUE &value,
01515                       VALUE &old_value);
01516 
01517   /**
01518    * Reassociate <key> with <value>, storing the old key and value
01519    * into the "out" parameters <old_key> and <old_value>.  The
01520    * function fails if <key> is not in the map for maps that do not
01521    * allow user specified keys.  However, for maps that allow user
01522    * specified keys, if the key is not in the map, a new <key>/<value>
01523    * association is created.
01524    */
01525   virtual int rebind (const KEY &key,
01526                       const VALUE &value,
01527                       KEY &old_key,
01528                       VALUE &old_value);
01529 
01530   /**
01531    * Associate <key> with <value> if and only if <key> is not in the
01532    * map.  If <key> is already in the map, then the <value> parameter
01533    * is overwritten with the existing value in the map. Returns 0 if a
01534    * new <key>/<value> association is created.  Returns 1 if an
01535    * attempt is made to bind an existing entry.  This function fails
01536    * for maps that do not allow user specified keys.
01537    */
01538   virtual int trybind (const KEY &key,
01539                        VALUE &value);
01540 
01541   /// Locate <value> associated with <key>.
01542   virtual int find (const KEY &key,
01543                     VALUE &value);
01544 
01545   /// Is <key> in the map?
01546   virtual int find (const KEY &key);
01547 
01548   /// Remove <key> from the map.
01549   virtual int unbind (const KEY &key);
01550 
01551   /// Remove <key> from the map, and return the <value> associated with
01552   /// <key>.
01553   virtual int unbind (const KEY &key,
01554                       VALUE &value);
01555 
01556   /// Return the current size of the map.
01557   virtual size_t current_size (void) const;
01558 
01559   /// Return the total size of the map.
01560   virtual size_t total_size (void) const;
01561 
01562   /// Dump the state of an object.
01563   virtual void dump (void) const;
01564 
01565   /// Accessor to implementation object.
01566   ACE_Map_Manager<KEY, VALUE, ACE_Null_Mutex> &impl (void);
01567 
01568   /// Accessor to key generator.
01569   KEY_GENERATOR &key_generator (void);
01570 
01571 protected:
01572 
01573   /// All implementation details are forwarded to this class.
01574   ACE_Map_Manager<KEY, VALUE, ACE_Null_Mutex> implementation_;
01575 
01576   /// Functor class used for generating key.
01577   KEY_GENERATOR key_generator_;
01578 
01579   // = STL styled iterator factory functions.
01580 
01581   /// Return forward iterator.
01582   virtual ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *begin_impl (void);
01583   virtual ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *end_impl (void);
01584 
01585   /// Return reverse iterator.
01586   virtual ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *rbegin_impl (void);
01587   virtual ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *rend_impl (void);
01588 
01589 private:
01590 
01591   // = Disallow these operations.
01592   ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Map_Manager_Adapter<KEY, VALUE, KEY_GENERATOR> &))
01593   ACE_UNIMPLEMENTED_FUNC (ACE_Map_Manager_Adapter (const ACE_Map_Manager_Adapter<KEY, VALUE, KEY_GENERATOR> &))
01594 };
01595 
01596 ACE_END_VERSIONED_NAMESPACE_DECL
01597 
01598 #if defined (__ACE_INLINE__)
01599 #include "ace/Map_T.inl"
01600 #endif /* __ACE_INLINE__ */
01601 
01602 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
01603 #include "ace/Map_T.cpp"
01604 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
01605 
01606 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
01607 #pragma implementation ("Map_T.cpp")
01608 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
01609 
01610 #include /**/ "ace/post.h"
01611 #endif /* ACE_MAP_T_H */

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