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_ValArray.h
"
33
34
class
UT_Notifier
;
35
36
class
UT_API
UT_NotifierList
37
{
38
public
:
39
// constructor
40
UT_NotifierList
();
41
virtual
~
UT_NotifierList
();
42
43
// ----------------------------------------------------------------------
44
// Removes all notifiers from the private list of notifiers.
45
// Also asks each of these notifiers to remove the observer
46
// associated with this list from the notifier's own list of observers.
47
// ----------------------------------------------------------------------
48
virtual
void
removeAllNotifiers();
49
50
51
protected
:
52
53
// NB: only UT_NotifierImpl should call addNotifier() and removeNotifier()
54
// when it registers and unregisters callbacks. We thus make these
55
// two methods protected and make the UT_NotifierImpl the friend
56
// of this class (UT_NotifierList). But, UT_NotifierImpl should not
57
// use any private members, especially the private list itself.
58
template
<
typename
T>
friend
class
UT_NotifierImpl
;
59
60
// adds the notifier to private list of notifiers
61
virtual
void
addNotifier(
UT_Notifier
¬ifier );
62
63
// removes the notifier from private list of notifiers
64
virtual
void
removeNotifier(
UT_Notifier
¬ifier );
65
66
private
:
67
68
// a list of notifiers in which we expressed an interst.
69
// This list is kept around so that when we are destructed, we know
70
// from which notifiers we need to remove interest. Otherwise,
71
// notifiers may use nonexistent observers leading to core dump.
72
UT_ValArray< UT_Notifier * >
myNotifiers;
73
};
74
75
#endif //__UT_NotifierList_h__
UT_NotifierList
Definition:
UT_NotifierList.h:36
UT_API.h
UT_API
#define UT_API
Definition:
UT_API.h:13
UT_ValArray< UT_Notifier * >
UT_ValArray.h
UT_Notifier
Definition:
UT_Notifier.h:88
UT_NotifierImpl
Definition:
UT_Notifier.h:97
UT
UT_NotifierList.h
Generated on Tue Jan 19 2021 05:52:56 for HDK by
1.8.6