28 #ifndef CASA_COUNTEDPTR_H 29 #define CASA_COUNTEDPTR_H 31 #include <casacore/casa/aips.h> 33 #if (defined(AIPS_CXX11) || (defined(__APPLE_CC__) && __APPLE_CC__ > 5621)) 35 #define SHARED_PTR std::shared_ptr 36 #define DYNAMIC_POINTER_CAST std::dynamic_pointer_cast 37 #define CONST_POINTER_CAST std::const_pointer_cast 38 #define STATIC_POINTER_CAST std::static_pointer_cast 41 #define SHARED_PTR std::tr1::shared_ptr 42 #define DYNAMIC_POINTER_CAST std::tr1::dynamic_pointer_cast 43 #define CONST_POINTER_CAST std::tr1::const_pointer_cast 44 #define STATIC_POINTER_CAST std::tr1::static_pointer_cast 57 void throw_Null_CountedPtr_dereference_error();
129 template<
typename TP>
146 template<
typename TP>
172 throw_Null_CountedPtr_dereference_error();
196 return (
get() == other.
get());
200 return (ptr == 0 &&
get() == 0);
210 return (ptr != 0 ||
get() != 0);
244 {
return get() == 0; }
247 operator bool()
const 248 {
return get() != 0; }
264 template<
typename T,
typename U>
267 template<
typename T,
typename U>
270 template<
typename T,
typename U>
278 #ifndef CASACORE_NO_AUTO_TEMPLATES 279 #include <casacore/casa/Utilities/CountedPtr.tcc> 280 #endif //# CASACORE_NO_AUTO_TEMPLATES CountedPtr< t > & operator=(const CountedPtr< TP > &that)
This assignment operator allows CountedPtrs to be copied from other CountedPtrs for which the pointer...
Bool operator==(const CountedPtr< t > &other) const
Equality operator which checks to see if two CountedPtrs are pointing at the same thing...
CountedPtr(t *val, Bool delit=True)
This constructor sets up a reference count for the val pointer.
CountedPtr(const SHARED_PTR< t > &rep)
Create from a shared_ptr.
t * get() const
Get the underlying pointer.
~CountedPtr()
This destructor only deletes the really stored data when it was initialized as deletable and the refe...
Bool null() const
Check to see if this CountedPtr is un-initialized, null.
Helper class to make deletion of object optional.
CountedPtr(const CountedPtr< TP > &that)
This copy constructor allows CountedPtrs to be initialized from other CountedPtrs for which the point...
CountedPtr< t > & operator=(t *v)
This assignment operator allows the object to which the current CountedPtr points to be changed...
SHARED_PTR< t > PointerRep
t & operator*() const
The CountedPtr indirection operator simply returns a reference to the value being protected...
Bool operator!=(int ptr) const
void reset(t *val, Bool delit=True)
Reset the pointer.
CountedPtr< U > dynamic_ptr_cast() const
Referenced counted pointer for constant data.
uInt nrefs() const
Sometimes it is useful to know if there is more than one reference made.
Bool operator==(int ptr) const
CountedPtr< U > const_ptr_cast() const
bool Bool
Define the standard types used by Casacore.
Bool operator!=(const CountedPtr< t > &other) const
Non-equality operator which checks to see if two CountedPtrs are not pointing at the same thing...
CountedPtr< T > static_pointer_cast(const CountedPtr< U > &that)
Cast the CountedPtr from one pointer type to another.
CountedPtr< T > const_pointer_cast(const CountedPtr< U > &that)
CountedPtr()
This constructor allows for the creation of a null CountedPtr.
CountedPtr< U > static_ptr_cast() const
Cast functions.
void operator()(T *data) const
t * operator->() const
This dereferencing operator behaves as expected; it returns the pointer to the value being protected...
CountedPtr< T > dynamic_pointer_cast(const CountedPtr< U > &that)
this file contains all the compiler specific defines
Bool countedPtrShared()
A shared_ptr is used as implementation.