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
PDG_EventEmitter.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
* COMMENTS:
7
*/
8
9
#ifndef __PDG_EVENT_EMITTER_H__
10
#define __PDG_EVENT_EMITTER_H__
11
12
#include "
PDG_API.h
"
13
14
#include "
PDG_EventTypes.h
"
15
16
#include <
UT/UT_Array.h
>
17
#include <
UT/UT_ArrayMap.h
>
18
#include <
UT/UT_ArraySet.h
>
19
#include <
UT/UT_ValArray.h
>
20
#include <
UT/UT_TBBSpinLock.h
>
21
22
class
PDG_EventHandler
;
23
class
PDG_Event
;
24
class
PDG_EventQueue
;
25
26
class
PDG_API
PDG_EventEmitter
27
{
28
public
:
29
using
Filter
=
UT_ValArray<PDG_EventType>
;
30
using
FilterMap
=
UT_ArrayMap<PDG_EventHandler *, Filter>
;
31
using
HandlerSet
=
UT_ArraySet<PDG_EventHandler *>
;
32
using
HandlerArray
=
UT_Array<PDG_EventHandler *>
;
33
34
public
:
35
PDG_EventEmitter
(
PDG_EventQueue
* eventQueue,
36
bool
block_destruction);
37
virtual
~
PDG_EventEmitter
();
38
39
/// Returns the list of supported event types for this emitter
40
virtual
Filter
& supportedEventTypes()
const
= 0;
41
42
/// Returns memory usage for this event emitter instance
43
int64
getMemoryUsage(
bool
inclusive)
const
;
44
45
/// Adds an event handlers that listens for all types of events
46
bool
addEventHandler(
PDG_EventHandler
* handler);
47
48
/// Adds an event handlers that listens for a specific event
49
bool
addEventHandler(
PDG_EventHandler
* handler,
50
PDG_EventType
event
);
51
52
/// Adds an event handler with a filter, so that it only listens for
53
/// events in the specified list
54
bool
addEventHandler(
PDG_EventHandler
* handler,
55
const
Filter
&
filter
);
56
57
/// Removes an event handler from this emitter
58
void
removeEventHandler(
PDG_EventHandler
* handler);
59
60
/// Removes all event handlers from this emitter. If user_handler_only
61
/// is true, only user-added event handlers are removed.
62
void
removeAllEventHandlers(
63
bool
user_handler_only =
false
);
64
65
/// Emit an event to all handlers
66
void
emitEvent(
const
PDG_Event
& evt)
const
;
67
68
/// Safely makes a copy of the list of handlers. If this emitter is
69
/// currently being destroyed, the resulting array is empty
70
void
eventHandlers(
HandlerArray
& handlers)
const
;
71
72
void
setEventQueue(
PDG_EventQueue
* eventQueue);
73
void
eventQueueDestroyed();
74
75
protected
:
76
HandlerSet
myHandlers
;
77
FilterMap
myFilters
;
78
mutable
UT_TBBSpinLock
myHandlersLock
;
79
bool
myBeingDestroyedFlag =
false
;
80
81
82
private
:
83
void
doEmitEvent(
const
PDG_Event
& evt)
const
;
84
85
PDG_EventQueue
* myEventQueue =
nullptr
;
86
bool
myWaitEventsWhenDestroyed =
false
;
87
88
friend
class
PDG_EventQueue
;
89
};
90
91
#endif
UT::ArraySet
Definition:
UT_ArraySet.h:166
UT_Lockable< tbb::spin_mutex >
PDG_API
#define PDG_API
Definition:
PDG_API.h:23
PDG_EventEmitter::myHandlers
HandlerSet myHandlers
Definition:
PDG_EventEmitter.h:76
UT_Array.h
UT_ValArray
Definition:
GA_ArrayDataArray.h:33
PDG_EventEmitter
Definition:
PDG_EventEmitter.h:26
UT_Array
Definition:
BV_KDOPTree.h:18
UT::ArrayMap
Definition:
UT_ArrayMap.h:85
UT_TBBSpinLock.h
PDG_EventEmitter::myFilters
FilterMap myFilters
Definition:
PDG_EventEmitter.h:77
event
struct _cl_event * event
Definition:
glcorearb.h:2961
PDG_Event
Definition:
PDG_Event.h:25
PDG_EventHandler
Definition:
PDG_EventHandler.h:21
UT_ArraySet.h
UT_ValArray.h
PDG_EventTypes.h
int64
long long int64
Definition:
SYS_Types.h:116
PDG_API.h
UT_ArrayMap.h
PDG_EventQueue
Definition:
PDG_EventQueue.h:29
PDG_EventEmitter::myHandlersLock
UT_TBBSpinLock myHandlersLock
Definition:
PDG_EventEmitter.h:78
filter
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition:
glcorearb.h:1297
PDG
PDG_EventEmitter.h
Generated on Thu May 9 2024 03:15:31 for HDK by
1.8.6