diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1999-07-16 22:05:50 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1999-07-16 22:05:50 +0000 |
commit | 9ee6337357f40e44ebbaa61f8552277f840f7ca4 (patch) | |
tree | 8bad01d8653ad73452988ed6d14aa473af9bdcd3 /ace/Based_Pointer_T.h | |
parent | 3b4d59d72a7e3b9574edbfb540dd44a73fad7731 (diff) | |
download | ATCD-9ee6337357f40e44ebbaa61f8552277f840f7ca4.tar.gz |
.
Diffstat (limited to 'ace/Based_Pointer_T.h')
-rw-r--r-- | ace/Based_Pointer_T.h | 99 |
1 files changed, 73 insertions, 26 deletions
diff --git a/ace/Based_Pointer_T.h b/ace/Based_Pointer_T.h index 0100ed1245d..0753b1980e5 100644 --- a/ace/Based_Pointer_T.h +++ b/ace/Based_Pointer_T.h @@ -29,21 +29,19 @@ #endif /* _MSC_VER */ template <class CONCRETE> -class ACE_Based_Pointer +class ACE_Based_Pointer_Basic { // = 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: - // = Initialization method. - ACE_Based_Pointer (void); + ACE_Based_Pointer_Basic (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 @@ -60,37 +58,49 @@ public: // 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 (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 (const ACE_Based_Pointer<CONCRETE> &rhs); + ACE_Based_Pointer_Basic (const ACE_Based_Pointer_Basic<CONCRETE> &); // Copy constructor. - CONCRETE *operator->(void); - // The C++ "delegation operator". - - CONCRETE *operator =(CONCRETE *from); + void operator = (CONCRETE *from); // Pseudo-assignment operator. - CONCRETE operator *(void) const; + CONCRETE operator * (void) const; // Dereference operator. - int operator < (const ACE_Based_Pointer<CONCRETE> &) const; + int operator < (const ACE_Based_Pointer_Basic<CONCRETE> &) const; // Less than operator. - int operator <= (const ACE_Based_Pointer<CONCRETE> &) const; + int operator <= (const ACE_Based_Pointer_Basic<CONCRETE> &) const; // Less than or equal operator. - int operator > (const ACE_Based_Pointer<CONCRETE> &) const; + int operator > (const ACE_Based_Pointer_Basic<CONCRETE> &) const; // Greater than operator. - int operator >= (const ACE_Based_Pointer<CONCRETE> &) const; + int operator >= (const ACE_Based_Pointer_Basic<CONCRETE> &) const; // Greater than or equal operator. - int operator == (const ACE_Based_Pointer<CONCRETE> &) const; + int operator == (const ACE_Based_Pointer_Basic<CONCRETE> &) const; // Equality operator. - int operator != (const ACE_Based_Pointer<CONCRETE> &) const; + int operator != (const ACE_Based_Pointer_Basic<CONCRETE> &) const; // Inequality operator. CONCRETE operator [](long index) const; @@ -99,26 +109,63 @@ public: void operator+= (long index); // Increment operator. - operator void *() const; + CONCRETE *addr (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. -// private: - CONCRETE *target_; +protected: + long 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> &)) }; -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>. +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> &)) +}; #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) |