Elementa v8.0.0
Minimalistic library for any C++ application (C++11 and up)
Loading...
Searching...
No Matches

Description


To declare classes whose derived classes must implement cloning.

Usage:

Author
Juan-Antonio Fernandez-Madrigal. http://jafma.net
Date
2019
Collaboration diagram for Clonable:

Classes

class  elementa::patterns::Clonable
 Any class derived from this base class must be clonable. More...
 
class  elementa::patterns::ClonableShared< C >
 Any class derived from this must be clonable. More...
 

Class Documentation

◆ elementa::patterns::Clonable

class elementa::patterns::Clonable

Any class derived from this base class must be clonable.

Use this class to produce clones that are plain pointers.

Definition at line 82 of file clonable.h.

Inheritance diagram for elementa::patterns::Clonable:

Public Member Functions

virtual Clonableclone (void) const =0
 Derived classes must implement this method varying its return type. More...
 
virtual ClonableemptyClone (void) const
 Derived classes can override this to provide a clone that is "empty". More...
 

Member Function Documentation

◆ clone()

virtual Clonable * elementa::patterns::Clonable::clone ( void  ) const
pure virtual

Derived classes must implement this method varying its return type.

Implemented in elementa::adts::graphs::SparseGraph< Vertex, Edge >, elementa::base::SerChLoc, and elementa::base::SerChLocText.

◆ emptyClone()

virtual Clonable * elementa::patterns::Clonable::emptyClone ( void  ) const
inlinevirtual

Derived classes can override this to provide a clone that is "empty".

"Emptiness" here means that the clone is not actually a clone of the derived object, but a new object of the same class of the derived object, without no content (i.e., right after creation).

Reimplemented in elementa::adts::graphs::SparseGraph< Vertex, Edge >.

Definition at line 93 of file clonable.h.

References ELE_CODE_UNIMPLEMENTED.

◆ elementa::patterns::ClonableShared

class elementa::patterns::ClonableShared
template<class C>
class elementa::patterns::ClonableShared< C >

Any class derived from this must be clonable.

Use this class to produce clones that are shared_ptr pointers.

Definition at line 108 of file clonable.h.

Inheritance diagram for elementa::patterns::ClonableShared< C >:

Public Member Functions

virtual std::shared_ptr< C > clone (void) const =0
 Derived classes must implement this method, returning the same return.
 
virtual std::shared_ptr< C > * emptyClone (void) const
 Derived classes can override this to provide a clone that is "empty". More...
 

Member Function Documentation

◆ emptyClone()

template<class C >
virtual std::shared_ptr< C > * elementa::patterns::ClonableShared< C >::emptyClone ( void  ) const
inlinevirtual

Derived classes can override this to provide a clone that is "empty".

"Emptiness" here means that the clone is not actually a clone of the derived object, but a new object of the same class of the derived object, without no content (i.e., right after creation).

Definition at line 119 of file clonable.h.

References ELE_CODE_UNIMPLEMENTED.