Map_Manager.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Map_Manager.h
00006  *
00007  *  Map_Manager.h,v 4.78 2006/04/27 11:17:55 jwillemsen Exp
00008  *
00009  *  @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
00010  */
00011 //=============================================================================
00012 
00013 #ifndef ACE_MAP_MANAGER_H
00014 #define ACE_MAP_MANAGER_H
00015 
00016 #include /**/ "ace/pre.h"
00017 
00018 #include "ace/config-all.h"
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 #include "ace/Basic_Types.h"
00025 #include "ace/Global_Macros.h"
00026 #include "ace/Default_Constants.h"
00027 
00028 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00029 
00030 // Forward declaration.
00031 class ACE_Allocator;
00032 
00033 /**
00034  * @class ACE_Map_Entry
00035  *
00036  * @brief An entry in the Map.
00037  */
00038 template <class EXT_ID, class INT_ID>
00039 class ACE_Map_Entry
00040 {
00041 public:
00042 # if ! defined (ACE_HAS_BROKEN_NOOP_DTORS)
00043   /// We need this destructor to keep some compilers from complaining.
00044   /// It's just a no-op, however.
00045   ~ACE_Map_Entry (void);
00046 # endif /* ! defined (ACE_HAS_BROKEN_NOOP_DTORS) */
00047 
00048   /// Key used to look up an entry.
00049   EXT_ID ext_id_;
00050 
00051   /// The contents of the entry itself.
00052   INT_ID int_id_;
00053 
00054   /// Dump the state of an object.
00055   void dump (void) const;
00056 
00057   /// Declare the dynamic allocation hooks.
00058   ACE_ALLOC_HOOK_DECLARE;
00059 
00060   // = These are really private, but unfortunately template friends
00061   // are not portable.
00062 
00063   /// Get next entry.
00064   ACE_UINT32 next (void) const;
00065 
00066   /// Set next entry.
00067   void next (ACE_UINT32 n);
00068 
00069   /// Get prev entry.
00070   ACE_UINT32 prev (void) const;
00071 
00072   /// Set prev entry.
00073   void prev (ACE_UINT32 p);
00074 
00075   /// Keeps track of the next entry.
00076   ACE_UINT32 next_;
00077 
00078   /// Keeps track of the previous entry.
00079   ACE_UINT32 prev_;
00080 
00081 #if defined (ACE_HAS_LAZY_MAP_MANAGER)
00082 
00083   /// Is this entry free?
00084   int free_;
00085 
00086 #endif /* ACE_HAS_LAZY_MAP_MANAGER */
00087 
00088 };
00089 
00090 // Forward decl.
00091 template <class EXT_ID, class INT_ID, class ACE_LOCK>
00092 class ACE_Map_Iterator_Base;
00093 
00094 // Forward decl.
00095 template <class EXT_ID, class INT_ID, class ACE_LOCK>
00096 class ACE_Map_Const_Iterator_Base;
00097 
00098 // Forward decl.
00099 template <class EXT_ID, class INT_ID, class ACE_LOCK>
00100 class ACE_Map_Iterator;
00101 
00102 // Forward decl.
00103 template <class EXT_ID, class INT_ID, class ACE_LOCK>
00104 class ACE_Map_Const_Iterator;
00105 
00106 // Forward decl.
00107 template <class EXT_ID, class INT_ID, class ACE_LOCK>
00108 class ACE_Map_Reverse_Iterator;
00109 
00110 /**
00111  * @class ACE_Map_Manager
00112  *
00113  * @brief Define a map abstraction that associates <EXT_ID>s with
00114  * <INT_ID>s.
00115  *
00116  * The <EXT_ID> must support <operator==>.  This constraint can
00117  * be alleviated via template specialization, as shown in the
00118  * $ACE_ROOT/tests/Conn_Test.cpp test.
00119  * This class uses an ACE_Allocator to allocate memory.  The
00120  * user can make this a persistant class by providing an
00121  * ACE_Allocator with a persistable memory pool.
00122  * This implementation of a map uses an array, which is searched
00123  * linearly.  For more efficient searching you should use the
00124  * <ACE_Hash_Map_Manager>.
00125  */
00126 template <class EXT_ID, class INT_ID, class ACE_LOCK>
00127 class ACE_Map_Manager
00128 {
00129 public:
00130   friend class ACE_Map_Iterator_Base<EXT_ID, INT_ID, ACE_LOCK>;
00131   friend class ACE_Map_Const_Iterator_Base<EXT_ID, INT_ID, ACE_LOCK>;
00132   friend class ACE_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK>;
00133   friend class ACE_Map_Const_Iterator<EXT_ID, INT_ID, ACE_LOCK>;
00134   friend class ACE_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK>;
00135 
00136   // = Traits.
00137   typedef EXT_ID KEY;
00138   typedef INT_ID VALUE;
00139   typedef ACE_LOCK lock_type;
00140   typedef ACE_Map_Entry<EXT_ID, INT_ID> ENTRY;
00141   typedef ACE_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK> ITERATOR;
00142   typedef ACE_Map_Const_Iterator<EXT_ID, INT_ID, ACE_LOCK> CONST_ITERATOR;
00143   typedef ACE_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK> REVERSE_ITERATOR;
00144 
00145   typedef ACE_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK> iterator;
00146   typedef ACE_Map_Const_Iterator<EXT_ID, INT_ID, ACE_LOCK> const_iterator;
00147   typedef ACE_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK> reverse_iterator;
00148 
00149   // = Initialization and termination methods.
00150   /// Initialize a ACE_Map_Manager with the ACE_DEFAULT_MAP_SIZE.
00151   ACE_Map_Manager (ACE_Allocator *alloc = 0);
00152 
00153   /// Initialize a ACE_Map_Manager with @a size entries.
00154   ACE_Map_Manager (size_t size,
00155                    ACE_Allocator *alloc = 0);
00156 
00157   /// Initialize a ACE_Map_Manager with size @a length.
00158   int open (size_t length = ACE_DEFAULT_MAP_SIZE,
00159             ACE_Allocator *alloc = 0);
00160 
00161   /// Close down a ACE_Map_Manager and release dynamically allocated
00162   /// resources.
00163   int close (void);
00164 
00165   /// Close down a ACE_Map_Manager and release dynamically allocated
00166   /// resources.
00167   ~ACE_Map_Manager (void);
00168 
00169   /**
00170    * Associate @a ext_id with @a int_id.  If @a ext_id is already in the
00171    * map then the ACE_Map_Entry is not changed.
00172    * @retval 0 If a new entry is bound successfully.
00173    * @retval 1 If an attempt is made to bind an existing entry.
00174    * @retval -1 If failures occur.
00175    */
00176   int bind (const EXT_ID &ext_id,
00177             const INT_ID &int_id);
00178 
00179   /**
00180    * Reassociate @a ext_id with @a int_id.  If @a ext_id is not in the
00181    * map then behaves just like bind().  Otherwise, store the old
00182    * values of <ext_id> and <int_id> into the "out" parameters and
00183    * rebind the new parameters.  This is very useful if you need to
00184    * have an atomic way of updating <Map_Entries> and you also need
00185    * full control over memory allocation.
00186    * @retval 0 If a new entry is bound successfully.
00187    * @retval 1 If an existing entry was rebound.
00188    * @retval -1 If failures occur.
00189    */
00190   int rebind (const EXT_ID &ext_id,
00191               const INT_ID &int_id,
00192               EXT_ID &old_ext_id,
00193               INT_ID &old_int_id);
00194 
00195   /**
00196    * Reassociate @a ext_id with @a int_id.  If <ext_id> is not in the
00197    * map then behaves just like <bind>.  Otherwise, store the old
00198    * values of <int_id> into the "out" parameter and rebind the new
00199    * parameters.
00200    * @retval 0 If a new entry is bound successfully.
00201    * @retval 1 If an existing entry was rebound.
00202    * @retval -1 If failures occur.
00203    */
00204   int rebind (const EXT_ID &ext_id,
00205               const INT_ID &int_id,
00206               INT_ID &old_int_id);
00207 
00208   /// Reassociate @a ext_id with @a int_id.  Old values in the map are
00209   /// ignored.
00210   int rebind (const EXT_ID &ext_id,
00211               const INT_ID &int_id);
00212 
00213   /**
00214    * Associate <ext_id> with <int_id> if and only if <ext_id> is not
00215    * in the map.  If <ext_id> is already in the map then the <int_id>
00216    * parameter is overwritten with the existing value in the map
00217    * @retval 0 If a new entry is bound successfully.
00218    * @retval 1 If an attempt is made to bind an existing entry.
00219    * @retval -1 If failures occur.
00220    */
00221   int trybind (const EXT_ID &ext_id,
00222                INT_ID &int_id);
00223 
00224   /**
00225    * Locate <ext_id> and pass out parameter via <int_id>.
00226    * @retval 0 If found.
00227    * @retval -1 If not found.
00228    */
00229   int find (const EXT_ID &ext_id,
00230             INT_ID &int_id) const;
00231 
00232   /// Returns 0 if the <ext_id> is in the mapping, otherwise -1.
00233   int find (const EXT_ID &ext_id) const;
00234 
00235   /**
00236    * Unbind (remove) the <ext_id> from the map.  Don't return the
00237    * <int_id> to the caller (this is useful for collections where the
00238    * <int_id>s are *not* dynamically allocated...)  Returns 0 if
00239    * successful, else -1.
00240    */
00241   int unbind (const EXT_ID &ext_id);
00242 
00243   /**
00244    * Break any association of <ext_id>.  Returns the value of <int_id>
00245    * in case the caller needs to deallocate memory.  Returns 0 if
00246    * successful, else -1.
00247    */
00248   int unbind (const EXT_ID &ext_id,
00249               INT_ID &int_id);
00250 
00251   /**
00252    * Unbind all entires.
00253    */
00254   void unbind_all (void);
00255 
00256   /// Return the current size of the map.
00257   size_t current_size (void) const;
00258 
00259   /// Return the total size of the map.
00260   size_t total_size (void) const;
00261 
00262   /**
00263    * Returns a reference to the underlying <ACE_LOCK>.  This makes it
00264    * possible to acquire the lock explicitly, which can be useful in
00265    * some cases if you instantiate the ACE_Atomic_Op with an
00266    * ACE_Recursive_Mutex or ACE_Process_Mutex, or if you need to
00267    * guard the state of an iterator.
00268    * @note The right name would be <lock>, but HP/C++ will choke on that!
00269    */
00270   ACE_LOCK &mutex (void);
00271 
00272   /// Dump the state of an object.
00273   void dump (void) const;
00274 
00275   // = STL styled iterator factory functions.
00276 
00277   /// Return forward iterator.
00278   ACE_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK> begin (void);
00279   ACE_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK> end (void);
00280 
00281   /// Return reverse iterator.
00282   ACE_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK> rbegin (void);
00283   ACE_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK> rend (void);
00284 
00285   /// Declare the dynamic allocation hooks.
00286   ACE_ALLOC_HOOK_DECLARE;
00287 
00288 protected:
00289 
00290   // = The following methods do the actual work.
00291 
00292   // These methods assume that the locks are held by the private
00293   // methods.
00294 
00295   /// Performs the binding of <ext_id> to <int_id>.  Must be called
00296   /// with locks held.
00297   int bind_i (const EXT_ID &ext_id,
00298               const INT_ID &int_id);
00299 
00300   /// Bind an entry (without finding first).  Must be called with locks
00301   /// held.
00302   int shared_bind (const EXT_ID &ext_id,
00303                    const INT_ID &int_id);
00304 
00305   /// Performs a rebinding of <ext_it> to <int_id>.  Also, recovers old
00306   /// values.  Must be called with locks held.
00307   int rebind_i (const EXT_ID &ext_id,
00308                 const INT_ID &int_id,
00309                 EXT_ID &old_ext_id,
00310                 INT_ID &old_int_id);
00311 
00312   /// Performs a rebinding of <ext_it> to <int_id>.  Also, recovers old
00313   /// values.  Must be called with locks held.
00314   int rebind_i (const EXT_ID &ext_id,
00315                 const INT_ID &int_id,
00316                 INT_ID &old_int_id);
00317 
00318   /// Performs a rebinding of <ext_it> to <int_id>.  Must be called
00319   /// with locks held.
00320   int rebind_i (const EXT_ID &ext_id,
00321                 const INT_ID &int_id);
00322 
00323   /// Performs a conditional bind of <int_id> using <ext_id> as the
00324   /// key.  Must be called with locks held.
00325   int trybind_i (const EXT_ID &ext_id,
00326                  INT_ID &int_id);
00327 
00328   /// Performs a find of <int_id> using <ext_id> as the key.  Must be
00329   /// called with locks held.
00330   int find_i (const EXT_ID &ext_id,
00331               INT_ID &int_id);
00332 
00333   /// Performs a find using <ext_id> as the key.  Must be called with
00334   /// locks held.
00335   int find_and_return_index (const EXT_ID &ext_id,
00336                              ACE_UINT32 &slot);
00337 
00338   /// Performs an unbind of <int_id> using <ext_id> as the key.  Must
00339   /// be called with locks held.
00340   int unbind_i (const EXT_ID &ext_id,
00341                 INT_ID &int_id);
00342 
00343   /// Performs an unbind using <ext_id> as the key.  Must be called
00344   /// with locks held.
00345   int unbind_i (const EXT_ID &ext_id);
00346 
00347   /// Performs an unbind using <ext_id> as the key.  Must be called
00348   /// with locks held.
00349   int unbind_and_return_index (const EXT_ID &ext_id,
00350                                ACE_UINT32 &slot);
00351 
00352   /// Unbind <slot>.
00353   void unbind_slot (ACE_UINT32 slot);
00354 
00355   /// Resize the map.  Must be called with locks held.
00356   int resize_i (ACE_UINT32 size);
00357 
00358   /// Close down a <Map_Manager>.  Must be called with locks held.
00359   int close_i (void);
00360 
00361   /// Returns 1 if <id1> == <id2>, else 0.  This is defined as a
00362   /// separate method to facilitate template specialization.
00363   int equal (const EXT_ID &id1, const EXT_ID &id2);
00364 
00365   /// This function returns the new size of the Map Manager.  This
00366   /// function is called when we run out of room and need to resize.
00367   ACE_UINT32 new_size (void);
00368 
00369   /// Explicitly call the destructors and free up the
00370   /// <search_structure_>.
00371   void free_search_structure (void);
00372 
00373   /// Id of the free list sentinel.
00374   ACE_UINT32 free_list_id (void) const;
00375 
00376   /// Id of the occupied list sentinel.
00377   ACE_UINT32 occupied_list_id (void) const;
00378 
00379   /// Finds the next free slot.
00380   int next_free (ACE_UINT32 &slot);
00381 
00382   /// Move from free list to occupied list.
00383   void move_from_free_list_to_occupied_list (ACE_UINT32 slot);
00384 
00385   /// Move from occupied list to free list.
00386   void move_from_occupied_list_to_free_list (ACE_UINT32 slot);
00387 
00388 #if defined (ACE_HAS_LAZY_MAP_MANAGER)
00389 
00390   /**
00391    * In the case of lazy map managers, the movement of free slots from
00392    * the occupied list to the free list is delayed until we run out of
00393    * free slots in the free list. This function goes through the
00394    * entire occupied list, moving free slots to the free list.
00395    */
00396   void move_all_free_slots_from_occupied_list (void);
00397 
00398 #endif /* ACE_HAS_LAZY_MAP_MANAGER */
00399 
00400   /// Move helper.
00401   void shared_move (ACE_UINT32 slot,
00402                     ACE_Map_Entry<EXT_ID, INT_ID> &current_list,
00403                     ACE_UINT32 current_list_id,
00404                     ACE_Map_Entry<EXT_ID, INT_ID> &new_list,
00405                     ACE_UINT32 new_list_id);
00406 
00407   /// Pointer to a memory allocator.
00408   ACE_Allocator *allocator_;
00409 
00410   /// Synchronization variable for the MT_SAFE <ACE_Map_Manager>.
00411   mutable ACE_LOCK lock_;
00412 
00413   /// Implement the Map as a resizeable array of <ACE_Map_Entry>.
00414   ACE_Map_Entry<EXT_ID, INT_ID> *search_structure_;
00415 
00416   /// Total number of elements in this->search_structure_.
00417   ACE_UINT32 total_size_;
00418 
00419   /// Current size of the map.
00420   ACE_UINT32 cur_size_;
00421 
00422   /// Free list.
00423   ACE_Map_Entry<EXT_ID, INT_ID> free_list_;
00424 
00425   /// Occupied list.
00426   ACE_Map_Entry<EXT_ID, INT_ID> occupied_list_;
00427 
00428   enum
00429   {
00430     /// Grow map exponentially up to 64K
00431     MAX_EXPONENTIAL = 64 * 1024,
00432 
00433     /// Afterwards grow in chunks of 32K
00434     LINEAR_INCREASE = 32 * 1024
00435   };
00436 
00437 private:
00438   // = Disallow these operations.
00439   ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK> &))
00440   ACE_UNIMPLEMENTED_FUNC (ACE_Map_Manager (const ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK> &))
00441 };
00442 
00443 /**
00444  * @class ACE_Map_Iterator_Base
00445  *
00446  * @brief Iterator for the ACE_Map_Manager.
00447  *
00448  * This class factors out common code from its templatized
00449  * subclasses.
00450  */
00451 template <class EXT_ID, class INT_ID, class ACE_LOCK>
00452 class ACE_Map_Iterator_Base
00453 {
00454 public:
00455   // = Initialization method.
00456   /// Contructor.  If head != 0, the iterator constructed is positioned
00457   /// at the head of the map, it is positioned at the end otherwise.
00458   ACE_Map_Iterator_Base (ACE_Map_Manager <EXT_ID, INT_ID, ACE_LOCK> &mm);
00459 
00460   // = Iteration methods.
00461 
00462   /// Pass back the next <entry> that hasn't been seen in the Set.
00463   /// Returns 0 when all items have been seen, else 1.
00464   int next (ACE_Map_Entry<EXT_ID, INT_ID> *&next_entry) const;
00465 
00466   /// Returns 1 when all items have been seen, else 0.
00467   int done (void) const;
00468 
00469   /// Returns a reference to the interal element <this> is pointing to.
00470   ACE_Map_Entry<EXT_ID, INT_ID>& operator* (void) const;
00471 
00472   /// Returns reference the Map_Manager that is being iterated
00473   /// over.
00474   ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK>& map (void);
00475 
00476   /// Check if two iterators point to the same position
00477   bool operator== (const ACE_Map_Iterator_Base<EXT_ID, INT_ID, ACE_LOCK> &) const;
00478   bool operator!= (const ACE_Map_Iterator_Base<EXT_ID, INT_ID, ACE_LOCK> &) const;
00479 
00480   /// Declare the dynamic allocation hooks.
00481   ACE_ALLOC_HOOK_DECLARE;
00482 
00483 protected:
00484   /// Move forward by one element in the set.  Returns 0 when there's
00485   /// no more item in the set after the current items, else 1.
00486   int forward_i (void);
00487 
00488   /// Move backware by one element in the set.  Returns 0 when there's
00489   /// no more item in the set before the current item, else 1.
00490   int reverse_i (void);
00491 
00492   /// Dump the state of an object.
00493   void dump_i (void) const;
00494 
00495   /// Map we are iterating over.
00496   ACE_Map_Manager <EXT_ID, INT_ID, ACE_LOCK> *map_man_;
00497 
00498   /// Keeps track of how far we've advanced...
00499   ACE_UINT32 next_;
00500 };
00501 
00502 /**
00503  * @class ACE_Map_Const_Iterator_Base
00504  *
00505  * @brief Const iterator for the ACE_Map_Manager.
00506  *
00507  * This class factors out common code from its templatized
00508  * subclasses.
00509  */
00510 template <class EXT_ID, class INT_ID, class ACE_LOCK>
00511 class ACE_Map_Const_Iterator_Base
00512 {
00513 public:
00514   // = Initialization method.
00515   /// Contructor.  If head != 0, the iterator constructed is positioned
00516   /// at the head of the map, it is positioned at the end otherwise.
00517   ACE_Map_Const_Iterator_Base (const ACE_Map_Manager <EXT_ID, INT_ID, ACE_LOCK> &mm);
00518 
00519   // = Iteration methods.
00520 
00521   /// Pass back the next <entry> that hasn't been seen in the Set.
00522   /// Returns 0 when all items have been seen, else 1.
00523   int next (ACE_Map_Entry<EXT_ID, INT_ID> *&next_entry) const;
00524 
00525   /// Returns 1 when all items have been seen, else 0.
00526   int done (void) const;
00527 
00528   /// Returns a reference to the interal element <this> is pointing to.
00529   ACE_Map_Entry<EXT_ID, INT_ID>& operator* (void) const;
00530 
00531   /// Returns reference the Map_Manager that is being iterated
00532   /// over.
00533   const ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK>& map (void) const;
00534 
00535   /// Check if two iterators point to the same position
00536   bool operator== (const ACE_Map_Const_Iterator_Base<EXT_ID, INT_ID, ACE_LOCK> &) const;
00537   bool operator!= (const ACE_Map_Const_Iterator_Base<EXT_ID, INT_ID, ACE_LOCK> &) const;
00538 
00539   /// Declare the dynamic allocation hooks.
00540   ACE_ALLOC_HOOK_DECLARE;
00541 
00542 protected:
00543   /// Move forward by one element in the set.  Returns 0 when there's
00544   /// no more item in the set after the current items, else 1.
00545   int forward_i (void);
00546 
00547   /// Move backware by one element in the set.  Returns 0 when there's
00548   /// no more item in the set before the current item, else 1.
00549   int reverse_i (void);
00550 
00551   /// Dump the state of an object.
00552   void dump_i (void) const;
00553 
00554   /// Map we are iterating over.
00555   const ACE_Map_Manager <EXT_ID, INT_ID, ACE_LOCK> *map_man_;
00556 
00557   /// Keeps track of how far we've advanced...
00558   ACE_UINT32 next_;
00559 };
00560 
00561 /**
00562  * @class ACE_Map_Iterator
00563  *
00564  * @brief Forward iterator for the ACE_Map_Manager.
00565  *
00566  * This class does not perform any internal locking of the
00567  * <ACE_Map_Manager> it is iterating upon since locking is
00568  * inherently inefficient and/or error-prone within an STL-style
00569  * iterator.  If you require locking, you can explicitly use an
00570  * ACE_Guard or ACE_Read_Guard on the <ACE_Map_Manager>'s
00571  * internal lock, which is accessible via its <mutex> method.
00572  */
00573 template <class EXT_ID, class INT_ID, class ACE_LOCK>
00574 class ACE_Map_Iterator : public ACE_Map_Iterator_Base<EXT_ID, INT_ID, ACE_LOCK>
00575 {
00576 public:
00577   // = Initialization method.
00578   ACE_Map_Iterator (ACE_Map_Manager <EXT_ID, INT_ID, ACE_LOCK> &mm,
00579                     int pass_end = 0);
00580 
00581   // = Iteration methods.
00582 
00583   /// Move forward by one element in the set.   Returns 0 when all the
00584   /// items in the set have been seen, else 1.
00585   int advance (void);
00586 
00587   /// Dump the state of an object.
00588   void dump (void) const;
00589 
00590   // = STL styled iteration, compare, and reference functions.
00591 
00592   /// Prefix advance.
00593   ACE_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK> &operator++ (void);
00594 
00595   /// Postfix advance.
00596   ACE_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK> operator++ (int);
00597 
00598   /// Prefix reverse.
00599   ACE_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK> &operator-- (void);
00600 
00601   /// Postfix reverse.
00602   ACE_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK> operator-- (int);
00603 
00604   /// Declare the dynamic allocation hooks.
00605   ACE_ALLOC_HOOK_DECLARE;
00606 };
00607 
00608 /**
00609  * @class ACE_Map_Const_Iterator
00610  *
00611  * @brief Forward const iterator for the ACE_Map_Manager.
00612  *
00613  * This class does not perform any internal locking of the
00614  * <ACE_Map_Manager> it is iterating upon since locking is
00615  * inherently inefficient and/or error-prone within an STL-style
00616  * iterator.  If you require locking, you can explicitly use an
00617  * ACE_Guard or ACE_Read_Guard on the <ACE_Map_Manager>'s
00618  * internal lock, which is accessible via its <mutex> method.
00619  */
00620 template <class EXT_ID, class INT_ID, class ACE_LOCK>
00621 class ACE_Map_Const_Iterator : public ACE_Map_Const_Iterator_Base<EXT_ID, INT_ID, ACE_LOCK>
00622 {
00623 public:
00624   // = Initialization method.
00625   ACE_Map_Const_Iterator (const ACE_Map_Manager <EXT_ID, INT_ID, ACE_LOCK> &mm,
00626                           int pass_end = 0);
00627 
00628   // = Iteration methods.
00629 
00630   /// Move forward by one element in the set.   Returns 0 when all the
00631   /// items in the set have been seen, else 1.
00632   int advance (void);
00633 
00634   /// Dump the state of an object.
00635   void dump (void) const;
00636 
00637   // = STL styled iteration, compare, and reference functions.
00638 
00639   /// Prefix advance.
00640   ACE_Map_Const_Iterator<EXT_ID, INT_ID, ACE_LOCK> &operator++ (void);
00641 
00642   /// Postfix advance.
00643   ACE_Map_Const_Iterator<EXT_ID, INT_ID, ACE_LOCK> operator++ (int);
00644 
00645   /// Prefix reverse.
00646   ACE_Map_Const_Iterator<EXT_ID, INT_ID, ACE_LOCK> &operator-- (void);
00647 
00648   /// Postfix reverse.
00649   ACE_Map_Const_Iterator<EXT_ID, INT_ID, ACE_LOCK> operator-- (int);
00650 
00651   /// Declare the dynamic allocation hooks.
00652   ACE_ALLOC_HOOK_DECLARE;
00653 };
00654 
00655 /**
00656  * @class ACE_Map_Reverse_Iterator
00657  *
00658  * @brief Reverse Iterator for the <ACE_Map_Manager>.
00659  *
00660  * This class does not perform any internal locking of the
00661  * <ACE_Map_Manager> it is iterating upon since locking is
00662  * inherently inefficient and/or error-prone within an STL-style
00663  * iterator.  If you require locking, you can explicitly use an
00664  * ACE_Guard or ACE_Read_Guard on the <ACE_Map_Manager>'s
00665  * internal lock, which is accessible via its <mutex> method.
00666  */
00667 template <class EXT_ID, class INT_ID, class ACE_LOCK>
00668 class ACE_Map_Reverse_Iterator : public ACE_Map_Iterator_Base<EXT_ID, INT_ID, ACE_LOCK>
00669 {
00670 public:
00671   // = Initialization method.
00672   ACE_Map_Reverse_Iterator (ACE_Map_Manager <EXT_ID, INT_ID, ACE_LOCK> &mm,
00673                             int pass_end = 0);
00674 
00675   // = Iteration methods.
00676 
00677   /// Move forward by one element in the set.  Returns 0 when all the
00678   /// items in the set have been seen, else 1.
00679   int advance (void);
00680 
00681   /// Dump the state of an object.
00682   void dump (void) const;
00683 
00684   // = STL styled iteration, compare, and reference functions.
00685 
00686   /// Prefix reverse.
00687   ACE_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK> &operator++ (void);
00688 
00689   /// Postfix reverse.
00690   ACE_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK> operator++ (int);
00691 
00692   /// Prefix advance.
00693   ACE_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK> &operator-- (void);
00694 
00695   /// Postfix advance.
00696   ACE_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK> operator-- (int);
00697 
00698   /// Declare the dynamic allocation hooks.
00699   ACE_ALLOC_HOOK_DECLARE;
00700 };
00701 
00702 ACE_END_VERSIONED_NAMESPACE_DECL
00703 
00704 #if defined (__ACE_INLINE__)
00705 #include "ace/Map_Manager.inl"
00706 #endif /* __ACE_INLINE__ */
00707 
00708 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
00709 #include "ace/Map_Manager.cpp"
00710 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
00711 
00712 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
00713 #pragma implementation ("Map_Manager.cpp")
00714 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
00715 
00716 #include /**/ "ace/post.h"
00717 
00718 #endif /* ACE_MAP_MANAGER_H */

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