Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
sdk
src
FaspManagerFunctor.h
Go to the documentation of this file.
1
7
#ifndef __FASP_MANAGER_FUNCTOR_H__
8
#define __FASP_MANAGER_FUNCTOR_H__
9
10
#include "
FaspManagerCommon.h
"
11
12
namespace
Aspera
13
{
14
namespace
FaspManager
15
{
16
17
/* Forward declarations */
18
struct
JobStats;
19
struct
FileStats;
20
21
23
class
Functor
24
{
25
/* Member functions */
26
public
:
28
virtual
~Functor
( ) { };
29
33
virtual
Functor
*
Clone
( ) = 0;
34
41
virtual
void
operator()
(
callback_event_e
cb_event,
const
JobStats
* j_stats,
const
FileStats
* f_stats ) = 0;
42
45
// \return true if the two objects are the same
46
virtual
bool
CompareWith
(
const
Functor
* other) = 0;
47
};
48
51
template
<
class
T>
class
CallbackFunctor
:
public
Functor
52
{
53
/* Member variables */
54
private
:
55
T *m_obj_ptr;
/* the pointer to the object */
56
/* the pointer to the member function */
57
void (T::*m_fnct_ptr)(
callback_event_e
cb_event,
const
JobStats
*,
const
FileStats
* );
58
59
/* Member functions */
60
public
:
65
FASP_MANAGER_API
CallbackFunctor
( T *obj,
void
(T::*fnct)(
callback_event_e
cb_event,
const
JobStats
*,
const
FileStats
* ) ):
66
m_obj_ptr( obj ),
67
m_fnct_ptr( fnct )
68
{ };
69
73
FASP_MANAGER_API
CallbackFunctor
(
CallbackFunctor
&functor )
74
:
Functor
()
75
{
76
m_obj_ptr = functor.m_obj_ptr;
77
m_fnct_ptr = functor.m_fnct_ptr;
78
};
79
81
FASP_MANAGER_API
~CallbackFunctor
( ) { };
82
86
FASP_MANAGER_API
Functor
*
Clone
( )
87
{
return
new
CallbackFunctor
( *
this
); };
88
95
FASP_MANAGER_API
void
operator()
(
callback_event_e
cb_event,
const
JobStats
* j_stats,
const
FileStats
* f_stats )
96
{ (m_obj_ptr->*m_fnct_ptr)(cb_event, j_stats, f_stats ); };
97
98
FASP_MANAGER_API
bool
CompareWith
(
const
Functor
* other)
99
{
100
if
(
const
CallbackFunctor
* cbfOther = dynamic_cast<const CallbackFunctor*>(other)) {
101
return
(m_obj_ptr == cbfOther->m_obj_ptr) && (m_fnct_ptr == cbfOther->m_fnct_ptr);
102
}
103
return
false
;
104
}
105
};
106
107
108
}
/* namespace FaspManager */
109
}
/* namespace Aspera */
110
111
#endif
/* __FASP_MANAGER_FUNCTOR_H__ */
Copyright © 2005 - 2008 Aspera, Inc. |
asperasoft.com