Based_Pointer_Repository.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Based_Pointer_Repository.h
00006  *
00007  *  Based_Pointer_Repository.h,v 4.19 2006/02/10 09:23:40 jwillemsen 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/Singleton.h"
00026 #include "ace/Synch_Traits.h"
00027 #include "ace/os_include/os_stddef.h"
00028 
00029 
00030 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00031 
00032 // Forward decl., using the "Cheshire Cat" technique.
00033 class ACE_Based_Pointer_Repository_Rep;
00034 
00035 /**
00036  * @class ACE_Based_Pointer_Repository
00037  *
00038  * @brief Maps pointers to the base address of the region to which each
00039  * pointer belongs.
00040  */
00041 class ACE_Export ACE_Based_Pointer_Repository
00042 {
00043 public:
00044   // = Use ACE_Null_Mutex to allow locking while iterating.
00045 
00046   // = Initialization and termination methods.
00047   ACE_Based_Pointer_Repository (void);
00048   ~ACE_Based_Pointer_Repository (void);
00049 
00050   // = Search structure methods.
00051   /**
00052    * Return the appropriate @a base_addr region that contains @a addr.
00053    * Returns 1 on success and 0 if the @a addr isn't contained in any
00054    * @a base_addr region.
00055    */
00056   int find (void *addr,
00057             void *&base_addr);
00058 
00059   /// Bind a new entry to the repository or update the size of an
00060   /// existing entry.  Returns 0 on success and -1 on failure.
00061   int bind (void *addr,
00062             size_t size);
00063 
00064   /// Unbind from the repository the <base_addr> that <addr> is
00065   /// contained within.
00066   int unbind (void *addr);
00067 
00068 private:
00069 
00070   /// Use the "Cheshire-Cat" technique to hide the implementation in
00071   /// order to avoid circular #include dependencies.
00072   ACE_Based_Pointer_Repository_Rep *rep_;
00073 
00074 };
00075 
00076 // ----------------------------------
00077 
00078 /// Declare a process wide singleton
00079 ACE_SINGLETON_DECLARE (ACE_Singleton,
00080                        ACE_Based_Pointer_Repository,
00081                        ACE_SYNCH_RW_MUTEX)
00082 
00083 /// Provide a Singleton access point to the based pointer repository.
00084 typedef ACE_Singleton<ACE_Based_Pointer_Repository, ACE_SYNCH_RW_MUTEX>
00085         ACE_BASED_POINTER_REPOSITORY;
00086 
00087 ACE_END_VERSIONED_NAMESPACE_DECL
00088 
00089 #include /**/ "ace/post.h"
00090 
00091 #endif /* ACE_BASED_POINTER_REPOSITORY_H */

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