Jpp
software
JLang
JClonable.hh
Go to the documentation of this file.
1
#ifndef __JLANG__JCLONABLE__
2
#define __JLANG__JCLONABLE__
3
4
#include "
JLang/JNullType.hh
"
5
6
/**
7
* \author mdejong
8
*/
9
10
namespace
JLANG
{}
11
namespace
JPP
{
using namespace
JLANG
; }
12
13
namespace
JLANG
{
14
15
16
/**
17
* Template class for object cloning.
18
*/
19
template
<
class
JClonable_t,
class
JDerived_t = JNullType>
20
struct
JClonable
;
21
22
23
/**
24
* Template specialisation to define base class for interface of object cloning.
25
*/
26
template
<
class
JClonable_t>
27
struct
JClonable
<JClonable_t,
JNullType
>
28
{
29
/**
30
* Type definition of return value of method clone().
31
*/
32
typedef
JClonable_t*
clone_type
;
33
34
35
/**
36
* Virtual destructor.
37
*/
38
virtual
~JClonable
()
39
{}
40
41
42
/**
43
* Get clone of this object.
44
*
45
* \return pointer to newly created object
46
*/
47
virtual
clone_type
clone
()
const
= 0;
48
};
49
50
51
/**
52
* Template specialisation to define base class for implementation of object cloning.
53
*
54
* This class derives from the specified clonable class and implements the method clone.
55
*/
56
template
<
class
JClonable_t,
class
JDerived_t>
57
struct
JClonable
:
58
public
JClonable_t
59
{
60
61
typedef
typename
JClonable<JClonable_t>::clone_type
clone_type
;
62
63
64
/**
65
* Get clone of this object.
66
*
67
* \return pointer to newly created object
68
*/
69
virtual
clone_type
clone
()
const
70
{
71
return
new
JDerived_t(static_cast<const JDerived_t&>(*
this
));
72
}
73
};
74
}
75
76
77
#endif
JLANG::JClonable< JClonable_t, JNullType >::clone_type
JClonable_t * clone_type
Type definition of return value of method clone().
Definition:
JClonable.hh:32
JLANG::JNullType
Auxiliary class for no type definition.
Definition:
JNullType.hh:19
JLANG::JClonable::clone
virtual clone_type clone() const
Get clone of this object.
Definition:
JClonable.hh:69
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition:
JAAnetToolkit.hh:37
JLANG::JClonable::clone_type
JClonable< JClonable_t >::clone_type clone_type
Definition:
JClonable.hh:61
JLANG::JClonable< JClonable_t, JNullType >::~JClonable
virtual ~JClonable()
Virtual destructor.
Definition:
JClonable.hh:38
JNullType.hh
JLANG
Auxiliary classes and methods for language specific functionality.
Definition:
JAbstractClass.hh:10
JLANG::JClonable
Template class for object cloning.
Definition:
JClonable.hh:20
Generated by
1.8.16