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

Generated on Tue Feb 2 17:18:40 2010 for ACE by  doxygen 1.4.7