28 #ifndef CASA_COUNTEDPTR_H
29 #define CASA_COUNTEDPTR_H
31 #include <casacore/casa/aips.h>
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
51 void throw_Null_CountedPtr_dereference_error();
123 template<
typename TP>
140 template<
typename TP>
166 throw_Null_CountedPtr_dereference_error();
190 return (
get() == other.
get());
194 return (ptr == 0 &&
get() == 0);
204 return (ptr != 0 ||
get() != 0);
238 {
return get() == 0; }
241 operator bool()
const
242 {
return get() != 0; }
258 template<
typename T,
typename U>
260 {
return that.template static_ptr_cast<T>(); }
261 template<
typename T,
typename U>
263 {
return that.template const_ptr_cast<T>(); }
264 template<
typename T,
typename U>
266 {
return that.template dynamic_ptr_cast<T>(); }
272 #ifndef CASACORE_NO_AUTO_TEMPLATES
273 #include <casacore/casa/Utilities/CountedPtr.tcc>
Helper class to make deletion of object optional.
void operator()(T *data) const
Referenced counted pointer for constant data.
std::shared_ptr< t > PointerRep
t & operator*() const
The CountedPtr indirection operator simply returns a reference to the value being protected.
Bool operator==(const CountedPtr< t > &other) const
Equality operator which checks to see if two CountedPtrs are pointing at the same thing.
~CountedPtr()
This destructor only deletes the really stored data when it was initialized as deletable and the refe...
CountedPtr< t > & operator=(t *v)
This assignment operator allows the object to which the current CountedPtr points to be changed.
CountedPtr< U > dynamic_ptr_cast() const
CountedPtr< U > static_ptr_cast() const
Cast functions.
CountedPtr< t > & operator=(const CountedPtr< TP > &that)
This assignment operator allows CountedPtrs to be copied from other CountedPtrs for which the pointer...
CountedPtr(const std::shared_ptr< t > &rep)
Create from a shared_ptr.
t * operator->() const
This dereferencing operator behaves as expected; it returns the pointer to the value being protected,...
void reset(t *val, Bool delit=True)
Reset the pointer.
t * get() const
Get the underlying pointer.
Bool operator!=(int ptr) const
Bool operator==(int ptr) const
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< U > const_ptr_cast() const
CountedPtr(const CountedPtr< TP > &that)
This copy constructor allows CountedPtrs to be initialized from other CountedPtrs for which the point...
CountedPtr(t *val, Bool delit=True)
This constructor sets up a reference count for the val pointer.
CountedPtr()
This constructor allows for the creation of a null CountedPtr.
uInt nrefs() const
Sometimes it is useful to know if there is more than one reference made.
this file contains all the compiler specific defines
CountedPtr< T > const_pointer_cast(const CountedPtr< U > &that)
CountedPtr< T > static_pointer_cast(const CountedPtr< U > &that)
Cast the CountedPtr from one pointer type to another.
Bool countedPtrShared()
A shared_ptr is used as implementation.
CountedPtr< T > dynamic_pointer_cast(const CountedPtr< U > &that)
bool Bool
Define the standard types used by Casacore.