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"
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...
CountedPtrOrPtr(const CountedPtr< T > &r) noexcept
unsigned int count() const
Counter * counterPtr() const
bool myIsCountedPtr
If true, 'this' pointer object is smart, otherwise it is simple.
CountedPtrOrPtr & operator=(const CountedPtr< T > &r)
void acquire(Counter *c) noexcept
CountedPtrOrPtr(T *p=0, bool isCountedPtr=true)
CountedPtrOrPtr & operator=(const CountedPtrOrPtr &r)
bool operator==(const T *other) const
T & operator*() const noexcept
CountedPtrOrPtr(const CountedPtrOrPtr &r) noexcept
bool operator!=(const T *other) const
void selfDisplay(std::ostream &out) const
T * operator->() const noexcept
bool unique() const noexcept
CountedPtr< T >::Counter Counter
The counter is the same as CountedPtr.
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 ClosedIntegerHalfPlane< TSpace > &object)
T * ptr
A pointer to a (shared) dynamically allocated object of type T.
unsigned count
The number of CountedPtr pointing to this counter.