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 80 of file Based_Pointer_Repository.cpp.

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

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

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(), and ACE_Map_Iterator_Base< EXT_ID, INT_ID, ACE_LOCK >::next().

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

int ACE_Based_Pointer_Repository::unbind ( void *  addr  ) 

Unbind from the repository the <base_addr> that addr is contained within.

Definition at line 91 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_Iterator_Base< EXT_ID, INT_ID, ACE_LOCK >::next(), and rep_.

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


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 Tue Feb 2 17:34:56 2010 for ACE by  doxygen 1.4.7