HDK
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
UT_NotifierList.h
Go to the documentation of this file.
1
/*
2
* PROPRIETARY INFORMATION. This software is proprietary to
3
* Side Effects Software Inc., and is not to be reproduced,
4
* transmitted, or disclosed in any way without written permission.
5
*
6
* NAME: UT_NotifierList.h ( UT Library, C++)
7
*
8
* COMMENTS: An list that keeps track of the notifiers. It is
9
* used by classes that register callbacks with notifiers.
10
* Its main function is to unregister any callbacks with
11
* all the notifiers that still would invoke them at the
12
* destruction time of the notifier list.
13
*
14
* Notifier list should be a member variable (not a reference
15
* or a pointer to a list) of the class that owns
16
* the methods registered with the notifiers. This way the
17
* destructor of the UT_NotifierList will be invoked when
18
* the class with callbacks is destroyed, and the notifiers
19
* will unregister the callbacks through the UT_NotifierList
20
* destructor.
21
*
22
*
23
* HOW TO SET UP THE NOTIFIER AND THE CALLBACK:
24
*
25
* see UT_Notifier.h for the instructions
26
*/
27
28
#ifndef __UT_NotifierList_h__
29
#define __UT_NotifierList_h__
30
31
#include "
UT_API.h
"
32
#include "
UT_NonCopyable.h
"
33
#include "
UT_ValArray.h
"
34
35
class
UT_Notifier
;
36
37
class
UT_API
UT_NotifierList
38
{
39
public
:
40
// constructor
41
UT_NotifierList
();
42
virtual
~
UT_NotifierList
();
43
44
UT_NON_COPYABLE
(
UT_NotifierList
)
45
46
// ----------------------------------------------------------------------
47
// Removes all notifiers from the private list of notifiers.
48
// Also asks each of these notifiers to remove the observer
49
// associated with this list from the notifier's own list of observers.
50
// ----------------------------------------------------------------------
51
void
removeAllNotifiers();
52
53
54
protected
:
55
56
// NB: only UT_NotifierImpl should call addNotifier() and removeNotifier()
57
// when it registers and unregisters callbacks. We thus make these
58
// two methods protected and make the UT_NotifierImpl the friend
59
// of this class (UT_NotifierList). But, UT_NotifierImpl should not
60
// use any private members, especially the private list itself.
61
template
<
typename
T>
friend
class
UT_NotifierImpl
;
62
63
// adds the notifier to private list of notifiers
64
virtual
void
addNotifier(
UT_Notifier
¬ifier );
65
66
// removes the notifier from private list of notifiers
67
virtual
void
removeNotifier(
UT_Notifier
¬ifier );
68
69
private
:
70
71
// a list of notifiers in which we expressed an interst.
72
// This list is kept around so that when we are destructed, we know
73
// from which notifiers we need to remove interest. Otherwise,
74
// notifiers may use nonexistent observers leading to core dump.
75
UT_ValArray< UT_Notifier * >
myNotifiers;
76
};
77
78
#endif //__UT_NotifierList_h__
UT_NotifierList
Definition:
UT_NotifierList.h:37
UT_API.h
UT_API
#define UT_API
Definition:
UT_API.h:14
UT_ValArray< UT_Notifier * >
UT_ValArray.h
UT_NON_COPYABLE
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
Definition:
UT_NonCopyable.h:31
UT_NonCopyable.h
UT_Notifier
Definition:
UT_Notifier.h:89
UT_NotifierImpl
Definition:
UT_Notifier.h:102
UT
UT_NotifierList.h
Generated on Tue Dec 17 2024 03:42:14 for HDK by
1.8.6