10 #define ThePEG_RCPtr_H 14 #include "ReferenceCounted.h" 16 #include "PtrTraits.h" 96 template <
typename UPtr>
156 if ( ptr == p.
ptr )
return *
this;
167 template <
typename UPtr>
180 template <
typename UPtr>
183 if ( ptr == up )
return *
this;
194 template <
typename UPtr>
197 if ( ptr == up )
return *
this;
208 const pointer tmp = ptr;
237 template <
typename UPtr>
245 template <
typename UPtr>
254 return ( ptr && p.
ptr && ptr->uniqueId != p.
ptr->uniqueId ) ?
255 ptr->uniqueId < p.
ptr->uniqueId : ptr < p.
ptr;
262 return ( ptr && p && ptr->uniqueId != p->uniqueId ) ?
263 ptr->uniqueId < p->uniqueId : ptr < p;
274 operator T * ()
const {
return ptr; }
314 template <
typename T>
350 template <
typename UPtr>
368 if ( ptr == p.
ptr )
return *
this;
379 template <
typename UPtr>
392 template <
typename UPtr>
396 if ( ptr == up )
return *
this;
407 const const_pointer tmp = ptr;
436 template <
typename UPtr>
442 template <
typename UPtr>
449 return ( ptr && p.
ptr && ptr->uniqueId != p.
ptr->uniqueId ) ?
450 ptr->uniqueId < p.
ptr->uniqueId : ptr < p.
ptr;
457 return ( ptr && p && ptr->uniqueId != p->uniqueId ) ?
458 ptr->uniqueId < p->uniqueId : ptr < p;
469 operator const T * ()
const {
return ptr; }
508 template <
typename T>
544 template <
typename UPtr>
569 template <
typename UPtr>
579 template <
typename UPtr>
589 template <
typename UPtr>
618 template <
typename UPtr>
624 template <
typename UPtr>
631 return ( ptr && p.
ptr && ptr->uniqueId != p.
ptr->uniqueId ) ?
632 ptr->uniqueId < p.
ptr->uniqueId : ptr < p.
ptr;
639 return ( ptr && p && ptr->uniqueId != p->uniqueId ) ?
640 ptr->uniqueId < p->uniqueId : ptr < p;
651 operator T * ()
const {
return ptr; }
680 template <
typename T>
716 template <
typename UPtr>
741 template <
typename UPtr>
751 template <
typename UPtr>
781 template <
typename UPtr>
787 template <
typename UPtr>
794 return ( ptr && p.
ptr && ptr->uniqueId != p.
ptr->uniqueId ) ?
795 ptr->uniqueId < p.
ptr->uniqueId : ptr < p.
ptr;
802 return ( ptr && p && ptr->uniqueId != p->uniqueId ) ?
803 ptr->uniqueId < p->uniqueId : ptr < p;
814 operator const T * ()
const {
return ptr; }
838 template <
typename T>
879 template <
typename UPtr>
889 template <
typename UPtr>
906 static const bool reference_counted =
true;
913 template <
typename T>
935 return p.operator->();
948 static const_pointer
create(const_reference t) {
960 template <
typename UPtr>
970 template <
typename UPtr>
981 return const_pointer(t);
987 static const bool reference_counted =
true;
994 template <
typename T>
1016 return p.operator->();
1027 template <
typename UPtr>
1029 transient_pointer t;
1037 static transient_pointer
ConstCast(transient_const_pointer c) {
1038 transient_pointer t;
1047 return transient_pointer(t);
1053 static const bool reference_counted =
false;
1060 template <
typename T>
1082 return p.operator->();
1093 template <
typename UPtr>
1095 transient_const_pointer t;
1103 template <
typename UPtr>
1105 transient_const_pointer t;
1113 static transient_const_pointer
PtrCast(
const T * t) {
1114 return transient_const_pointer(t);
1120 static const bool reference_counted =
false;
1133 template <
typename T>
1143 template <
typename T>
TransientRCPtr(const UPtr &u)
Copyconstructor for class UPtr which has operator-> defined resulting in a value implicitly convertib...
T value_type
Template argument typedef.
ConstRCPtr(const_pointer p)
Construction from real pointer.
ConstRCPtr< T >::value_type value_type
Template argument typedef.
The PtrTraits class is used everywhere in ThePEG to interface to the pointers which are handled...
pointer ptr
The actual pointer.
bool release(const ReferenceCounted *rcp)
Decrement the counter of a reference counted object.
static pointer ConstCast(const UPtr &u)
Cast away constness.
TransientRCPtr & operator=(const TransientRCPtr &p)
Assignment.
TransientConstRCPtr & assignDynamic(const UPtr &u)
Assignment from class UPtr which has operator-> defined resulting in a value which can be cast dynami...
TransientRCPtr & assignDynamic(const UPtr &u)
Assignment from class UPtr which has operator-> defined resulting in a value which can be cast dynami...
~TransientRCPtr()
Destructor.
static transient_pointer PtrCast(T *t)
Cast from a basic pointer.
RCPtr< T >::reference reference
Template argument typedef.
RCPtr & operator=(const UPtr &u)
Assignment from class UPtr which has operator-> defined resulting in a value implicitly convertible t...
T & reference
Template argument typedef.
ConstRCPtr< T > const_pointer
Template argument typedef.
void iterator_category
Template argument typedef.
reference operator*() const
Dereferencing.
void release()
Stop pointing to the current object and delete it if this was the last pointer to it...
bool operator!=(const_pointer p) const
Test for inequality of the underlying pointers.
TransientConstRCPtr< T > transient_const_pointer
Template argument typedef.
static transient_const_pointer ConstCast(const UPtr &u)
Cast away constness.
bool operator==(const UPtr &u) const
Test for equality of the underlying pointers.
bool operator!=(const TransientRCPtr &p) const
Test for inequality of the underlying pointers.
void swap(RCPtr &p)
Make p point to the object pointed to by this and vice versa.
static const_pointer create(const_reference t)
Create an copy of an object and return a pointer to it.
void increment(const ReferenceCounted *rcp)
Increment the counter of a reference counted object.
void release()
Stop pointing to the current object and delete it if this was the last pointer to it...
TransientRCPtr< T > transient_pointer
Template argument typedef.
TransientConstRCPtr & operator=(const TransientConstRCPtr &p)
Assignment.
void incrementReferenceCount() const
Increment the reference count.
TransientRCPtr & assignConst(const UPtr &u)
Assignment from class UPtr which has operator-> defined resulting in a value whcih can be const_cast'...
T value_type
Template argument typedef.
TransientRCPtr< T >::const_reference const_reference
Template argument typedef.
TransientConstRCPtr is a simple wrapper around a bare const pointer which can be assigned to and from...
static pointer PtrCast(T *t)
Cast from a basic pointer.
bool operator!=(const ConstRCPtr &p) const
Test for inequality of the underlying pointers.
ConstRCPtr< T > const_pointer
Template argument typedef.
TransientRCPtr is a simple wrapper around a bare pointer which can be assigned to and from an RCPtr a...
bool operator==(const_pointer p) const
Test for equality of the underlying pointers.
ConstRCPtr is a reference counted (smart) const pointer.
const T & const_reference
Template argument typedef.
static transient_pointer ConstCast(transient_const_pointer c)
Cast away constness.
void increment()
Increment the counter of the object pointed to.
ConstRCPtr< T >::const_reference const_reference
Template argument typedef.
bool operator==(const_pointer p) const
Test for equality of the underlying pointers.
This is the main namespace within which all identifiers in ThePEG are declared.
const_reference operator*() const
Dereferencing.
bool operator<(const_pointer p) const
Test for ordering.
void difference_type
Template argument typedef.
const T * const_pointer
Template argument typedef.
bool operator<(const_pointer p) const
Test for ordering.
T & reference
Template argument typedef.
ConstRCPtr & operator=(const UPtr &u)
Assignment from class UPtr which has operator-> defined resulting in a value implicitly convertible t...
static transient_pointer DynamicCast(const UPtr &u)
Cast dynamically.
const T * const_pointer
Template argument typedef.
RCPtr & assignDynamic(const UPtr &u)
Assignment from class UPtr which has operator-> defined resulting in a value which can be cast dynami...
TransientConstRCPtr(const UPtr &u)
Copyconstructor for class UPtr which has operator-> defined resulting in a value implicitly convertib...
const_pointer ptr
The actual pointer.
RCPtr(const UPtr &u)
Copy constructor for class UPtr which has operator-> defined resulting in a value implicitly converti...
RCPtr & assignConst(const UPtr &u)
Assignment from class UPtr which has operator-> defined resulting in a value which can be const_cast'...
bool operator!=(const UPtr &u) const
Test for inequality of the underlying pointers.
T value_type
Template argument typedef.
const T & const_reference
Template argument typedef.
ConstRCPtr()
Constructor for null pointer.
void swap(ConstRCPtr &p)
Make p point to the object pointed to by this and vice versa.
void iterator_category
Template argument typedef.
static T * barePointer(const RCPtr< T > &p)
Return the bare pointer of the given pointer object.
TransientRCPtr< T >::value_type value_type
Template argument typedef.
const T & const_reference
Template argument typedef.
const T & const_reference
Template argument typedef.
bool operator==(const_pointer p) const
Test for equality of the underlying pointers.
RCPtr & create(const_reference t)
Allocate and copy-construct an object of class T and point to it, possibly deleting the object pointe...
TransientConstRCPtr< T >::reference reference
Template argument typedef.
static pointer create(const_reference t)
Create an copy of an object and return a pointer to it.
ReferenceCounted::CounterType CounterType
Get counter type from ReferenceCounted class.
T * pointer
Template argument typedef.
bool operator!=(const UPtr &u) const
Test for inequality of the underlying pointers.
pointer operator->() const
Member access.
static const_pointer ConstCast(const UPtr &u)
Cast away constness.
TransientConstRCPtr< T > transient_const_pointer
Template argument typedef.
static const T * barePointer(const TransientConstRCPtr< T > &p)
Return the bare pointer of the given pointer object.
T * pointer
Template argument typedef.
bool operator!=(const UPtr &u) const
Test for inequality of the underlying pointers.
bool operator==(const TransientConstRCPtr &p) const
Test for equality of the underlying pointers.
reference operator*() const
Dereferencing.
TransientRCPtr< T > transient_pointer
Template argument typedef.
static void destroy(const_pointer)
Destroy the object pointed to.
bool operator<(const TransientRCPtr &p) const
Test for ordering.
static transient_const_pointer DynamicCast(const UPtr &u)
Cast dynamically.
bool operator<(const RCPtr &p) const
Test for ordering.
static const_pointer create()
Create an object and return a pointer to it.
T value_type
Template argument typedef.
TransientRCPtr< T > transient_pointer
Template argument typedef.
static RCPtr Create(const_reference t)
Allocate and copy-construct an object of class T and return a RCPtr to it.
RCPtr(const RCPtr &p)
Copy constructor.
TransientConstRCPtr & operator=(const UPtr &u)
Assignment from class UPtr which has operator-> defined resulting in a value implicitly convertible t...
void difference_type
Template argument typedef.
TransientRCPtr< T >::reference reference
Template argument typedef.
RCPtr & operator=(const RCPtr &p)
Assignment.
const_pointer ptr
The actual pointer.
const_reference operator*() const
Dereferencing.
ConstRCPtr & assignDynamic(const UPtr &u)
Assignment from class UPtr which has operator-> defined resulting in a value which can be cast dynami...
static void destroy(pointer)
Destroy the object pointed to.
bool operator!=(const UPtr &u) const
Test for inequality of the underlying pointers.
bool operator==(const_pointer p) const
Test for equality of the underlying pointers.
void iterator_category
Template argument typedef.
bool operator!() const
Returns true if the underlying pointer is null.
bool operator<(const TransientConstRCPtr &p) const
Test for ordering.
bool operator!() const
Returns true if the underlying pointer is null.
RCPtr is a reference counted (smart) pointer.
bool operator!() const
Returns true if the underlying pointer is null.
bool operator==(const UPtr &u) const
Test for equality of the underlying pointers.
bool operator==(const RCPtr &p) const
Test for equality of the underlying pointers.
const T * const_pointer
Template argument typedef.
RCPtr< T > pointer
Template argument typedef.
const_pointer operator->() const
Member access.
TransientConstRCPtr< T >::value_type value_type
Template argument typedef.
TransientRCPtr & operator=(const UPtr &u)
Assignment from class UPtr which has operator-> defined resulting in a value implicitly convertible t...
bool operator==(const UPtr &u) const
Test for equality of the underlying pointers.
static T * barePointer(const TransientRCPtr< T > &p)
Return the bare pointer of the given pointer object.
bool operator<(const_pointer p) const
Test for ordering.
TransientConstRCPtr(const_pointer p)
Construction from real pointer.
bool decrementReferenceCount() const
Decrement with the reference count.
static const T * barePointer(const ConstRCPtr< T > &p)
Return the bare pointer of the given pointer object.
RCPtrBase is the base class of RCPtr and ConstRCPtr which are reference counted (smart) pointers...
PtrTraitsType is an empty non-polymorphic base class for all PtrTraits classes.
bool operator==(const ConstRCPtr &p) const
Test for equality of the underlying pointers.
TransientRCPtr< T > transient_pointer
Template argument typedef.
unsigned int CounterType
The integer type used for counting.
const T * const_pointer
Template argument typedef.
ReferenceCounted must be the (virtual) base class of all classes which may be pointed to by the RCPtr...
bool operator!=(const TransientConstRCPtr &p) const
Test for inequality of the underlying pointers.
TransientConstRCPtr< T > transient_const_pointer
Template argument typedef.
bool operator!=(const_pointer p) const
Test for inequality of the underlying pointers.
TransientRCPtr(pointer p)
Construction from real pointer.
TransientRCPtr()
Constructor for null pointer.
T & reference
Template argument typedef.
bool operator==(const UPtr &u) const
Test for equality of the underlying pointers.
ConstRCPtr(const ConstRCPtr &p)
Copy constructor.
bool operator<(const ConstRCPtr &p) const
Test for ordering.
TransientConstRCPtr()
Constructor for null pointer.
static void destroy(transient_const_pointer)
Destroy the object pointed to.
~TransientConstRCPtr()
Destructor.
ConstRCPtr< T > const_pointer
Template argument typedef.
pointer ptr
The actual pointer.
T * pointer
Template argument typedef.
void increment()
Increment the counter of the object pointed to.
bool operator!=(const_pointer p) const
Test for inequality of the underlying pointers.
T & reference
Template argument typedef.
RCPtr< T > pointer
Template argument typedef.
ConstRCPtr & operator=(const ConstRCPtr &p)
Assignment.
const_pointer operator->() const
Member access.
RCPtr< T > pointer
Template argument typedef.
RCPtr< T >::const_reference const_reference
Template argument typedef.
TransientRCPtr(const TransientRCPtr &p)
Copy constructor.
RCPtr(pointer p)
Construction from real pointer.
void difference_type
Template argument typedef.
static transient_const_pointer PtrCast(const T *t)
Cast from a basic pointer.
T * pointer
Template argument typedef.
bool operator==(const TransientRCPtr &p) const
Test for equality of the underlying pointers.
ConstRCPtr< T > const_pointer
Template argument typedef.
TransientConstRCPtr(const TransientConstRCPtr &p)
Copy constructor.
bool operator!=(const_pointer p) const
Test for inequality of the underlying pointers.
bool operator<(const_pointer p) const
Test for ordering.
pointer operator->() const
Member access.
TransientConstRCPtr< T >::const_reference const_reference
Template argument typedef.
void difference_type
Template argument typedef.
bool operator!=(const RCPtr &p) const
Test for inequality of the underlying pointers.
static void destroy(transient_pointer)
Destroy the object pointed to.
void iterator_category
Template argument typedef.
ConstRCPtr(const UPtr &u)
Copyconstructor for class UPtr which has operator-> defined resulting in a value implicitly convertib...
static pointer DynamicCast(const UPtr &u)
Cast dynamically.
ConstRCPtr< T >::reference reference
Template argument typedef.
TransientConstRCPtr< T > transient_const_pointer
Template argument typedef.
RCPtr & create()
Allocate and construct an object of class T and point to it, possibly deleting the object pointed to ...
static pointer create()
Create an object and return a pointer to it.
static RCPtr Create()
Allocate and construct an object of class T and return a RCPtr to it.
RCPtr< T >::value_type value_type
Template argument typedef.
RCPtr< T > pointer
Template argument typedef.
static const_pointer DynamicCast(const UPtr &u)
Cast dynamically.
bool operator!() const
Returns true if the underlying pointer is null.
static const_pointer PtrCast(const T *t)
Cast from a basic pointer.