DART  6.7.3
dart::common::Cloneable< T > Class Template Referenceabstract

Cloneable is a CRTP base class that provides an interface for easily creating data structures that are meant to be extended. More...

#include <Cloneable.hpp>

Public Member Functions

 Cloneable ()=default
 Default constructor. More...
 
virtual ~Cloneable ()=default
 Virtual destructor. More...
 
 Cloneable (const Cloneable &doNotCopy)=delete
 Do not copy this class directly, use clone() or copy() instead. More...
 
Cloneableoperator= (const Cloneable &doNotCopy)=delete
 Do not copy this class directly, use clone() or copy() instead. More...
 
virtual std::unique_ptr< T > clone () const =0
 Implement this function to allow your Cloneable type to be copied safely. More...
 
virtual void copy (const T &anotherCloneable)=0
 Copy the contents of anotherCloneable into this one. More...
 

Detailed Description

template<class T>
class dart::common::Cloneable< T >

Cloneable is a CRTP base class that provides an interface for easily creating data structures that are meant to be extended.

Ordinary copying does not work with extended data structures, because information from the derived classes will typically be lost during a copy. The Cloneable class provides an interface for creating a new copy of an extended data structure, as well as copying information between two extended data structures of the same type.

Constructor & Destructor Documentation

◆ Cloneable() [1/2]

template<class T >
dart::common::Cloneable< T >::Cloneable ( )
default

Default constructor.

◆ ~Cloneable()

template<class T >
virtual dart::common::Cloneable< T >::~Cloneable ( )
virtualdefault

Virtual destructor.

◆ Cloneable() [2/2]

template<class T >
dart::common::Cloneable< T >::Cloneable ( const Cloneable< T > &  doNotCopy)
delete

Do not copy this class directly, use clone() or copy() instead.

Member Function Documentation

◆ clone()

template<class T >
virtual std::unique_ptr<T> dart::common::Cloneable< T >::clone ( ) const
pure virtual

Implement this function to allow your Cloneable type to be copied safely.

◆ copy()

template<class T >
virtual void dart::common::Cloneable< T >::copy ( const T &  anotherCloneable)
pure virtual

Copy the contents of anotherCloneable into this one.

◆ operator=()

template<class T >
Cloneable& dart::common::Cloneable< T >::operator= ( const Cloneable< T > &  doNotCopy)
delete

Do not copy this class directly, use clone() or copy() instead.