33 #if defined(CountedPtrOrPtr_RECURSES)
34 #error Recursive header files inclusion detected in CountedPtrOrPtr.h
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>
458 #include "DGtal/base/CountedPtrOrPtr.ih"
465 #undef CountedPtrOrPtr_RECURSES
Aim: Smart or simple const pointer on T. It can be a smart pointer based on reference counts or a sim...
Aim: Smart or simple pointer on T. It can be a smart pointer based on reference counts or a simple po...
Counter * counterPtr() const
CountedPtrOrPtr & operator=(const CountedPtr< T > &r)
CountedPtrOrPtr(const CountedPtr< T > &r) noexcept
unsigned int count() const
bool myIsCountedPtr
If true, 'this' pointer object is smart, otherwise it is simple.
void acquire(Counter *c) noexcept
CountedPtrOrPtr(T *p=0, bool isCountedPtr=true)
bool operator==(const T *other) const
T * operator->() const noexcept
CountedPtrOrPtr & operator=(const CountedPtrOrPtr &r)
CountedPtrOrPtr(const CountedPtrOrPtr &r) noexcept
bool operator!=(const T *other) const
void selfDisplay(std::ostream &out) const
bool unique() const noexcept
CountedPtr< T >::Counter Counter
The counter is the same as CountedPtr.
T & operator*() const noexcept
Aim: Smart pointer based on reference counts.
DGtal is the top-level namespace which contains all DGtal functions and types.
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 count
The number of CountedPtr pointing to this counter.