HDK
 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 
27 {
28 public:
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:
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
#define PDG_API
Definition: PDG_API.h:23
HandlerSet myHandlers
struct _cl_event * event
Definition: glcorearb.h:2961
long long int64
Definition: SYS_Types.h:116
UT_TBBSpinLock myHandlersLock
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glcorearb.h:1297