summaryrefslogtreecommitdiff
path: root/ace/Based_Pointer_T.h
diff options
context:
space:
mode:
Diffstat (limited to 'ace/Based_Pointer_T.h')
-rw-r--r--ace/Based_Pointer_T.h101
1 files changed, 26 insertions, 75 deletions
diff --git a/ace/Based_Pointer_T.h b/ace/Based_Pointer_T.h
index 0753b1980e5..0003bce08e8 100644
--- a/ace/Based_Pointer_T.h
+++ b/ace/Based_Pointer_T.h
@@ -18,8 +18,6 @@
#ifndef ACE_BASED_POINTER_T_H
#define ACE_BASED_POINTER_T_H
-#include "ace/OS.h" // Need ACE_Export
-
#if defined (_MSC_VER)
// Suppress warning e.g. "return type for
// 'ACE_Based_Pointer<long>::operator ->' is 'long *' (i.e., not a UDT
@@ -29,19 +27,21 @@
#endif /* _MSC_VER */
template <class CONCRETE>
-class ACE_Based_Pointer_Basic
+class ACE_Based_Pointer
{
// = TITLE
// A proxy that keeps track of the relative offset of a "pointer"
// from its base address.
//
+ // = DESCRIPTION
// This class makes it possible to transparently use "pointers" in
// shared memory as easily as programming with pointers to local
// memory. In particular, we don't need to ensure that the base
// addresses of all the pointers are mapped into separate
// processes at the same absolute memory base address.
public:
- ACE_Based_Pointer_Basic (void);
+ // = Initialization method.
+ ACE_Based_Pointer (void);
// This constructor initializes the <base_offset_> by asking the
// <ACE_BASED_POINTER_REPOSITORY> Singleton for the base address of
// the memory region within which it is instantiated. Two results
@@ -58,49 +58,37 @@ public:
// based-pointer uses its address as an offset to it's base
// address 0.
- ACE_Based_Pointer_Basic (CONCRETE *initial);
- // Initialize this object using the <initial> pointer. This
- // constructor initializes the <base_offset_> by asking the
- // <ACE_BASED_POINTER_REPOSITORY> Singleton for the base address of
- // the memory region within which it is instantiated. Two results
- // are possible:
- //
- // 1. An <ACE_*_Memory_Pool> has stored a base address/size pair and the
- // new based-pointer instance is located between the base address and
- // the base address + size - 1. In this case, the repository
- // returns the base address.
- //
- // 2. No suitable address/size pair was found. The repository
- // assumes an address in the regular (not mapped) virtual address
- // space of the process and returns 0. In this case, the
- // based-pointer uses its address as an offset to it's base
- // address 0.
+ ACE_Based_Pointer (CONCRETE *initial);
+ // Initialize this object with the <initial> pointer.
- ACE_Based_Pointer_Basic (const ACE_Based_Pointer_Basic<CONCRETE> &);
+ ACE_Based_Pointer (const ACE_Based_Pointer<CONCRETE> &rhs);
// Copy constructor.
- void operator = (CONCRETE *from);
+ CONCRETE *operator->(void);
+ // The C++ "delegation operator".
+
+ CONCRETE *operator =(CONCRETE *from);
// Pseudo-assignment operator.
- CONCRETE operator * (void) const;
+ CONCRETE operator *(void) const;
// Dereference operator.
- int operator < (const ACE_Based_Pointer_Basic<CONCRETE> &) const;
+ int operator < (const ACE_Based_Pointer<CONCRETE> &) const;
// Less than operator.
- int operator <= (const ACE_Based_Pointer_Basic<CONCRETE> &) const;
+ int operator <= (const ACE_Based_Pointer<CONCRETE> &) const;
// Less than or equal operator.
- int operator > (const ACE_Based_Pointer_Basic<CONCRETE> &) const;
+ int operator > (const ACE_Based_Pointer<CONCRETE> &) const;
// Greater than operator.
- int operator >= (const ACE_Based_Pointer_Basic<CONCRETE> &) const;
+ int operator >= (const ACE_Based_Pointer<CONCRETE> &) const;
// Greater than or equal operator.
- int operator == (const ACE_Based_Pointer_Basic<CONCRETE> &) const;
+ int operator == (const ACE_Based_Pointer<CONCRETE> &) const;
// Equality operator.
- int operator != (const ACE_Based_Pointer_Basic<CONCRETE> &) const;
+ int operator != (const ACE_Based_Pointer<CONCRETE> &) const;
// Inequality operator.
CONCRETE operator [](long index) const;
@@ -109,63 +97,26 @@ public:
void operator+= (long index);
// Increment operator.
- CONCRETE *addr (void) const;
+ operator void *() const;
// Returns the underlying memory address of the smart pointer.
- ACE_ALLOC_HOOK_DECLARE;
- // Declare the dynamic allocation hooks.
-
- void dump (void) const;
- // Dump the state of the object.
-
// The following should be private, but that causes problems due to
// broken C++ compilers that don't like friends for methods
// in templates.
-protected:
- long target_;
+// private:
+ CONCRETE *target_;
long base_offset_;
// Keep track of our offset from the base pointer.
-
- // = Prevent assignment and initialization (for now).
- ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Based_Pointer_Basic<CONCRETE> &))
};
-template <class CONCRETE>
-class ACE_Based_Pointer : public ACE_Based_Pointer_Basic<CONCRETE>
-{
- // = TITLE
- // A smart proxy that keeps track of the relative offset of a
- // "pointer" from its base address.
- //
- // = DESCRIPTION
- // This class makes it possible to transparently use "pointers" in
- // shared memory as easily as programming with pointers to local
- // memory by overloading the C++ delegation operator ->().
-public:
- // = Initialization method.
- ACE_Based_Pointer (void);
- // Constructor. See constructor for <ACE_Based_Pointer_Basic> for
- // details.
-
- ACE_Based_Pointer (CONCRETE *initial);
- // Initialize this object using the <initial> pointer.
-
- ACE_Based_Pointer (const ACE_Based_Pointer<CONCRETE> &);
- // Copy constructor.
-
- void operator = (CONCRETE *from);
- // Pseudo-assignment operator.
-
- CONCRETE *operator-> (void);
- // The C++ "delegation operator".
-
- // = Prevent assignment and initialization (for now).
- ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Based_Pointer<CONCRETE> &))
-};
+ACE_Export template <class CONCRETE>
+ACE_Based_Pointer<CONCRETE> operator+ (const ACE_Based_Pointer<CONCRETE> &lhs,
+ long increment);
+// Emulate "pointer arithmetic" by adding <increment> to <lhs>.
#if defined (__ACE_INLINE__)
-// #include "ace/Based_Pointer_T.i"
+#include "ace/Based_Pointer_T.i"
#endif /* __ACE_INLINE__ */
#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)