sigx++
2.0.1
Main Page
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
sigx
signal_source_obj_mem.h
Go to the documentation of this file.
1
#ifndef _SIGX_SIGNAL_SOURCE_OBJ_MEM_HPP_
2
#define _SIGX_SIGNAL_SOURCE_OBJ_MEM_HPP_
3
4
/*
5
* Copyright 2005 Klaus Triendl
6
*
7
* This library is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Library General Public
9
* License as published by the Free Software Foundation; either
10
* version 2 of the License, or (at your option) any later version.
11
*
12
* This library is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Library General Public License for more details.
16
*
17
* You should have received a copy of the GNU Library General Public
18
* License along with this library; if not, write to the Free
19
* Software Foundation, 51 Franklin Street, Fifth Floor,
20
* Boston, MA 02110-1301, USA.
21
*/
22
23
#include <sigc++/functors/functor_trait.h>
24
#include <sigxconfig.h>
25
#include <
sigx/signal_source_base.h
>
26
27
28
namespace
sigx
29
{
30
33
template
<
typename
T_obj,
typename
T_signal>
34
struct
signal_source_obj_mem
:
public
signal_source_base
35
{
36
typedef
signal_source_obj_mem<T_obj, T_signal>
self_type
;
37
typedef
T_signal T_obj::*
typed_signal_ptr
;
38
39
signal_source_obj_mem
(T_obj* _A_obj,
typed_signal_ptr
_A_sig):
40
signal_source_base
(reinterpret_cast<
hook
>(&
self_type
::
get_signal
)),
41
m_obj
(_A_obj),
42
m_sig
(_A_sig)
43
{}
44
45
static
T_signal
get_signal
(
signal_source_ptr
base)
46
{
47
self_type
*
const
this_ =
static_cast<
self_type
*
>
(base);
48
const
typed_signal_ptr
sig = this_->
m_sig
;
49
return
this_->
m_obj
->*sig;
50
}
51
52
T_obj*
m_obj
;
53
typed_signal_ptr
m_sig
;
54
};
55
59
template
<
typename
T_obj,
typename
T_signal>
60
struct
signal_source_pobj_mem
:
public
signal_source_base
61
{
62
typedef
signal_source_pobj_mem<T_obj, T_signal>
self_type
;
63
typedef
T_signal T_obj::*
typed_signal_ptr
;
64
65
signal_source_pobj_mem
(T_obj*
const
& _A_obj,
typed_signal_ptr
_A_sig):
66
signal_source_base
(reinterpret_cast<
hook
>(&
self_type
::
get_signal
)),
67
m_obj
(_A_obj),
68
m_sig
(_A_sig)
69
{}
70
71
static
T_signal
get_signal
(
signal_source_ptr
base)
72
{
73
self_type
*
const
this_ =
static_cast<
self_type
*
>
(base);
74
const
typed_signal_ptr
sig = this_->
m_sig
;
75
return
this_->
m_obj
->*sig;
76
}
77
78
T_obj*
const
&
m_obj
;
79
typed_signal_ptr
m_sig
;
80
};
81
86
template
<
typename
T_obj,
typename
T_functor,
typename
T_signal>
87
struct
signal_source_pobj_mem_fun
:
public
signal_source_base
88
{
89
typedef
signal_source_pobj_mem_fun<T_obj, T_functor, T_signal>
self_type
;
90
typedef
typename
sigc::functor_trait<T_functor>::functor_type
functor_type
;
91
92
signal_source_pobj_mem_fun
(T_obj*
const
& _A_obj,
const
T_functor& _A_mem_func):
93
signal_source_base
(reinterpret_cast<
hook
>(&
self_type
::
get_signal
)),
94
m_obj
(_A_obj),
95
m_mem_func
(_A_mem_func)
96
{}
97
98
static
T_signal
get_signal
(
signal_source_ptr
base)
99
{
100
self_type
* this_ =
static_cast<
self_type
*
>
(base);
101
return
this_->
m_mem_func
(this_->
m_obj
);
102
}
103
104
T_obj*
const
&
m_obj
;
105
functor_type
m_mem_func
;
106
};
107
108
109
}
// namespace sigx
110
111
112
#endif // _SIGX_SIGNAL_SOURCE_OBJ_MEM_HPP_
Generated on Mon Oct 1 2012 16:04:09 for sigx++ by
1.8.1.2