33 #if defined(CountedPtrOrPtr_RECURSES)
34 #error Recursive header files inclusion detected in CountedPtrOrPtr.h
35 #else // defined(CountedPtrOrPtr_RECURSES)
37 #define CountedPtrOrPtr_RECURSES
39 #if !defined CountedPtrOrPtr_h
41 #define CountedPtrOrPtr_h
46 #include "DGtal/base/Common.h"
47 #include "DGtal/base/CountedPtr.h"
52 template <
typename T>
class CountedConstPtrOrConstPtr;
124 if ( isCountedPtr ) {
128 myAny =
static_cast<void*
>( p );
190 if ( r.myIsCountedPtr )
acquire( r.counterPtr() );
191 else myAny = r.myAny;
372 return static_cast<T*
>(
myAny );
386 myAny =
static_cast<void*
>( c );
404 if (--counter->count == 0) {
449 template <
typename T>
451 operator<< ( std::ostream & out,
const CountedPtrOrPtr<T> &
object );
458 #include "DGtal/base/CountedPtrOrPtr.ih"
463 #endif // !defined CountedPtrOrPtr_h
465 #undef CountedPtrOrPtr_RECURSES
466 #endif // else defined(CountedPtrOrPtr_RECURSES)
CountedPtrOrPtr(const CountedPtr< T > &r) noexcept
bool myIsCountedPtr
If true, 'this' pointer object is smart, otherwise it is simple.
void selfDisplay(std::ostream &out) const
T * operator->() const noexcept
Counter * counterPtr() const
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
T * ptr
A pointer to a (shared) dynamically allocated object of type T.
unsigned int count() const
bool unique() const noexcept
T & operator*() const noexcept
Aim: Smart or simple const pointer on T. It can be a smart pointer based on reference counts or a sim...
CountedPtrOrPtr(T *p=0, bool isCountedPtr=true)
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: Smart or simple pointer on T. It can be a smart pointer based on reference counts or a simple po...
CountedPtr< T >::Counter Counter
The counter is the same as CountedPtr.
CountedPtrOrPtr(const CountedPtrOrPtr &r) noexcept
Aim: Smart pointer based on reference counts.
void acquire(Counter *c) noexcept
bool operator!=(const T *other) const
CountedPtrOrPtr & operator=(const CountedPtr< T > &r)
bool operator==(const T *other) const
CountedPtrOrPtr & operator=(const CountedPtrOrPtr &r)
unsigned count
The number of CountedPtr pointing to this counter.