Panda3D
dtool
src
interrogatedb
extension.h
Go to the documentation of this file.
1
/**
2
* PANDA 3D SOFTWARE
3
* Copyright (c) Carnegie Mellon University. All rights reserved.
4
*
5
* All use of this software is subject to the terms of the revised BSD
6
* license. You should have received a copy of this license along
7
* with this source code in a file named "LICENSE."
8
*
9
* @file extension.h
10
* @author rdb
11
* @date 2013-09-11
12
*/
13
14
#ifndef EXTENSION_H
15
#define EXTENSION_H
16
17
#include "
dtoolbase.h
"
18
19
/**
20
* This is where all extensions should derive from. It defines the _self and
21
* _this members that can be used from the extension method.
22
*/
23
template
<
class
T>
24
class
EXPCL_INTERROGATEDB
ExtensionBase
{
25
public
:
26
T * _this;
27
};
28
29
/**
30
* The default class template does not define any methods. Classes that are
31
* extended should create a specialization of this class template.
32
*/
33
template
<
class
T>
34
class
Extension
:
public
ExtensionBase
<T> {
35
};
36
37
/**
38
* Creates a new extension object for the given pointer that can then be used
39
* to call extension methods, as follows: invoke_extension((MyClass)
40
* *ptr).method()
41
*/
42
template
<
class
T>
43
inline
Extension<T>
44
invoke_extension
(T *ptr) {
45
Extension<T>
ext;
46
ext._this = ptr;
47
return
ext;
48
}
49
50
/**
51
* The const version of the above function.
52
*/
53
template
<
class
T>
54
inline
const
Extension<T>
55
invoke_extension
(
const
T *ptr) {
56
Extension<T>
ext;
57
ext._this = (T *) ptr;
58
return
ext;
59
}
60
61
#endif
ExtensionBase
This is where all extensions should derive from.
Definition:
extension.h:24
dtoolbase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
invoke_extension
Extension< T > invoke_extension(T *ptr)
Creates a new extension object for the given pointer that can then be used to call extension methods,...
Definition:
extension.h:44
Extension
The default class template does not define any methods.
Definition:
extension.h:34
Generated on Wed Jan 23 2019 21:39:50 for Panda3D by
1.8.15