summaryrefslogtreecommitdiff
path: root/ace/Based_Pointer_T.cpp
blob: 5c993b8855f9396c0b3af5e64c2e975d599b5f88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// $Id$

#ifndef ACE_BASED_POINTER_T_CPP
#define ACE_BASED_POINTER_T_CPP

#define ACE_BUILD_DLL
#include "ace/Based_Pointer_T.h"
#include "ace/Based_Pointer_Repository.h"

#if !defined (__ACE_INLINE__)
#include "ace/Based_Pointer_T.i"
#endif /* __ACE_INLINE__ */

template <class CONCRETE> ACE_Based_Pointer<CONCRETE> 
operator+ (const ACE_Based_Pointer<CONCRETE> &lhs, long increment)
{
  // Perform pointer arithmetic.
  CONCRETE *ptr = ((CONCRETE *) ACE_COMPUTE_BASED_POINTER (&lhs)) + increment;
  ACE_Based_Pointer<CONCRETE> tmp (ptr);
  return tmp;
}

template <class CONCRETE>
ACE_Based_Pointer<CONCRETE>::ACE_Based_Pointer (void)
  : target_ (0),
    base_offset_ (0)
{
  void *base_addr = 0;

  // Find the base address associated with our <this> pointer.  Note
  // that it's ok for <find> to return 0, which simply indicates that
  // the address is not in memory-mapped virtual address space.
  ACE_BASED_POINTER_REPOSITORY::instance ()->find (this, 
                                                   base_addr);
  this->base_offset_ = (char *) this - (char *) base_addr;
}

template <class CONCRETE>
ACE_Based_Pointer<CONCRETE>::ACE_Based_Pointer (CONCRETE *addr)
  : target_ (0),
    base_offset_ (0)
{
  void *base_addr = 0;

  // Find the base address associated with the <addr> pointer.  Note
  // that it's ok for <find> to return 0, which simply indicates that
  // the address is not in memory-mapped virtual address space.
  ACE_BASED_POINTER_REPOSITORY::instance ()->find (addr,
                                                   base_addr);
  this->base_offset_ = (char *) addr - (char *) base_addr;
}

#endif/* ACE_BASED_POINTER_T_CPP */