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"
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 & operator=(const CountedConstPtrOrConstPtr &r)
CountedConstPtrOrConstPtr(const CountedPtrOrPtr< T > &r) noexcept
CountedConstPtrOrConstPtr & operator=(const CountedPtrOrPtr< T > &r)
CountedConstPtrOrConstPtr(const CountedPtr< T > &r) noexcept
Counter * counterPtr() const
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.
void acquire(Counter *c) noexcept
CountedConstPtrOrConstPtr & operator=(const CountedPtr< T > &r)
const T * get() const noexcept
unsigned int count() const
void selfDisplay(std::ostream &out) const
const T * operator->() const noexcept
CountedConstPtrOrConstPtr(const CountedConstPtrOrConstPtr &r) noexcept
const T & operator*() const noexcept
bool unique() const noexcept
CountedPtr< T >::Counter Counter
The counter is the same as CountedPtr.
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 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.