Hash_Map_With_Allocator_T.h

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

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