33#if defined(CountedConstPtrOrConstPtr_RECURSES)
34#error Recursive header files inclusion detected in CountedConstPtrOrConstPtr.h
37#define CountedConstPtrOrConstPtr_RECURSES
39#if !defined CountedConstPtrOrConstPtr_h
41#define CountedConstPtrOrConstPtr_h
46#include "DGtal/base/Common.h"
47#include "DGtal/base/CountedPtr.h"
48#include "DGtal/base/CountedPtrOrPtr.h"
94 class CountedConstPtrOrConstPtr
122 if ( isCountedPtr ) {
123 if (p)
myAny =
static_cast<void*
>(
new Counter(
const_cast<T*
>( p ) ) );
126 myAny =
const_cast<void*
>(
static_cast<const void*
>( p ) );
206 if ( r.myIsCountedPtr )
acquire( r.counterPtr() );
207 else myAny = r.myAny;
228 if ( r.myIsCountedPtr )
acquire( r.counterPtr() );
229 else myAny = r.myAny;
327 const T*
get() const noexcept
410 return static_cast<T*
>(
myAny );
424 myAny =
static_cast<void*
>( c );
442 if (--counter->count == 0) {
487 template <
typename T>
496#include "DGtal/base/CountedConstPtrOrConstPtr.ih"
503#undef CountedConstPtrOrConstPtr_RECURSES
Aim: Smart or simple const pointer on T. It can be a smart pointer based on reference counts or a sim...
~CountedConstPtrOrConstPtr()
CountedConstPtrOrConstPtr(const T *p=0, bool isCountedPtr=true)
CountedConstPtrOrConstPtr(const CountedPtrOrPtr< T > &r) noexcept
CountedConstPtrOrConstPtr(const CountedPtr< T > &r) noexcept
bool operator!=(const T *other) const
bool operator==(const T *other) const
bool myIsCountedPtr
If true, 'this' pointer object is smart, otherwise it is simple.
const T * operator->() const noexcept
const T & operator*() const noexcept
void acquire(Counter *c) noexcept
CountedPtr< T >::Counter Counter
The counter is the same as CountedPtr.
CountedConstPtrOrConstPtr & operator=(const CountedPtr< T > &r)
unsigned int count() const
CountedConstPtrOrConstPtr & operator=(const CountedPtrOrPtr< T > &r)
void selfDisplay(std::ostream &out) const
CountedConstPtrOrConstPtr(const CountedConstPtrOrConstPtr &r) noexcept
CountedConstPtrOrConstPtr & operator=(const CountedConstPtrOrConstPtr &r)
Counter * counterPtr() const
bool unique() const noexcept
const T * get() const noexcept
Aim: Smart or simple pointer on T. It can be a smart pointer based on reference counts or a simple po...
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.