ACE_Based_Pointer_Repository Class Reference

Maps pointers to the base address of the region to which each pointer belongs. More...

#include <Based_Pointer_Repository.h>

Collaboration diagram for ACE_Based_Pointer_Repository:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ACE_Based_Pointer_Repository (void)
 ~ACE_Based_Pointer_Repository (void)
int find (void *addr, void *&base_addr)
int bind (void *addr, size_t size)
int unbind (void *addr)

Private Attributes

ACE_Based_Pointer_Repository_Reprep_

Detailed Description

Maps pointers to the base address of the region to which each pointer belongs.

Definition at line 41 of file Based_Pointer_Repository.h.


Constructor & Destructor Documentation

ACE_Based_Pointer_Repository::ACE_Based_Pointer_Repository void   ) 
 

Definition at line 37 of file Based_Pointer_Repository.cpp.

References ACE_NEW, and ACE_TRACE.

00038 {
00039   ACE_TRACE ("ACE_Based_Pointer_Repository::ACE_Based_Pointer_Repository");
00040   ACE_NEW (this->rep_,
00041            ACE_Based_Pointer_Repository_Rep);
00042 }

ACE_Based_Pointer_Repository::~ACE_Based_Pointer_Repository void   ) 
 

Definition at line 44 of file Based_Pointer_Repository.cpp.

References ACE_TRACE, and rep_.

00045 {
00046   ACE_TRACE ("ACE_Based_Pointer_Repository::~ACE_Based_Pointer_Repository");
00047   delete this->rep_;
00048 }


Member Function Documentation

int ACE_Based_Pointer_Repository::bind void *  addr,
size_t  size
 

Bind a new entry to the repository or update the size of an existing entry. Returns 0 on success and -1 on failure.

Definition at line 81 of file Based_Pointer_Repository.cpp.

References ACE_GUARD_RETURN, ACE_SYNCH_MUTEX, ACE_TRACE, ACE_Based_Pointer_Repository_Rep::addr_map_, and rep_.

00083 {
00084   ACE_TRACE ("ACE_Based_Pointer_Repository::bind");
00085   ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->rep_->lock_, -1);
00086 
00087   return this->rep_->addr_map_.rebind (addr, size);
00088 }

int ACE_Based_Pointer_Repository::find void *  addr,
void *&  base_addr
 

Return the appropriate base_addr region that contains addr. Returns 1 on success and 0 if the addr isn't contained in any base_addr region.

Definition at line 53 of file Based_Pointer_Repository.cpp.

References ACE_GUARD_RETURN, ACE_SYNCH_MUTEX, ACE_TRACE, ACE_Map_Iterator< EXT_ID, INT_ID, ACE_LOCK >::advance(), ACE_Map_Entry< void *, size_t >::ext_id_, ACE_Map_Entry< void *, size_t >::int_id_, ACE_Based_Pointer_Repository_Rep::MAP_ENTRY, ACE_Based_Pointer_Repository_Rep::MAP_ITERATOR, and ACE_Map_Iterator_Base< EXT_ID, INT_ID, ACE_LOCK >::next().

00055 {
00056   ACE_TRACE ("ACE_Based_Pointer_Repository::find");
00057   ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->rep_->lock_, -1);
00058   ACE_Based_Pointer_Repository_Rep::MAP_ENTRY *ce = 0;
00059 
00060   for (ACE_Based_Pointer_Repository_Rep::MAP_ITERATOR iter (this->rep_->addr_map_);
00061        iter.next (ce) != 0;
00062        iter.advance ())
00063     // Check to see if <addr> is within any of the regions.
00064     if (addr >= ce->ext_id_
00065         && addr < ((char *) ce->ext_id_ + ce->int_id_))
00066       {
00067         // Assign the base address.
00068         base_addr = ce->ext_id_;
00069         return 1;
00070       }
00071 
00072   // Assume base address 0 (e.g., if new'ed).
00073   base_addr = 0;
00074   return 0;
00075 }

int ACE_Based_Pointer_Repository::unbind void *  addr  ) 
 

Unbind from the repository the that is contained within.

Definition at line 93 of file Based_Pointer_Repository.cpp.

References ACE_GUARD_RETURN, ACE_SYNCH_MUTEX, ACE_TRACE, ACE_Based_Pointer_Repository_Rep::addr_map_, ACE_Map_Iterator< EXT_ID, INT_ID, ACE_LOCK >::advance(), ACE_Map_Entry< void *, size_t >::ext_id_, ACE_Map_Entry< void *, size_t >::int_id_, ACE_Based_Pointer_Repository_Rep::MAP_ENTRY, ACE_Based_Pointer_Repository_Rep::MAP_ITERATOR, ACE_Map_Iterator_Base< EXT_ID, INT_ID, ACE_LOCK >::next(), and rep_.

00094 {
00095   ACE_TRACE ("ACE_Based_Pointer_Repository::unbind");
00096   ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->rep_->lock_, -1);
00097   ACE_Based_Pointer_Repository_Rep::MAP_ENTRY *ce = 0;
00098 
00099   // Search for service handlers that requested notification.
00100 
00101   for (ACE_Based_Pointer_Repository_Rep::MAP_ITERATOR iter (this->rep_->addr_map_);
00102        iter.next (ce) != 0;
00103        iter.advance ())
00104     {
00105       // Check to see if <addr> is within any of the regions and if
00106       // so, unbind the key from the map.
00107       if (addr >= ce->ext_id_
00108           && addr < ((char *) ce->ext_id_ + ce->int_id_))
00109         // Unbind base address.
00110         return this->rep_->addr_map_.unbind (ce->ext_id_);
00111     }
00112 
00113   return 0;
00114 }


Member Data Documentation

ACE_Based_Pointer_Repository_Rep* ACE_Based_Pointer_Repository::rep_ [private]
 

Use the "Cheshire-Cat" technique to hide the implementation in order to avoid circular #include dependencies.

Definition at line 72 of file Based_Pointer_Repository.h.

Referenced by bind(), unbind(), and ~ACE_Based_Pointer_Repository().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:20:19 2006 for ACE by doxygen 1.3.6