VR-Link API Documentation for HLA 1.3
Home
Namespaces
Classes
Files
Examples
Libraries
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
include
managedInterface
delegate.h
Go to the documentation of this file.
1
/*********************************************************************************
2
** Copyright (c) 2014 MAK Technologies, Inc.
3
** All rights reserved.
4
*********************************************************************************/
5
6
#pragma once
7
12
13
class
DtMessage
;
14
16
template
<
typename
Ret,
typename
Param0>
17
class
Callback
18
{
19
public
:
20
virtual
Ret
invoke
(Param0 param0) = 0;
21
};
22
23
26
template
<
typename
Ret,
typename
Param0>
27
class
StaticFunctionCallback
:
public
Callback
<Ret, Param0>
28
{
29
private
:
30
Ret (*
func_
)(Param0);
31
32
public
:
33
StaticFunctionCallback
(Ret (*func)(Param0))
34
:
func_
(func)
35
{}
36
37
virtual
Ret
invoke
(Param0 param0)
38
{
39
return
(*
func_
)(param0);
40
}
41
};
42
43
46
template
<
typename
Ret,
typename
Param0,
typename
T,
typename
Method>
47
class
MethodCallback
:
public
Callback
<Ret, Param0>
48
{
49
private
:
50
void
*
object_
;
51
Method
method_
;
52
53
public
:
54
MethodCallback
(
void
*
object
, Method method)
55
:
object_
(object)
56
,
method_
(method)
57
{}
58
59
virtual
Ret
invoke
(Param0 param0)
60
{
61
T *obj =
static_cast<
T *
>
(
object_
);
62
return
(obj->*
method_
)(param0);
63
}
64
};
65
68
template
<
typename
Ret,
typename
Param0>
69
class
DtDelegate
70
{
71
private
:
72
Callback<Ret, Param0>
*
callback_
;
73
74
public
:
76
DtDelegate
(Ret (*func)(Param0))
77
:
callback_
(new
StaticFunctionCallback
<Ret, Param0>(func))
78
{}
79
81
template
<
typename
T,
typename
Method>
82
DtDelegate
(T *
object
, Method method)
83
:
callback_
(new
MethodCallback
<Ret, Param0, T, Method>(object, method))
84
{}
85
87
~DtDelegate
(
void
) {
delete
callback_
; }
88
90
Ret
operator()
(Param0 param0)
91
{
92
return
callback_
->invoke(param0);
93
}
94
};
95
98
typedef
DtDelegate<void, DtMessage*>
DtMessageDelegate
;
Document ID: Generated on Mon Apr 8 04:49:21 EDT 2019 from SVN revision 197403
Copyright © 2005-2016 VT MÄK. All Rights Reserved (
www.mak.com
)