28 #ifndef CASA_COUNTEDPTR_H
29 #define CASA_COUNTEDPTR_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>
274 #endif //# CASACORE_NO_AUTO_TEMPLATES
Bool null() const
Check to see if this CountedPtr is un-initialized, null.
std::shared_ptr< t > PointerRep
Helper class to make deletion of object optional.
Bool operator!=(const CountedPtr< t > &other) const
Non-equality operator which checks to see if two CountedPtrs are not pointing at the same thing...
t * get() const
Get the underlying pointer.
uInt nrefs() const
Sometimes it is useful to know if there is more than one reference made.
CountedPtr< U > dynamic_ptr_cast() const
CountedPtr< t > & operator=(const CountedPtr< TP > &that)
This assignment operator allows CountedPtrs to be copied from other CountedPtrs for which the pointer...
Bool operator!=(int ptr) const
CountedPtr< U > static_ptr_cast() const
Cast functions.
ABSTRACT CLASSES Deliberately vague to be general enough to allow for many different types of data
Referenced counted pointer for constant data.
CountedPtr()
This constructor allows for the creation of a null CountedPtr.
CountedPtr< U > const_ptr_cast() const
Bool operator==(int ptr) const
t * operator->() const
This dereferencing operator behaves as expected; it returns the pointer to the value being protected...
bool Bool
Define the standard types used by Casacore.
CountedPtr< T > static_pointer_cast(const CountedPtr< U > &that)
Cast the CountedPtr from one pointer type to another.
CountedPtr< t > & operator=(t *v)
This assignment operator allows the object to which the current CountedPtr points to be changed...
CountedPtr< T > const_pointer_cast(const CountedPtr< U > &that)
CountedPtr(t *val, Bool delit=True)
This constructor sets up a reference count for the val pointer.
CountedPtr(const CountedPtr< TP > &that)
This copy constructor allows CountedPtrs to be initialized from other CountedPtrs for which the point...
void reset(t *val, Bool delit=True)
Reset the pointer.
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 > dynamic_pointer_cast(const CountedPtr< U > &that)
CountedPtr(const std::shared_ptr< t > &rep)
Create from a shared_ptr.
Bool countedPtrShared()
A shared_ptr is used as implementation.
#define casacore
<X11/Intrinsic.h> #defines true, false, casacore::Bool, and String.
void operator()(T *data) const