33 #if defined(CountedConstPtrOrConstPtr_RECURSES) 34 #error Recursive header files inclusion detected in CountedConstPtrOrConstPtr.h 35 #else // defined(CountedConstPtrOrConstPtr_RECURSES) 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 ) );
327 const T*
get()
const throw()
397 ASSERT( myIsCountedPtr );
398 return static_cast<Counter*
>(
myAny );
409 ASSERT( ! myIsCountedPtr );
410 return static_cast<T*
>(
myAny );
423 ASSERT( myIsCountedPtr );
424 myAny =
static_cast<void*
>( c );
439 ASSERT( myIsCountedPtr );
442 if (--counter->
count == 0) {
487 template <
typename T>
489 operator<< ( std::ostream & out, const CountedConstPtrOrConstPtr<T> & object );
496 #include "DGtal/base/CountedConstPtrOrConstPtr.ih" 501 #endif // !defined CountedConstPtrOrConstPtr_h 503 #undef CountedConstPtrOrConstPtr_RECURSES 504 #endif // else defined(CountedConstPtrOrConstPtr_RECURSES) void selfDisplay(std::ostream &out) const
CountedConstPtrOrConstPtr(const CountedPtrOrPtr< T > &r)
~CountedConstPtrOrConstPtr()
Aim: Smart pointer based on reference counts.
bool myIsCountedPtr
If true, 'this' pointer object is smart, otherwise it is simple.
const T * operator->() const
Aim: Smart or simple const pointer on T. It can be a smart pointer based on reference counts or a sim...
const T & operator*() const
Counter * counterPtr() const
CountedPtr< T >::Counter Counter
The counter is the same as CountedPtr.
T * ptr
A pointer to a (shared) dynamically allocated object of type T.
unsigned int count() const
CountedConstPtrOrConstPtr(const T *p=0, bool isCountedPtr=true)
bool operator==(const T *other) const
Aim: Smart or simple pointer on T. It can be a smart pointer based on reference counts or a simple po...
CountedConstPtrOrConstPtr & operator=(const CountedPtrOrPtr< T > &r)
CountedConstPtrOrConstPtr & operator=(const CountedPtr< T > &r)
Counter * counterPtr() const
DGtal is the top-level namespace which contains all DGtal functions and types.
CountedConstPtrOrConstPtr & operator=(const CountedConstPtrOrConstPtr &r)
CountedConstPtrOrConstPtr(const CountedPtr< T > &r)
CountedConstPtrOrConstPtr(const CountedConstPtrOrConstPtr &r)
unsigned count
The number of CountedPtr pointing to this counter.
bool myIsCountedPtr
If true, 'this' pointer object is smart, otherwise it is simple.
bool operator!=(const T *other) const
Counter * myCounter
The counter object pointed by this smart pointer.