00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file Based_Pointer_Repository.h 00006 * 00007 * $Id: Based_Pointer_Repository.h,v 1.1.1.4 2003/02/21 18:36:32 chad Exp $ 00008 * 00009 * @author Dietrich Quehl <Dietrich.Quehl@med.siemens.de> 00010 * @author Douglas C. Schmidt <schmidt@.cs.wustl.edu> 00011 */ 00012 //============================================================================= 00013 00014 #ifndef ACE_BASED_POINTER_REPOSITORY_H 00015 #define ACE_BASED_POINTER_REPOSITORY_H 00016 00017 #include "ace/pre.h" 00018 00019 #include "ace/ACE_export.h" 00020 00021 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00022 # pragma once 00023 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00024 00025 #include "ace/OS.h" 00026 00027 // Forward decl., using the "Cheshire Cat" technique. 00028 class ACE_Based_Pointer_Repository_Rep; 00029 00030 /** 00031 * @class ACE_Based_Pointer_Repository 00032 * 00033 * @brief Maps pointers to the base address of the region to which each 00034 * pointer belongs. 00035 */ 00036 class ACE_Export ACE_Based_Pointer_Repository 00037 { 00038 public: 00039 // = Use <ACE_Null_Mutex> to allow locking while iterating. 00040 00041 // = Initialization and termination methods. 00042 ACE_Based_Pointer_Repository (void); 00043 ~ACE_Based_Pointer_Repository (void); 00044 00045 // = Search structure methods. 00046 /** 00047 * Return the appropriate <base_addr> region that contains <addr>. 00048 * Returns 1 on success and 0 if the <addr> isn't contained in any 00049 * <base_addr> region. 00050 */ 00051 int find (void *addr, 00052 void *&base_addr); 00053 00054 /// Bind a new entry to the repository or update the size of an 00055 /// existing entry. Returns 0 on success and -1 on failure. 00056 int bind (void *addr, 00057 size_t size); 00058 00059 /// Unbind from the repository the <base_addr> that <addr> is 00060 /// contained within. 00061 int unbind (void *addr); 00062 00063 private: 00064 00065 /// Use the "Cheshire-Cat" technique to hide the implementation in 00066 /// order to avoid circular #include dependencies. 00067 ACE_Based_Pointer_Repository_Rep *rep_; 00068 00069 }; 00070 00071 #include "ace/Singleton.h" 00072 00073 /// Provide a Singleton access point to the based pointer repository. 00074 typedef ACE_Singleton<ACE_Based_Pointer_Repository, ACE_SYNCH_RW_MUTEX> 00075 ACE_BASED_POINTER_REPOSITORY; 00076 00077 #include "ace/post.h" 00078 00079 #endif /* ACE_BASED_POINTER_REPOSITORY_H */
1.2.14 written by Dimitri van Heesch,
© 1997-2002