Public Member Functions | Private Member Functions | Private Attributes

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 Member Functions

void operator= (const ACE_Based_Pointer_Repository &)
 ACE_Based_Pointer_Repository (const ACE_Based_Pointer_Repository &)

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.

{
  ACE_TRACE ("ACE_Based_Pointer_Repository::ACE_Based_Pointer_Repository");
  ACE_NEW (this->rep_,
           ACE_Based_Pointer_Repository_Rep);
}

ACE_Based_Pointer_Repository::~ACE_Based_Pointer_Repository ( void   ) 

Definition at line 44 of file Based_Pointer_Repository.cpp.

{
  ACE_TRACE ("ACE_Based_Pointer_Repository::~ACE_Based_Pointer_Repository");
  delete this->rep_;
}

ACE_Based_Pointer_Repository::ACE_Based_Pointer_Repository ( const ACE_Based_Pointer_Repository  )  [private]

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.

{
  ACE_TRACE ("ACE_Based_Pointer_Repository::bind");
  ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->rep_->lock_, -1);

  return this->rep_->addr_map_.rebind (addr, size);
}

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.

{
  ACE_TRACE ("ACE_Based_Pointer_Repository::find");
  ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->rep_->lock_, -1);
  ACE_Based_Pointer_Repository_Rep::MAP_ENTRY *ce = 0;

  for (ACE_Based_Pointer_Repository_Rep::MAP_ITERATOR iter (this->rep_->addr_map_);
       iter.next (ce) != 0;
       iter.advance ())
    // Check to see if <addr> is within any of the regions.
    if (addr >= ce->ext_id_
        && addr < ((char *)ce->ext_id_ + ce->int_id_))
      {
        // Assign the base address.
        base_addr = ce->ext_id_;
        return 1;
      }

  // Assume base address 0 (e.g., if new'ed).
  base_addr = 0;
  return 0;
}

void ACE_Based_Pointer_Repository::operator= ( const ACE_Based_Pointer_Repository  )  [private]
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.

{
  ACE_TRACE ("ACE_Based_Pointer_Repository::unbind");
  ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->rep_->lock_, -1);
  ACE_Based_Pointer_Repository_Rep::MAP_ENTRY *ce = 0;

  // Search for service handlers that requested notification.

  for (ACE_Based_Pointer_Repository_Rep::MAP_ITERATOR iter (this->rep_->addr_map_);
       iter.next (ce) != 0;
       iter.advance ())
    {
      // Check to see if <addr> is within any of the regions and if
      // so, unbind the key from the map.
      if (addr >= ce->ext_id_
          && addr < ((char *)ce->ext_id_ + ce->int_id_))
        // Unbind base address.
        return this->rep_->addr_map_.unbind (ce->ext_id_);
    }

  return 0;
}


Member Data Documentation

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.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines