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_EventHandler.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_HANDLER_H__
10
#define __PDG_EVENT_HANDLER_H__
11
12
#include "
PDG_API.h
"
13
14
#include "
PDG_EventTypes.h
"
15
#include "
PDG_RegisteredType.h
"
16
17
#include <
UT/UT_TBBSpinLock.h
>
18
19
class
PDG_Event
;
20
class
PDG_EventEmitter
;
21
22
/*
23
* Base class for an event handler that can be assigned to receive events from
24
* a PDG_EventEmitter. Handlers are registered with the event queue associated
25
* with the emitter.
26
*/
27
class
PDG_API
PDG_EventHandler
28
{
29
public
:
30
/// Constructs a new event handler. The handler keeps track of whether it
31
/// was created by user code or internally by Houdini/TOPs/PDG, to make
32
/// it possible for user to remove all "user created" handlers without
33
/// accidentally removing ones created internally.
34
PDG_EventHandler
(
35
PDG_BaseType::Language
language=
PDG_BaseType::eCpp
,
36
bool
user_handler=
false
);
37
38
/// Destroys the handler and removes it from all active emitters, in case
39
/// the emitter has outlived the life time of the handler
40
virtual
~
PDG_EventHandler
();
41
42
43
/// Removes the handler from all emitters current in its emitter set
44
void
removeFromAllEmitters();
45
46
/// Returns the set of event emitters that this handler is currently
47
/// attached to
48
void
emitters(
PDG_EventEmitterSet
& emitters)
const
;
49
50
51
/// Returns the language that event handler is implemented in. Mostly used
52
/// to distinguish between C++ event handler subclasses and ones created
53
/// using the PDG Python API.
54
PDG_BaseType::Language
language
()
const
55
{
return
myLanguage; }
56
57
/// Returns true if this handler was created in user code
58
bool
isUserHandler
()
const
59
{
return
myIsUserHandler; }
60
61
protected
:
62
/// The main event handling hook, invoked by the event queue each time an
63
/// event for this handler is dispatched. This method must be implemented
64
/// by subclasses.
65
virtual
void
handlePDGEvent(
const
PDG_Event
&) = 0;
66
67
/// Invoke to indicate to subclasses that an emitter is no longer, an has
68
/// been removed from the emitter set.
69
virtual
void
eventEmitterNotAvailable
(
PDG_EventEmitter
*emitter)
70
{};
71
72
private
:
73
friend
class
PDG_EventQueue
;
74
75
void
registerEventEmitter(
PDG_EventEmitter
*emitter);
76
void
unregisterEventEmitter(
77
PDG_EventEmitter
*emitter,
78
bool
notify);
79
80
private
:
81
mutable
UT_TBBSpinLock
myEmittersLock;
82
PDG_EventEmitterSet
myEmitters;
83
PDG_BaseType::Language
myLanguage;
84
bool
myIsUserHandler;
85
};
86
87
#endif
UT::ArraySet
Definition:
UT_ArraySet.h:167
UT_Lockable< tbb::spin_mutex >
PDG_API
#define PDG_API
Definition:
PDG_API.h:23
PDG_EventHandler::eventEmitterNotAvailable
virtual void eventEmitterNotAvailable(PDG_EventEmitter *emitter)
Definition:
PDG_EventHandler.h:69
PDG_EventEmitter
Definition:
PDG_EventEmitter.h:22
UT_TBBSpinLock.h
PDG_Event
Definition:
PDG_Event.h:31
PDG_EventHandler
Definition:
PDG_EventHandler.h:27
PDG_EventTypes.h
PDG_EventHandler::isUserHandler
bool isUserHandler() const
Returns true if this handler was created in user code.
Definition:
PDG_EventHandler.h:58
PDGT_BaseType::Language
Language
Definition:
PDGT_BaseType.h:42
PDG_EventHandler::language
PDG_BaseType::Language language() const
Definition:
PDG_EventHandler.h:54
PDG_API.h
PDG_RegisteredType.h
PDGT_BaseType::eCpp
Definition:
PDGT_BaseType.h:45
PDG_EventQueue
Definition:
PDG_EventQueue.h:35
PDG
PDG_EventHandler.h
Generated on Thu Nov 21 2024 02:44:22 for HDK by
1.8.6