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

Hash_Map_With_Allocator_T.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 //=============================================================================
00003 /**
00004  *  @file   Hash_Map_With_Allocator_T.h
00005  *
00006  *  $Id: Hash_Map_With_Allocator_T.h,v 1.1.1.4 2003/02/21 18:36:32 chad Exp $
00007  *
00008  *  @author Marina Spivak <marina@cs.wustl.edu>
00009  *  @author Irfan Pyarali <irfan@cs.wustl.edu>
00010  */
00011 //=============================================================================
00012 
00013 #ifndef ACE_HASH_MAP_WITH_ALLOCATOR_T_H
00014 #define ACE_HASH_MAP_WITH_ALLOCATOR_T_H
00015 #include "ace/pre.h"
00016 
00017 #include "ace/Hash_Map_Manager.h"
00018 #include "ace/Synch.h"
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 /**
00025  * @class ACE_Hash_Map_With_Allocator
00026  *
00027  * @brief This class is a thin wrapper around ACE_Hash_Map_Manager,
00028  *     which comes handy when ACE_Hash_Map_Manager is to be used with a
00029  *     non-nil ACE_Allocator.  This wrapper insures that the appropriate
00030  *     allocator is in place for every operation that accesses or
00031  *     updates the hash map.
00032  *
00033  *     If we use ACE_Hash_Map_Manager with a shared memory allocator
00034  *     (or memory-mapped file allocator, for example), the allocator
00035  *     pointer used by ACE_Hash_Map_Manager gets stored with it, in
00036  *     shared memory (or memory-mapped file).  Naturally, this will
00037  *     cause horrible problems, since only the first process to set
00038  *     that pointer will be guaranteed the address of the allocator
00039  *     is meaningful!  That is why we need this wrapper, which
00040  *     insures that appropriate allocator pointer is in place for
00041  *     each call.
00042  */
00043 template <class EXT_ID, class INT_ID>
00044 class ACE_Hash_Map_With_Allocator :
00045   public ACE_Hash_Map_Manager<EXT_ID, INT_ID, ACE_Null_Mutex>
00046 {
00047 public:
00048   /// Constructor.
00049   ACE_Hash_Map_With_Allocator (ACE_Allocator *alloc);
00050 
00051   /// Constructor that specifies hash table size.
00052   ACE_Hash_Map_With_Allocator (size_t size,
00053                                ACE_Allocator *alloc);
00054 
00055   // = The following methods are Proxies to the corresponding methods
00056   // in <ACE_Hash_Map_Manager>.  Each method sets the allocator to
00057   // the one specified by the invoking entity, and then calls the
00058   // corresponding method in <ACE_Hash_Map_Manager> to do the
00059   // actual work.
00060 
00061   int bind (const EXT_ID &,
00062             const INT_ID &,
00063             ACE_Allocator *alloc);
00064 
00065   int unbind (const EXT_ID &,
00066               INT_ID &,
00067               ACE_Allocator *alloc);
00068 
00069   int unbind (const EXT_ID &,
00070               ACE_Allocator *alloc);
00071 
00072   int rebind (const EXT_ID &,
00073               const INT_ID &,
00074               EXT_ID &,
00075               INT_ID &,
00076               ACE_Allocator *alloc);
00077 
00078   int find (const EXT_ID &,
00079             INT_ID &,
00080             ACE_Allocator *alloc);
00081 
00082   /// Returns 0 if the <ext_id> is in the mapping, otherwise -1.
00083   int find (const EXT_ID &,
00084             ACE_Allocator *alloc);
00085 
00086   int close (ACE_Allocator *alloc);
00087 };
00088 
00089 #if defined (__ACE_INLINE__)
00090 #include "ace/Hash_Map_With_Allocator_T.i"
00091 #endif /* __ACE_INLINE__ */
00092 
00093 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
00094 #include "ace/Hash_Map_With_Allocator_T.cpp"
00095 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
00096 
00097 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
00098 #pragma implementation ("Hash_Map_With_Allocator_T.cpp")
00099 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
00100 
00101 
00102 #include "ace/post.h"
00103 #endif /* ACE_HASH_MAP_WITH_ALLOCATOR_T_H */

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