![]() |
Elementa v8.0.0
Minimalistic library for any C++ application (C++11 and up)
|
To declare classes whose derived classes must implement cloning.
Usage:
\code class YourClass: public Clonable ... \endcode
\code
class YourClass: public Clonable
{
public:
...
YourClass * clone(void) const { return(new YourClass{*this}); }
// Notice how the return type can be any one derived from
// Clonable.
...
};
\endcode

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 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.

Public Member Functions | |
| virtual Clonable * | clone (void) const =0 |
| Derived classes must implement this method varying its return type. More... | |
| virtual Clonable * | emptyClone (void) const |
| Derived classes can override this to provide a clone that is "empty". More... | |
|
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.
|
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.
| class elementa::patterns::ClonableShared |
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.

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... | |
|
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.