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

Map_Manager.h

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

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