-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelegate.h
49 lines (40 loc) · 1.18 KB
/
delegate.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//-----------------------------------------------------------------------------
// Application Core Library
// Copyright (c) 2009-2012 DuJardin Consulting, LLC.
// Portions Copyright (c) 2009 GarageGames, Inc.
//-----------------------------------------------------------------------------
#ifndef _UTIL_DELEGATE_H_
#define _UTIL_DELEGATE_H_
#include "core/util/FastDelegate.h"
/// Define a Delegate
///
/// This macro allows translation of Delegate definitions into a target
/// delegate implementation.
///
/// By default ACLib uses a @see FastDelegate implementation
///
namespace ACLib
{
#define Delegate fastdelegate::FastDelegate
typedef fastdelegate::DelegateMemento DelegateMemento;
template<class T>
class DelegateRemapper : public DelegateMemento
{
public:
DelegateRemapper() : mOffset(0) {}
void set(T * t, const DelegateMemento & memento)
{
SetMementoFrom(memento);
if (m_pthis)
mOffset = ((int)m_pthis) - ((int)t);
}
void rethis(T * t)
{
if (m_pthis)
m_pthis = (fastdelegate::detail::GenericClass *)(mOffset + (int)t);
}
protected:
int mOffset;
};
};
#endif