Elementa v8.0.0
Minimalistic library for any C++ application (C++11 and up)
Loading...
Searching...
No Matches
clonable.h
Go to the documentation of this file.
1
3#include "elementa/license.inc"
4#include "elementa/checks.inc"
5
6#ifndef ELEMENTA_PATTERNS_CLONABLE_H
7#define ELEMENTA_PATTERNS_CLONABLE_H
8
9#include <memory>
11
12
13namespace elementa
14{
15
16namespace patterns
17{
18
74/* ***************************************************************************
75
76 Abstract class: Clonable
77
78*******************************************************************************/
79
81
83{
84 public:
85
87 virtual Clonable * clone(void) const = 0;
88
90
93 virtual Clonable * emptyClone(void) const
95
96};
97
98
99/* ***************************************************************************
100
101 Abstract template class: ClonableShared
102
103*******************************************************************************/
104
106
107template <class C>
109{
110 public:
111
113 virtual std::shared_ptr<C> clone(void) const = 0;
114
116
119 virtual std::shared_ptr<C> * emptyClone(void) const
121};
122
123 // Clonable
125
126
127} // end patterns namespace
128
129} // end elementa namespace
130
131
132#endif
133
134
virtual Clonable * clone(void) const =0
Derived classes must implement this method varying its return type.
virtual Clonable * emptyClone(void) const
Derived classes can override this to provide a clone that is "empty".
Definition: clonable.h:93
virtual std::shared_ptr< C > * emptyClone(void) const
Derived classes can override this to provide a clone that is "empty".
Definition: clonable.h:119
virtual std::shared_ptr< C > clone(void) const =0
Derived classes must implement this method, returning the same return.
Any class derived from this base class must be clonable.
Definition: clonable.h:83
Any class derived from this must be clonable.
Definition: clonable.h:109
#define ELE_CODE_UNIMPLEMENTED
To throw an unimplemented exception.
Definition: exceptions.h:289