diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1999-07-08 06:21:24 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1999-07-08 06:21:24 +0000 |
commit | 902949f767e3510138644fda8ba93d2b1ab6f7a8 (patch) | |
tree | 42eeffdbd4af0c3045f0e0f03e964fad27af62c8 /ace/Based_Pointer_T.i | |
parent | e986ec75fc0edc25ee124df915d50e7c1013f060 (diff) | |
download | ATCD-902949f767e3510138644fda8ba93d2b1ab6f7a8.tar.gz |
ChangeLogTag:Thu Jul 8 00:23:02 1999 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu>
Diffstat (limited to 'ace/Based_Pointer_T.i')
-rw-r--r-- | ace/Based_Pointer_T.i | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/ace/Based_Pointer_T.i b/ace/Based_Pointer_T.i new file mode 100644 index 00000000000..cb0a3ae5fea --- /dev/null +++ b/ace/Based_Pointer_T.i @@ -0,0 +1,86 @@ +/* -*- C++ -*- */ +// $Id$ + +#define ACE_COMPUTE_BASED_POINTER(P) (((char *) (P) - (P)->base_offset_) + (long) (P)->target_) + +template <class CONCRETE> ACE_INLINE +ACE_Based_Pointer<CONCRETE>::ACE_Based_Pointer (const ACE_Based_Pointer<CONCRETE> &lhs) + : target_ (lhs.target_), + base_offset_ (lhs.base_offset_) +{ +} + +template <class CONCRETE> ACE_INLINE CONCRETE * +ACE_Based_Pointer<CONCRETE>::operator->(void) +{ + return (CONCRETE *)(ACE_COMPUTE_BASED_POINTER (this)); +} + +template <class CONCRETE> ACE_INLINE CONCRETE * +ACE_Based_Pointer<CONCRETE>::operator =(CONCRETE *from) +{ + this->target_ = (CONCRETE *)((char *) from + - ((char *) this - this->base_offset_)); + return from; +} + +template <class CONCRETE> ACE_INLINE CONCRETE +ACE_Based_Pointer<CONCRETE>::operator *(void) const +{ + return *(CONCRETE *)(ACE_COMPUTE_BASED_POINTER (this)); +} + +template <class CONCRETE> ACE_INLINE +ACE_Based_Pointer<CONCRETE>::operator void *() const +{ + return ACE_reinterpret_cast (void *, + ACE_COMPUTE_BASED_POINTER (this)); +} + +template <class CONCRETE> ACE_INLINE CONCRETE +ACE_Based_Pointer<CONCRETE>::operator [] (long index) const +{ + return *((CONCRETE *)(ACE_COMPUTE_BASED_POINTER (this)) + index); +} + +template <class CONCRETE> ACE_INLINE void +ACE_Based_Pointer<CONCRETE>::operator += (long index) +{ + this->base_offset_ += (index * sizeof (CONCRETE)); +} + +template <class CONCRETE> ACE_INLINE int +ACE_Based_Pointer<CONCRETE>::operator == (const ACE_Based_Pointer<CONCRETE> &rhs) const +{ + return ACE_COMPUTE_BASED_POINTER (this) == ACE_COMPUTE_BASED_POINTER (&rhs); +} + +template <class CONCRETE> ACE_INLINE int +ACE_Based_Pointer<CONCRETE>::operator != (const ACE_Based_Pointer<CONCRETE> &rhs) const +{ + return !(*this == rhs); +} + +template <class CONCRETE> ACE_INLINE int +ACE_Based_Pointer<CONCRETE>::operator < (const ACE_Based_Pointer<CONCRETE> &rhs) const +{ + return ACE_COMPUTE_BASED_POINTER (this) < ACE_COMPUTE_BASED_POINTER (&rhs); +} + +template <class CONCRETE> ACE_INLINE int +ACE_Based_Pointer<CONCRETE>::operator <= (const ACE_Based_Pointer<CONCRETE> &rhs) const +{ + return ACE_COMPUTE_BASED_POINTER (this) <= ACE_COMPUTE_BASED_POINTER (&rhs); +} + +template <class CONCRETE> ACE_INLINE int +ACE_Based_Pointer<CONCRETE>::operator > (const ACE_Based_Pointer<CONCRETE> &rhs) const +{ + return ACE_COMPUTE_BASED_POINTER (this) > ACE_COMPUTE_BASED_POINTER (&rhs); +} + +template <class CONCRETE> ACE_INLINE int +ACE_Based_Pointer<CONCRETE>::operator >= (const ACE_Based_Pointer<CONCRETE> &rhs) const +{ + return ACE_COMPUTE_BASED_POINTER (this) >= ACE_COMPUTE_BASED_POINTER (&rhs); +} |