31#if defined(Clone_RECURSES)
32#error Recursive header files inclusion detected in Clone.h
44#include "DGtal/base/Common.h"
45#include "DGtal/base/CountedPtr.h"
46#include "DGtal/base/CowPtr.h"
264 template <
typename T>
285 case PTR: sp =
"PTR";
break;
287 case COW_PTR: sp =
"COW_PTR";
break;
292 default: sp =
"UNKNOWN";
break;
294 trace.info() <<
"[Clone<T>::" << method <<
" param="
295 << sp <<
"]" << std::endl;
383 inline operator T()
const
388 return T( *
static_cast< const T*
>(
myPtr ) );
390 TempPtr tmp(
const_cast< T*
>(
static_cast< const T*
>(
myPtr ) ) );
391 return T( *
static_cast< const T*
>(
myPtr ) );
398 return T( std::move( *
const_cast<T*
>(
static_cast< const T*
>(
myPtr ) ) ) );
399 default: ASSERT(
false &&
"[Clone::operator T() const] Invalid cast for given type. " );
400 return T( *
static_cast< const T*
>(
myPtr ) );
383 inline operator T()
const {
…}
421 return CowPtr<T>(
const_cast<T*
>(
static_cast< const T*
>(
myPtr ) ) );
427 return CowPtr<T>(
new T( std::move( *
const_cast<T*
>(
static_cast< const T*
>(
myPtr ) ) ) ) );
428 default: ASSERT(
false &&
"[Clone::operator CowPtr<T>() const] Invalid cast for given type. " );
456 return CountedPtr<T>(
new T( std::move( *
const_cast<T*
>(
static_cast< const T*
>(
myPtr ) ) ) ) );
457 default: ASSERT(
false &&
"[Clone::operator CountedPtr<T>() const] Invalid cast for given type. " );
480 return new T( *
static_cast< const T*
>(
myPtr ) );
482 return const_cast<T*
>(
static_cast< const T*
>(
myPtr ) );
484 return new T( *(
static_cast< const CowPtr<T>*
>(
myPtr )->get() ) );
488 return new T( std::move( *
const_cast<T*
>(
static_cast< const T*
>(
myPtr ) ) ) );
489 default: ASSERT(
false &&
"[T* Clone::operator&() const] Invalid address for given type. " );
Clone & operator=(const Clone &other)
const Parameter myParam
Characterizes the type of the input parameter at clone instanciation.
void display(const std::string &method, Parameter p) const
Clone(const CowPtr< T > &ptrT)
Clone(const Clone &other)
const void *const myPtr
Stores the address of the input parameter for further use.
Clone(const CountedPtr< T > &ptrT)
Parameter
Internal class that allows to distinguish the different types of parameters.
@ COUNTED_CONST_PTR_OR_CONST_PTR
Aim: Smart pointer based on reference counts.
Aim: Copy on write shared pointer.
DGtal is the top-level namespace which contains all DGtal functions and types.
Internal class that is used for a late deletion of an acquired pointer.
T * _ptr
Acquired pointer.