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"
265 template <
typename T>
286 case PTR: sp =
"PTR";
break;
288 case COW_PTR: sp =
"COW_PTR";
break;
293 default: sp =
"UNKNOWN";
break;
295 trace.
info() <<
"[Clone<T>::" << method <<
" param="
296 << sp <<
"]" << std::endl;
384 inline operator T()
const
389 return T( *
static_cast< const T*
>(
myPtr ) );
391 TempPtr tmp(
const_cast< T*
>(
static_cast< const T*
>(
myPtr ) ) );
392 return T( *
static_cast< const T*
>(
myPtr ) );
399 return T( std::move( *
const_cast<T*
>(
static_cast< const T*
>(
myPtr ) ) ) );
400 default: ASSERT(
false &&
"[Clone::operator T() const] Invalid cast for given type. " );
401 return T( *
static_cast< const T*
>(
myPtr ) );
422 return CowPtr<T>(
const_cast<T*
>(
static_cast< const T*
>(
myPtr ) ) );
428 return CowPtr<T>(
new T( std::move( *
const_cast<T*
>(
static_cast< const T*
>(
myPtr ) ) ) ) );
429 default: ASSERT(
false &&
"[Clone::operator CowPtr<T>() const] Invalid cast for given type. " );
457 return CountedPtr<T>(
new T( std::move( *
const_cast<T*
>(
static_cast< const T*
>(
myPtr ) ) ) ) );
458 default: ASSERT(
false &&
"[Clone::operator CountedPtr<T>() const] Invalid cast for given type. " );
481 return new T( *
static_cast< const T*
>(
myPtr ) );
483 return const_cast<T*
>(
static_cast< const T*
>(
myPtr ) );
485 return new T( *(
static_cast< const CowPtr<T>*
>(
myPtr )->get() ) );
489 return new T( std::move( *
const_cast<T*
>(
static_cast< const T*
>(
myPtr ) ) ) );
490 default: ASSERT(
false &&
"[T* Clone::operator&() const] Invalid address for given type. " );
Aim: This class encapsulates its parameter class to indicate that the given parameter is required to ...
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.